From e1dfd058cefe8811e3b9d5d018f4c33450c68fbb Mon Sep 17 00:00:00 2001 From: jdgordon Date: Wed, 8 Jul 2009 00:51:03 +0000 Subject: [PATCH] cleanup the remote+main statusbar handling a bit, and fix the bug where the remote wps might reserve the space for the statusbar even if its disabled git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21709 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps.c | 12 +++--------- apps/gui/statusbar.c | 17 +++++++++-------- apps/gui/statusbar.h | 5 +++++ apps/gui/viewport.c | 17 ++--------------- apps/gui/wps_parser.c | 22 +++++++++++++--------- 5 files changed, 32 insertions(+), 41 deletions(-) diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 64b8939ee..95cca5c11 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -245,8 +245,8 @@ static void gwps_fix_statusbars(void) bool draw = false; if (gui_wps[i].data->wps_sb_tag) draw = gui_wps[i].data->show_sb_on_wps; - else if (global_settings.statusbar) - wpsbars |= VP_SB_ONSCREEN(i); + else if (statusbar_position(i) != STATUSBAR_OFF) + draw = true; if (draw) wpsbars |= (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i)); } @@ -937,13 +937,7 @@ static void statusbar_toggle_handler(void *data) } else { - bool bar_at_top = true; -#ifdef HAVE_REMOTE_LCD - if (i == SCREEN_REMOTE) - bar_at_top = global_settings.remote_statusbar != STATUSBAR_BOTTOM; - else -#endif - bar_at_top = global_settings.statusbar != STATUSBAR_BOTTOM; + bool bar_at_top = statusbar_position(i) != STATUSBAR_BOTTOM; vp->y = bar_at_top?STATUSBAR_HEIGHT:0; vp->height = screens[i].lcdheight - STATUSBAR_HEIGHT; } diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index dca416960..47dcb4ead 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -263,17 +263,10 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) memcmp(&(bar->info), &(bar->lastinfo), sizeof(struct status_info))) { struct viewport vp; - bool bar_at_top = true; viewport_set_defaults(&vp, display->screen_type); vp.height = STATUSBAR_HEIGHT; vp.x = STATUSBAR_X_POS; -#ifdef HAVE_REMOTE_LCD - if (display->screen_type == SCREEN_REMOTE) - bar_at_top = global_settings.remote_statusbar != STATUSBAR_BOTTOM; - else -#endif - bar_at_top = global_settings.statusbar != STATUSBAR_BOTTOM; - if (bar_at_top) + if (statusbar_position(display->screen_type) != STATUSBAR_BOTTOM) vp.y = 0; else vp.y = display->lcdheight - STATUSBAR_HEIGHT; @@ -829,3 +822,11 @@ void gui_statusbar_changed(int enabled) (void)enabled; send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL); } +#ifdef HAVE_REMOTE_LCD +int statusbar_position(int screen) +{ + if (screen == SCREEN_REMOTE) + return global_settings.remote_statusbar; + return global_settings.statusbar; +} +#endif diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index db0ff9d78..f346c92f5 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h @@ -99,5 +99,10 @@ struct gui_syncstatusbar extern void gui_syncstatusbar_init(struct gui_syncstatusbar * bars); extern void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars, bool force_redraw); void gui_statusbar_changed(int enabled); +#ifndef HAVE_REMOTE_LCD +#define statusbar_position(a) (global_settings.statusbar) +#else +int statusbar_position(int screen); +#endif #endif /*_GUI_STATUSBAR_H_*/ diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index 81baf1eab..d635c1048 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -53,11 +53,7 @@ static bool showing_bars(enum screen_type screen) { #ifdef HAVE_LCD_BITMAP bool ignore = statusbar_enabled & VP_SB_IGNORE_SETTING(screen); -#ifdef HAVE_REMOTE_LCD - if (screen == SCREEN_REMOTE) - return global_settings.remote_statusbar || ignore; -#endif - return global_settings.statusbar || ignore; + return ignore || (statusbar_position(screen)); #else return true; #endif @@ -67,24 +63,15 @@ static bool showing_bars(enum screen_type screen) void viewport_set_defaults(struct viewport *vp, enum screen_type screen) { -#ifdef HAVE_LCD_BITMAP - bool bar_at_top = true; -#endif vp->x = 0; vp->width = screens[screen].lcdwidth; #ifdef HAVE_LCD_BITMAP vp->drawmode = DRMODE_SOLID; vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ -#ifdef HAVE_REMOTE_LCD - if (screen == SCREEN_REMOTE) - bar_at_top = global_settings.remote_statusbar != STATUSBAR_BOTTOM; - else -#endif - bar_at_top = global_settings.statusbar != STATUSBAR_BOTTOM; vp->height = screens[screen].lcdheight; - if (bar_at_top && showing_bars(screen)) + if (statusbar_position(screen) != STATUSBAR_BOTTOM && showing_bars(screen)) vp->y = STATUSBAR_HEIGHT; else vp->y = 0; diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 14c8d30c6..09bcab844 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -1682,16 +1682,20 @@ bool wps_data_load(struct wps_data *wps_data, /* Initialise the first (default) viewport */ wps_data->viewports[0].vp.x = 0; wps_data->viewports[0].vp.width = display->getwidth(); - if (!global_settings.statusbar) + wps_data->viewports[0].vp.height = display->getheight(); + switch (statusbar_position(display->screen_type)) { - wps_data->viewports[0].vp.y = 0; - wps_data->viewports[0].vp.height = display->getheight(); - } - else - { - wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT; - wps_data->viewports[0].vp.height = display->getheight() - - STATUSBAR_HEIGHT; + case STATUSBAR_OFF: + wps_data->viewports[0].vp.y = 0; + break; + case STATUSBAR_TOP: + wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT; + wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT; + break; + case STATUSBAR_BOTTOM: + wps_data->viewports[0].vp.y = 0; + wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT; + break; } #ifdef HAVE_LCD_BITMAP wps_data->viewports[0].vp.font = FONT_UI; -- 2.11.4.GIT