- performance fix for the new status LED code: only call the gui specific code

to update the status text if there is really a change
- changed the counter resolution to 5 (auto-off still happens after 0.5 seconds)
- the element value -1 is only used to reset the LEDs, so we have to ignore the
  status flags
This commit is contained in:
Volker Ruppert 2011-12-29 16:28:58 +00:00
parent 13506f74ee
commit 32f53b5151
7 changed files with 49 additions and 36 deletions

View File

@ -249,7 +249,7 @@ void bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheig
// register timer for status bar LEDs
if (BX_GUI_THIS led_timer_index == BX_NULL_TIMER_HANDLE) {
BX_GUI_THIS led_timer_index =
DEV_register_timer(this, led_timer_handler, 50000, 1, 1, "status bar LEDs");
DEV_register_timer(this, led_timer_handler, 100000, 1, 1, "status bar LEDs");
}
}
@ -759,6 +759,8 @@ int bx_gui_c::register_statusitem(const char *text, bx_bool auto_off)
statusitem[statusitem_count].text[7] = 0;
statusitem[statusitem_count].auto_off = auto_off;
statusitem[statusitem_count].counter = 0;
statusitem[statusitem_count].active = 0;
statusitem[statusitem_count].mode = 0;
return statusitem_count++;
} else {
return -1;

View File

@ -197,6 +197,7 @@ protected:
int led_timer_index;
struct {
char text[8];
bx_bool active;
bx_bool mode; // read/write
bx_bool auto_off;
Bit8u counter;

View File

@ -335,13 +335,17 @@ void bx_rfb_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w)
{
if (element < 0) {
for (unsigned i = 0; i < statusitem_count; i++) {
rfbSetStatusText(i+1, statusitem[i].text, active, w);
rfbSetStatusText(i+1, statusitem[i].text, 0, 0);
}
} else if ((unsigned)element < statusitem_count) {
rfbSetStatusText(element+1, statusitem[element].text, active, w);
statusitem[element].mode = w;
if ((active != statusitem[element].active) ||
(w != statusitem[element].mode)) {
rfbSetStatusText(element+1, statusitem[element].text, active, w);
statusitem[element].active = active;
statusitem[element].mode = w;
}
if (active && statusitem[element].auto_off) {
statusitem[element].counter = 10;
statusitem[element].counter = 5;
}
}
}

View File

@ -431,13 +431,17 @@ void bx_sdl_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w)
{
if (element < 0) {
for (unsigned i = 0; i < statusitem_count; i++) {
sdl_set_status_text(i+1, statusitem[i].text, active, w);
sdl_set_status_text(i+1, statusitem[i].text, 0, 0);
}
} else if ((unsigned)element < statusitem_count) {
sdl_set_status_text(element+1, statusitem[element].text, active, w);
statusitem[element].mode = w;
if ((active != statusitem[element].active) ||
(w != statusitem[element].mode)) {
sdl_set_status_text(element+1, statusitem[element].text, active, w);
statusitem[element].active = active;
statusitem[element].mode = w;
}
if (active && statusitem[element].auto_off) {
statusitem[element].counter = 10;
statusitem[element].counter = 5;
}
}
}

View File

@ -961,13 +961,17 @@ void bx_win32_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w)
{
if (element < 0) {
for (int i = 0; i < (int)statusitem_count; i++) {
SetStatusText(i+BX_SB_TEXT_ELEMENTS, statusitem[i].text, active, w);
SetStatusText(i+BX_SB_TEXT_ELEMENTS, statusitem[i].text, 0, 0);
}
} else if (element < (int)statusitem_count) {
SetStatusText(element+BX_SB_TEXT_ELEMENTS, statusitem[element].text, active, w);
statusitem[element].mode = w;
if ((active != statusitem[element].active) ||
(w != statusitem[element].mode)) {
SetStatusText(element+BX_SB_TEXT_ELEMENTS, statusitem[element].text, active, w);
statusitem[element].active = active;
statusitem[element].mode = w;
}
if (active && statusitem[element].auto_off) {
statusitem[element].counter = 10;
statusitem[element].counter = 5;
}
}
}

View File

@ -1083,34 +1083,28 @@ void bx_wx_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w)
wxMutexGuiEnter();
if (element < 0) {
for (unsigned i = 0; i < statusitem_count; i++) {
if (active) {
#if defined(__WXMSW__)
status_text[0] = 9;
strcpy(status_text+1, statusitem[i].text);
theFrame->SetStatusText(status_text, i+1);
#else
theFrame->SetStatusText(wxString(statusitem[i].text, wxConvUTF8), i+1);
#endif
} else {
theFrame->SetStatusText(wxT(""), i+1);
}
theFrame->SetStatusText(wxT(""), i+1);
}
} else if ((unsigned)element < statusitem_count) {
if (active) {
if ((active != statusitem[element].active) ||
(w != statusitem[element].mode)) {
if (active) {
#if defined(__WXMSW__)
status_text[0] = 9;
strcpy(status_text+1, statusitem[element].text);
theFrame->SetStatusText(status_text, element+1);
#else
theFrame->SetStatusText(wxString(statusitem[element].text, wxConvUTF8),
element+1);
theFrame->SetStatusText(wxString(statusitem[element].text, wxConvUTF8),
element+1);
#endif
statusitem[element].mode = w;
if (active && statusitem[element].auto_off) {
statusitem[element].counter = 10;
} else {
theFrame->SetStatusText(wxT(""), element+1);
}
} else {
theFrame->SetStatusText(wxT(""), element+1);
statusitem[element].active = active;
statusitem[element].mode = w;
}
if (active && statusitem[element].auto_off) {
statusitem[element].counter = 5;
}
}
wxMutexGuiLeave();

View File

@ -712,13 +712,17 @@ void bx_x_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w)
{
if (element < 0) {
for (unsigned i = 0; i < statusitem_count; i++) {
set_status_text(i+1, statusitem[i].text, active, w);
set_status_text(i+1, statusitem[i].text, 0, 0);
}
} else if ((unsigned)element < statusitem_count) {
set_status_text(element+1, statusitem[element].text, active, w);
statusitem[element].mode = w;
if ((active != statusitem[element].active) ||
(w != statusitem[element].mode)) {
set_status_text(element+1, statusitem[element].text, active, w);
statusitem[element].active = active;
statusitem[element].mode = w;
}
if (active && statusitem[element].auto_off) {
statusitem[element].counter = 10;
statusitem[element].counter = 5;
}
}
}