From 19f44a61cfb333c363d823e43b5de282ef2d2ed0 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 23 Aug 2009 23:44:31 +0000 Subject: [PATCH] Fix redraw issues when the statusbar setting was changed with an UI viewport. Now the old statusbar area is cleared upon changing the setting. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22484 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/statusbar.c | 50 ++++++++++++++++++++++++++++++--------- apps/gui/statusbar.h | 9 +++++-- apps/menus/display_menu.c | 34 +++++++++++++++++++++++--- apps/settings.h | 4 +--- apps/settings_list.c | 4 ++-- 5 files changed, 80 insertions(+), 21 deletions(-) diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index 024ade330f..1a724406ef 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -34,6 +34,7 @@ #include "powermgmt.h" #include "usb.h" #include "led.h" +#include "screen_access.h" #include "status.h" /* needed for battery_state global var */ #include "action.h" /* for keys_locked */ @@ -172,13 +173,23 @@ static void gui_statusbar_init(struct gui_statusbar * bar) #endif } +#define GET_RECT(vp, vals,display) do { \ + viewport_set_fullscreen(&(vp), (display)->screen_type); \ + (vp).height = STATUSBAR_HEIGHT; \ + (vp).x = STATUSBAR_X_POS; \ + if ((vals) != STATUSBAR_BOTTOM) \ + (vp).y = 0; \ + else \ + (vp).y = (display)->lcdheight - STATUSBAR_HEIGHT; \ + } while(0) + void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) { struct screen * display = bar->display; #ifdef HAVE_LCD_CHARCELLS int val; - (void)force_redraw; /* players always "redraw" */ + (void)force_redraw; /* The Player always has "redraw" */ #endif /* HAVE_LCD_CHARCELLS */ bar->info.battlevel = battery_level(); @@ -263,13 +274,8 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) memcmp(&(bar->info), &(bar->lastinfo), sizeof(struct status_info))) { struct viewport vp; - viewport_set_fullscreen(&vp, display->screen_type); - vp.height = STATUSBAR_HEIGHT; - vp.x = STATUSBAR_X_POS; - if (statusbar_position(display->screen_type) != STATUSBAR_BOTTOM) - vp.y = 0; - else - vp.y = display->lcdheight - STATUSBAR_HEIGHT; + + GET_RECT(vp,statusbar_position(display->screen_type),display); display->set_viewport(&vp); display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); display->fillrect(0, 0, display->getwidth(), STATUSBAR_HEIGHT); @@ -816,11 +822,33 @@ void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars, } } -void gui_statusbar_changed(int enabled) +#ifdef HAVE_LCD_BITMAP +void gui_statusbar_changed( enum screen_type screen, + enum statusbar_values old) { - (void)enabled; - send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL); + /* clear and update the statusbar area to remove old parts */ + enum statusbar_values bar; +#ifdef HAVE_REMOTE_LCD + if (screen == SCREEN_REMOTE) + bar = global_settings.remote_statusbar; + else +#endif + bar = global_settings.statusbar; + + struct screen *display = &screens[screen]; + struct viewport vp; + + if (old != STATUSBAR_OFF && old != bar) + { + GET_RECT(vp, old, display); + display->set_viewport(&vp); + display->clear_viewport(); + display->update_viewport(); + display->set_viewport(NULL); + } } +#endif + #ifdef HAVE_REMOTE_LCD int statusbar_position(int screen) { diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index c2829a029b..169b76b15a 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h @@ -54,6 +54,9 @@ struct status_info { }; +/* statusbar visibility/position, used for settings also */ +enum statusbar_values { STATUSBAR_OFF = 0, STATUSBAR_TOP, STATUSBAR_BOTTOM }; + struct gui_statusbar { long battery_icon_switch_tick; @@ -97,8 +100,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); +extern void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars, + bool force_redraw); +void gui_statusbar_changed(enum screen_type screen, + enum statusbar_values old); #if !defined(HAVE_REMOTE_LCD) || defined(__PCTOOL__) #define statusbar_position(a) (global_settings.statusbar) #else diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c index 24e36e5fca..0b2769831e 100644 --- a/apps/menus/display_menu.c +++ b/apps/menus/display_menu.c @@ -40,6 +40,7 @@ #include "screens.h" #endif #include "viewport.h" +#include "statusbar.h" /* statusbar_vals enum*/ #ifdef HAVE_BACKLIGHT static int filterfirstkeypress_callback(int action,const struct menu_item_ex *this_item) @@ -307,23 +308,50 @@ MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, Icon_NOICON, /***********************************/ /* BARS MENU */ #ifdef HAVE_LCD_BITMAP -static int statusbar_callback(int action,const struct menu_item_ex *this_item) +static int statusbar_callback_ex(int action,const struct menu_item_ex *this_item, + enum screen_type screen) { (void)this_item; + /* we save the old statusbar value here, so the old statusbars can get + * removed and cleared from the display properly on exiting + * (in gui_statusbar_changed() ) */ + static enum statusbar_values old_bar[NB_SCREENS]; switch (action) { + case ACTION_ENTER_MENUITEM: +#ifdef HAVE_REMOTE_LCD + if (screen == SCREEN_REMOTE) + old_bar[screen] = global_settings.remote_statusbar; + else +#endif + old_bar[screen] = global_settings.statusbar; + break; case ACTION_EXIT_MENUITEM: + gui_statusbar_changed(screen, old_bar[screen]); send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL); send_event(GUI_EVENT_ACTIONUPDATE, (void*)true); break; } return action; } + +#ifdef HAVE_REMOTE_LCD +static int statusbar_callback_remote(int action,const struct menu_item_ex *this_item) +{ + return statusbar_callback_ex(action, this_item, SCREEN_REMOTE); +} +#endif +static int statusbar_callback(int action,const struct menu_item_ex *this_item) +{ + return statusbar_callback_ex(action, this_item, SCREEN_MAIN); +} MENUITEM_SETTING(scrollbar_item, &global_settings.scrollbar, NULL); MENUITEM_SETTING(scrollbar_width, &global_settings.scrollbar_width, NULL); -MENUITEM_SETTING(statusbar, &global_settings.statusbar, statusbar_callback); +MENUITEM_SETTING(statusbar, &global_settings.statusbar, + statusbar_callback); #ifdef HAVE_REMOTE_LCD -MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar, statusbar_callback); +MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar, + statusbar_callback_remote); #endif #if CONFIG_KEYPAD == RECORDER_PAD MENUITEM_SETTING(buttonbar, &global_settings.buttonbar, NULL); diff --git a/apps/settings.h b/apps/settings.h index cbd7b6d3b3..1365736ecf 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -26,6 +26,7 @@ #include #include "inttypes.h" #include "config.h" +#include "statusbar.h" /* for the statusbar values */ #include "button.h" #if CONFIG_CODEC == SWCODEC #include "audio.h" @@ -156,9 +157,6 @@ enum { REPLAYGAIN_TRACK = 0, REPLAYGAIN_ALBUM, REPLAYGAIN_SHUFFLE, REPLAYGAIN_OF /* show path types */ enum { SHOW_PATH_OFF = 0, SHOW_PATH_CURRENT, SHOW_PATH_FULL }; -/* statusbar visibility/position */ -enum { STATUSBAR_OFF = 0, STATUSBAR_TOP, STATUSBAR_BOTTOM }; - /* scrollbar visibility/position */ enum { SCROLLBAR_OFF = 0, SCROLLBAR_LEFT, SCROLLBAR_RIGHT }; diff --git a/apps/settings_list.c b/apps/settings_list.c index 450d0eada4..23424f94cc 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -604,12 +604,12 @@ const struct settings_list settings[] = { #endif CHOICE_SETTING(F_THEMESETTING|F_TEMPVAR, statusbar, LANG_STATUS_BAR, STATUSBAR_TOP, "statusbar","off,top,bottom", - gui_statusbar_changed, 3, ID2P(LANG_OFF), ID2P(LANG_STATUSBAR_TOP), + NULL, 3, ID2P(LANG_OFF), ID2P(LANG_STATUSBAR_TOP), ID2P(LANG_STATUSBAR_BOTTOM)), #ifdef HAVE_REMOTE_LCD CHOICE_SETTING(F_THEMESETTING|F_TEMPVAR, remote_statusbar, LANG_REMOTE_STATUSBAR, STATUSBAR_TOP, "remote statusbar","off,top,bottom", - gui_statusbar_changed, 3, ID2P(LANG_OFF), ID2P(LANG_STATUSBAR_TOP), + NULL, 3, ID2P(LANG_OFF), ID2P(LANG_STATUSBAR_TOP), ID2P(LANG_STATUSBAR_BOTTOM)), #endif CHOICE_SETTING(F_TEMPVAR, scrollbar,