From 0a9ea1b4875dec08b961c2fe35ddc9ae49b17256 Mon Sep 17 00:00:00 2001 From: jdgordon Date: Mon, 21 Dec 2009 05:19:12 +0000 Subject: [PATCH] fix FS#10870 - slightly change the viewportmanager theme undo-er to be able to force an update even if the theme isnt being toggled from off to on which caused WPS artifacts when leaving the WPS if the theme was enabled git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24087 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 2 +- apps/gui/list.c | 2 +- apps/gui/splash.c | 2 +- apps/gui/usb_screen.c | 2 +- apps/gui/viewport.c | 97 +++++++++++++++++++++++------------------------- apps/gui/viewport.h | 6 ++- apps/gui/wps.c | 11 +++++- apps/menu.c | 2 +- apps/menus/eq_menu.c | 2 +- apps/menus/theme_menu.c | 4 +- apps/plugin.c | 2 +- apps/recorder/keyboard.c | 2 +- apps/screens.c | 2 +- 13 files changed, 72 insertions(+), 64 deletions(-) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 74169301e..2691d2dc8 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -2665,7 +2665,7 @@ static int menu_action_callback(int btn, struct gui_synclist *lists) menuitems[gui_synclist_get_sel_pos(lists)].function(); btn = ACTION_REDRAW; FOR_NB_SCREENS(i) - viewportmanager_theme_undo(i); + viewportmanager_theme_undo(i, false); } return btn; } diff --git a/apps/gui/list.c b/apps/gui/list.c index eacebb5c3..8e350b514 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -908,7 +908,7 @@ bool simplelist_show_list(struct simplelist_info *info) } talk_shutup(); FOR_NB_SCREENS(i) - viewportmanager_theme_undo(i); + viewportmanager_theme_undo(i, false); return false; } diff --git a/apps/gui/splash.c b/apps/gui/splash.c index 39d224a74..7e4617bb7 100644 --- a/apps/gui/splash.c +++ b/apps/gui/splash.c @@ -212,7 +212,7 @@ void splashf(int ticks, const char *fmt, ...) if (ticks) sleep(ticks); FOR_NB_SCREENS(i) - viewportmanager_theme_undo(i); + viewportmanager_theme_undo(i, false); } void splash(int ticks, const char *str) diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c index fb09d3ea6..338cb0fe4 100644 --- a/apps/gui/usb_screen.c +++ b/apps/gui/usb_screen.c @@ -320,7 +320,7 @@ void gui_usb_screen_run(void) screens[i].backlight_on(); if(screen_theme_needs_undo[i]) { - viewportmanager_theme_undo(i); + viewportmanager_theme_undo(i, false); } } diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index 6e8491d11..6e0d26922 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -69,7 +69,7 @@ static int theme_stack_top[NB_SCREENS]; /* the last item added */ static struct viewport_stack_item theme_stack[NB_SCREENS][VPSTACK_DEPTH]; static bool is_theme_enabled(enum screen_type screen); -static void toggle_theme(void) +static void toggle_theme(enum screen_type screen, bool force) { bool enable_event = false; static bool was_enabled[NB_SCREENS] = {false}; @@ -91,53 +91,50 @@ static void toggle_theme(void) /* remove the left overs from the previous screen. * could cause a tiny flicker. Redo your screen code if that happens */ - FOR_NB_SCREENS(i) + if (!was_enabled[screen] || force) { - if (!was_enabled[i]) + struct viewport deadspace, user; + viewport_set_defaults(&user, screen); + deadspace = user; /* get colours and everything */ + /* above */ + deadspace.x = 0; + deadspace.y = 0; + deadspace.width = screens[screen].lcdwidth; + deadspace.height = user.y; + if (deadspace.width && deadspace.height) + { + screens[screen].set_viewport(&deadspace); + screens[screen].clear_viewport(); + screens[screen].update_viewport(); + } + /* below */ + deadspace.y = user.y + user.height; + deadspace.height = screens[screen].lcdheight - deadspace.y; + if (deadspace.width && deadspace.height) + { + screens[screen].set_viewport(&deadspace); + screens[screen].clear_viewport(); + screens[screen].update_viewport(); + } + /* left */ + deadspace.x = 0; + deadspace.y = 0; + deadspace.width = user.x; + deadspace.height = screens[screen].lcdheight; + if (deadspace.width && deadspace.height) + { + screens[screen].set_viewport(&deadspace); + screens[screen].clear_viewport(); + screens[screen].update_viewport(); + } + /* below */ + deadspace.x = user.x + user.width; + deadspace.width = screens[screen].lcdwidth - deadspace.x; + if (deadspace.width && deadspace.height) { - struct viewport deadspace, user; - viewport_set_defaults(&user, i); - deadspace = user; /* get colours and everything */ - /* above */ - deadspace.x = 0; - deadspace.y = 0; - deadspace.width = screens[i].lcdwidth; - deadspace.height = user.y; - if (deadspace.width && deadspace.height) - { - screens[i].set_viewport(&deadspace); - screens[i].clear_viewport(); - screens[i].update_viewport(); - } - /* below */ - deadspace.y = user.y + user.height; - deadspace.height = screens[i].lcdheight - deadspace.y; - if (deadspace.width && deadspace.height) - { - screens[i].set_viewport(&deadspace); - screens[i].clear_viewport(); - screens[i].update_viewport(); - } - /* left */ - deadspace.x = 0; - deadspace.y = 0; - deadspace.width = user.x; - deadspace.height = screens[i].lcdheight; - if (deadspace.width && deadspace.height) - { - screens[i].set_viewport(&deadspace); - screens[i].clear_viewport(); - screens[i].update_viewport(); - } - /* below */ - deadspace.x = user.x + user.width; - deadspace.width = screens[i].lcdwidth - deadspace.x; - if (deadspace.width && deadspace.height) - { - screens[i].set_viewport(&deadspace); - screens[i].clear_viewport(); - screens[i].update_viewport(); - } + screens[screen].set_viewport(&deadspace); + screens[screen].clear_viewport(); + screens[screen].update_viewport(); } } send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */ @@ -167,19 +164,19 @@ void viewportmanager_theme_enable(enum screen_type screen, bool enable, panicf("Stack overflow... viewportmanager"); theme_stack[screen][top].enabled = enable; theme_stack[screen][top].vp = viewport; - toggle_theme(); + toggle_theme(screen, false); /* then be nice and set the viewport up */ if (viewport) viewport_set_defaults(viewport, screen); } -void viewportmanager_theme_undo(enum screen_type screen) +void viewportmanager_theme_undo(enum screen_type screen, bool force_redraw) { int top = --theme_stack_top[screen]; if (top < 0) panicf("Stack underflow... viewportmanager"); - toggle_theme(); + toggle_theme(screen, force_redraw); } @@ -259,7 +256,7 @@ void viewportmanager_theme_changed(const int which) /* This can probably be done better... * disable the theme so it's forced to do a full redraw */ viewportmanager_theme_enable(i, false, NULL); - viewportmanager_theme_undo(i); + viewportmanager_theme_undo(i, true); } } send_event(GUI_EVENT_THEME_CHANGED, NULL); diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h index 6cb8d1f57..fffd2fedf 100644 --- a/apps/gui/viewport.h +++ b/apps/gui/viewport.h @@ -53,8 +53,10 @@ void viewport_set_fullscreen(struct viewport *vp, #ifdef HAVE_LCD_BITMAP void viewportmanager_theme_enable(enum screen_type screen, bool enable, struct viewport *viewport); - -void viewportmanager_theme_undo(enum screen_type screen); +/* Force will cause a redraw even if the theme was previously and + * currently enabled (i,e the undo doing nothing). + * Should almost always be set to false except coming out of fully skinned screens */ +void viewportmanager_theme_undo(enum screen_type screen, bool force_redraw); /* call this when a theme changed */ void viewportmanager_theme_changed(const int); diff --git a/apps/gui/wps.c b/apps/gui/wps.c index e500f1c2d..f6bcd7845 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -565,7 +565,16 @@ static void gwps_leave_wps(void) { gui_wps[i].display->stop_scroll(); gui_wps[i].display->backdrop_show(BACKDROP_MAIN); - viewportmanager_theme_undo(i); + + bool draw = false; +#ifdef HAVE_LCD_BITMAP + if (gui_wps[i].data->wps_sb_tag) + draw = gui_wps[i].data->show_sb_on_wps; + else if (statusbar_position(i) != STATUSBAR_OFF) + draw = true; +#endif + viewportmanager_theme_undo(i, draw); + } #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) diff --git a/apps/menu.c b/apps/menu.c index 951238e17..88f0f3c52 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -687,7 +687,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, gui_synclist_get_sel_pos(&lists), menu); } FOR_NB_SCREENS(i) - viewportmanager_theme_undo(i); + viewportmanager_theme_undo(i, false); return ret; } diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c index 1fc176213..05ee3f363 100644 --- a/apps/menus/eq_menu.c +++ b/apps/menus/eq_menu.c @@ -576,7 +576,7 @@ bool eq_menu_graphical(void) screens[i].setfont(FONT_UI); screens[i].clear_display(); screens[i].set_viewport(NULL); - viewportmanager_theme_undo(i); + viewportmanager_theme_undo(i, false); } return result; } diff --git a/apps/menus/theme_menu.c b/apps/menus/theme_menu.c index 9c9a2b2c7..777ab7f81 100644 --- a/apps/menus/theme_menu.c +++ b/apps/menus/theme_menu.c @@ -51,7 +51,7 @@ static int clear_main_backdrop(void) backdrop_show(BACKDROP_MAIN); /* force a full redraw so the whole backdrop is cleared */ viewportmanager_theme_enable(SCREEN_MAIN, false, NULL); - viewportmanager_theme_undo(SCREEN_MAIN); + viewportmanager_theme_undo(SCREEN_MAIN, false); settings_save(); return 0; } @@ -165,7 +165,7 @@ static int statusbar_callback_ex(int action,const struct menu_item_ex *this_item send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL); /* force a full redraw */ viewportmanager_theme_enable(screen, false, NULL); - viewportmanager_theme_undo(screen); + viewportmanager_theme_undo(screen, false); break; } return ACTION_REDRAW; diff --git a/apps/plugin.c b/apps/plugin.c index 7c7c7adf0..ca2313472 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -835,7 +835,7 @@ int plugin_load(const char* plugin, const void* parameter) #endif FOR_NB_SCREENS(i) - viewportmanager_theme_undo(i); + viewportmanager_theme_undo(i, false); if (pfn_tsr_exit == NULL) plugin_loaded = false; diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 4d59a85bb..1ca006973 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c @@ -1128,7 +1128,7 @@ int kbd_input(char* text, int buflen) FOR_NB_SCREENS(l) { screens[l].setfont(FONT_UI); - viewportmanager_theme_undo(l); + viewportmanager_theme_undo(l, false); } return ret; } diff --git a/apps/screens.c b/apps/screens.c index bed7d9d90..d99759062 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -930,7 +930,7 @@ int calibrate(void) sizeof(struct touchscreen_parameter)); touchscreen_set_mode(old_mode); - viewportmanager_theme_undo(SCREEN_MAIN); + viewportmanager_theme_undo(SCREEN_MAIN, false); settings_save(); return ret; -- 2.11.4.GIT