Skip to content

Commit

Permalink
Avoid to flash the cursor on request
Browse files Browse the repository at this point in the history
  • Loading branch information
amadvance committed Jun 20, 2018
1 parent f7b3f11 commit 95397e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions advance/menu/text.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,7 @@ class cell_manager {
void backdrop_update(int index);
unsigned backdrop_topline(int index);
void backdrop_box();
bool is_box_flashing();
void backdrop_redraw_all();

void clip_set(int index, const resource& res, unsigned aspectx, unsigned aspecty, bool restart);
Expand Down Expand Up @@ -2127,6 +2128,13 @@ static void box(int x, int y, int dx, int dy, int width, const adv_color_rgb& co
video_clear(x + dx - width, y + width, width, dy - 2 * width, pixel);
}

bool cell_manager::is_box_flashing()
{
return backdrop_box_color.foreground.red != backdrop_box_color.background.red
|| backdrop_box_color.foreground.green != backdrop_box_color.background.green
|| backdrop_box_color.foreground.blue != backdrop_box_color.background.blue;
}

void cell_manager::backdrop_box()
{
if (!backdrop_cursor)
Expand Down Expand Up @@ -2251,7 +2259,7 @@ bool cell_manager::idle()
// update all the clip
for (unsigned i = 0; i < backdrop_mac; ++i) {
target_clock_t backdrop_box_new = target_clock();
if (backdrop_box_new >= backdrop_box_last + TARGET_CLOCKS_PER_SEC / 20) {
if (!is_box_flashing() || backdrop_box_new >= backdrop_box_last + TARGET_CLOCKS_PER_SEC / 20) {
backdrop_box_last = backdrop_box_new;
backdrop_box();
}
Expand All @@ -2275,7 +2283,7 @@ bool cell_manager::idle()
}

target_clock_t backdrop_box_new = target_clock();
if (backdrop_box_new >= backdrop_box_last + TARGET_CLOCKS_PER_SEC / 20) {
if (!is_box_flashing() || backdrop_box_new >= backdrop_box_last + TARGET_CLOCKS_PER_SEC / 20) {
backdrop_box_last = backdrop_box_new;
backdrop_box();
}
Expand Down
3 changes: 2 additions & 1 deletion doc/advmenu.d
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,8 @@ Configuration
submenu_hidden - Submenu hidden entry.
submenu_hidden_select - Submenu selected hidden entry.
icon - Icon outline and missing icon.
cursor - Flashing cursor.
cursor - Flashing cursor. Use equal foreground and background to
avoid flashing.

Options:
FOREGROUND - Foreground color in RRGGBB
Expand Down
2 changes: 2 additions & 0 deletions doc/history.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ AdvanceMENU Version 3.8 2018/06
) Added a new 'exit' event to separate the exit action from the
generic esc one. Ensure to change also misc_exit to make this
command to work.
) Avoid to flash the cursor if it has equal foreground and background
color.

AdvanceMAME/MESS Version 3.7 2018/02
) In the Exit menu added new Load/Save/Reset commands.
Expand Down

0 comments on commit 95397e6

Please sign in to comment.