From 95397e67f5768e5ff08452830362056bec8dcc19 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 20 Jun 2018 22:59:36 +0200 Subject: [PATCH] Avoid to flash the cursor on request --- advance/menu/text.cc | 12 ++++++++++-- doc/advmenu.d | 3 ++- doc/history.d | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/advance/menu/text.cc b/advance/menu/text.cc index e1ba0ba36..93fc22bea 100644 --- a/advance/menu/text.cc +++ b/advance/menu/text.cc @@ -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); @@ -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) @@ -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(); } @@ -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(); } diff --git a/doc/advmenu.d b/doc/advmenu.d index a8072295e..0b81cf5be 100644 --- a/doc/advmenu.d +++ b/doc/advmenu.d @@ -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 diff --git a/doc/history.d b/doc/history.d index 02ef05dff..1ca75f9c0 100644 --- a/doc/history.d +++ b/doc/history.d @@ -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.