Index: apps/gui/statusbar-skinned.c =================================================================== --- apps/gui/statusbar-skinned.c (revision 23718) +++ apps/gui/statusbar-skinned.c (working copy) @@ -126,7 +126,7 @@ queue_post(&button_queue, BUTTON_NONE, 0); } - +#if 0 void sb_skin_set_state(int state, enum screen_type screen) { sb_skin[screen].sync_data->do_full_update = true; @@ -163,7 +163,7 @@ sb_skin[screen].sync_data->statusbars = skinbars; } - +#endif static void sb_skin_update(void* param) { static long next_update = 0; @@ -209,7 +209,6 @@ /* Currently no seperate wps_state needed/possible so use the only available ( "global" ) one */ sb_skin[i].state = &wps_state; - sb_skin_sync_data.statusbars = VP_SB_HIDE_ALL; sb_skin[i].sync_data = &sb_skin_sync_data; } } Index: apps/gui/wps.c =================================================================== --- apps/gui/wps.c (revision 23718) +++ apps/gui/wps.c (working copy) @@ -88,9 +88,6 @@ static void wps_state_init(void); static void track_changed_callback(void *param); static void nextid3available_callback(void* param); -#ifdef HAVE_LCD_BITMAP -static void statusbar_toggle_handler(void *data); -#endif #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" #ifdef HAVE_REMOTE_LCD @@ -562,17 +559,15 @@ static void gwps_leave_wps(void) { - int i, oldbars = VP_SB_HIDE_ALL; + int i; FOR_NB_SCREENS(i) { gui_wps[i].display->stop_scroll(); gui_wps[i].display->backdrop_show(BACKDROP_MAIN); - if (statusbar_position(i) != STATUSBAR_OFF) - oldbars |= VP_SB_ONSCREEN(i); + viewportmanager_theme_undo(i, NULL); } - viewportmanager_set_statusbar(oldbars); #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) /* Play safe and unregister the hook */ remove_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook); @@ -1271,33 +1266,6 @@ } -#ifdef HAVE_LCD_BITMAP -static void statusbar_toggle_handler(void *data) -{ - (void)data; - int i; - - int *wpsbars = &wps_sync_data.statusbars; - *wpsbars = VP_SB_HIDE_ALL; - FOR_NB_SCREENS(i) - { /* fix viewports if needed */ - skin_statusbar_changed(&gui_wps[i]); - - bool draw = false; - - /* fix up gui_wps::statusbars, so that the viewportmanager accepts it*/ - 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; - if (draw) - *wpsbars |= - (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i)); - } -} -#endif - - void gui_sync_wps_init(void) { int i; @@ -1315,11 +1283,7 @@ gui_wps[i].display->backdrop_unload(BACKDROP_SKIN_WPS); /* must point to the same struct for both screens */ gui_wps[i].sync_data = &wps_sync_data; - gui_wps[i].sync_data->statusbars = VP_SB_ALLSCREENS; } -#ifdef HAVE_LCD_BITMAP - add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggle_handler); -#endif } Index: apps/gui/list.c =================================================================== --- apps/gui/list.c (revision 23718) +++ apps/gui/list.c (working copy) @@ -822,14 +822,17 @@ bool simplelist_show_list(struct simplelist_info *info) { struct gui_synclist lists; - int action, old_line_count = simplelist_line_count; - int oldbars = viewportmanager_set_statusbar(VP_SB_ALLSCREENS); + int action, old_line_count = simplelist_line_count, i; const char* (*getname)(int item, void * data, char *buffer, size_t buffer_len); int wrap = LIST_WRAP_UNLESS_HELD; if (info->get_name) getname = info->get_name; else getname = simplelist_static_getname; + + FOR_NB_SCREENS(i) + viewportmanager_theme_enable(i, true, NULL); + gui_synclist_init(&lists, getname, info->callback_data, info->scroll_all, info->selection_size, NULL); @@ -904,7 +907,8 @@ return true; } talk_shutup(); - viewportmanager_set_statusbar(oldbars); + FOR_NB_SCREENS(i) + viewportmanager_theme_undo(i, NULL); return false; } Index: apps/gui/viewport.c =================================================================== --- apps/gui/viewport.c (revision 23718) +++ apps/gui/viewport.c (working copy) @@ -28,6 +28,7 @@ #include "screen_access.h" #include "settings.h" #include "misc.h" +#include "panicf.h" /*some short cuts for fg/bg/line selector handling */ #ifdef HAVE_LCD_COLOR @@ -57,15 +58,56 @@ #include "statusbar-skinned.h" #include "debug.h" +#define VPSTACK_DEPTH 16 +struct viewport_stack_item +{ + struct viewport* vp; + bool enabled; +}; + +static int theme_stack_top[NB_SCREENS]; +static struct viewport_stack_item theme_stack[NB_SCREENS][VPSTACK_DEPTH]; -static int statusbar_enabled = 0; -#ifdef HAVE_LCD_BITMAP -static struct { - struct viewport* vp; - int active[NB_SCREENS]; -} ui_vp_info; +void viewportmanager_theme_enable(enum screen_type screen, bool enable, + struct viewport *viewport) +{ + int top = theme_stack_top[screen]; + if (top >= VPSTACK_DEPTH-1) + panicf("Stack overflow... viewportmanager"); + theme_stack[screen][top].enabled = enable; + theme_stack[screen][top].vp = viewport; + theme_stack_top[screen]++; + + /* do something here probably */ + + /* then be nice and set the viewport up */ + if (viewport) /* this should only be allowed in viewport init(), or maybe not */ + viewport_set_defaults(screen, viewport); +} +void viewportmanager_theme_undo(enum screen_type screen, + const struct viewport *viewport) +{ + int top = theme_stack_top[screen]; + if (top < 0) + panicf("Stack underflow... viewportmanager"); + if (theme_stack[screen][top].vp && + theme_stack[screen][top].vp != viewport) + { + /* this is sort of an error condition here... */ + } + theme_stack_top[screen]--; +} + +static bool is_theme_enabled(enum screen_type screen) +{ + return theme_stack[screen][theme_stack_top[screen]].enabled; +} + + +#ifdef HAVE_LCD_BITMAP +static bool custom_vp_loaded_ok[NB_SCREENS]; static struct viewport custom_vp[NB_SCREENS]; /* callbacks for GUI_EVENT_* events */ @@ -86,64 +128,17 @@ #endif } -static bool showing_bars(enum screen_type screen) -{ - if (statusbar_enabled & VP_SB_ONSCREEN(screen)) - { -#ifdef HAVE_LCD_BITMAP - int ignore; - ignore = statusbar_enabled & VP_SB_IGNORE_SETTING(screen); - return ignore || (statusbar_position(screen) != STATUSBAR_OFF); -#else - return true; -#endif - } - return false; -} - - void viewportmanager_init(void) { -#ifdef HAVE_LCD_BITMAP - add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggled); -#endif - viewportmanager_set_statusbar(VP_SB_ALLSCREENS); + int i; + FOR_NB_SCREENS(i) + { + theme_stack_top[i] = 0; + /* We always want the theme enabled by default... */ + viewportmanager_theme_enable(i, true, NULL); + } } -int viewportmanager_get_statusbar(void) -{ - return statusbar_enabled; -} - -int viewportmanager_set_statusbar(const int enabled) -{ - int old = statusbar_enabled; - int i; - - statusbar_enabled = enabled; - - FOR_NB_SCREENS(i) - { - if (showing_bars(i) - && statusbar_position(i) != STATUSBAR_CUSTOM) - { - add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw); - gui_statusbar_draw(&statusbars.statusbars[i], true); - } - else - remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw); - } - -#ifdef HAVE_LCD_BITMAP - FOR_NB_SCREENS(i) - { - sb_skin_set_state(showing_bars(i) - && statusbar_position(i) == STATUSBAR_CUSTOM, i); - } -#endif - return old; -} - static void viewportmanager_redraw(void* data) { int i; @@ -280,15 +275,13 @@ else #endif setting = global_settings.ui_vp_config; - - if (!(viewport_parse_viewport(&custom_vp[screen], screen, - setting, ','))) - viewport_set_fullscreen(&custom_vp[screen], screen); - else - ret |= BIT_N(screen); + ret = viewport_parse_viewport(&custom_vp[screen], screen, + setting, ','); + + custom_vp_loaded_ok[screen] = ret > 0; } - return ret; + return true; /* meh fixme */ } #ifdef HAVE_TOUCHSCREEN @@ -311,7 +304,7 @@ #endif -void viewport_set_fullscreen(struct viewport *vp, +static void viewport_set_fullscreen(struct viewport *vp, const enum screen_type screen) { vp->x = 0; @@ -363,11 +356,17 @@ #if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__) struct viewport *sbs_area = NULL, *user_setting = NULL; + if (!is_theme_enabled(screen)) + { + viewport_set_fullscreen(vp, screen); + return; + } /* get the two viewports */ - if (ui_vp_info.active[screen]) - user_setting = &ui_vp_info.vp[screen]; + if (custom_vp_loaded_ok[screen]) + user_setting = &custom_vp[screen]; if (sb_skin_get_state(screen)) sbs_area = sb_skin_get_info_vp(screen); + /* have both? get their intersection */ if (sbs_area && user_setting) { Index: apps/gui/viewport.h =================================================================== --- apps/gui/viewport.h (revision 23718) +++ apps/gui/viewport.h (working copy) @@ -31,59 +31,28 @@ /* return the number of text lines in the vp viewport */ int viewport_get_nb_lines(const struct viewport *vp); -void viewport_set_defaults(struct viewport *vp, - const enum screen_type screen); - -/* Used to specify which screens the statusbar (SB) should be displayed on. - * - * The parameter is a bit OR'ed combination of the following (screen is - * SCREEN_MAIN or SCREEN_REMOTE from screen_access.h): - * - * VP_SB_HIDE_ALL means "hide the SB on all screens" - * VP_SB_ONSCREEN(screen) means "display the SB on the given screen - * as specified by the SB setting for that screen" - * VP_SB_IGNORE_SETTING(screen) means "ignore the SB setting for that screen" - * VP_SB_ALLSCREENS means "VP_SB_ONSCREEN for all screens" - * - * In most cases, VP_SB_ALLSCREENS should be used which means display the SB - * as specified by the settings. - * For the WPS (and other possible exceptions) use VP_SB_IGNORE_SETTING() to - * FORCE the statusbar on for the given screen (i.e it will show regardless - * of the setting) - * - * Returns the status before the call. This value can be used to restore the - * SB "displaying rules". - */ - - #define THEME_STATUSBAR (BIT_N(0)) #define THEME_UI_VIEWPORT (BIT_N(1)) #define THEME_BUTTONBAR (BIT_N(2)) #define THEME_LANGUAGE (BIT_N(3)) #define THEME_ALL (~(0u)) -#define VP_SB_HIDE_ALL 0 -#define VP_SB_ONSCREEN(screen) BIT_N(screen) -#define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen) -#define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1)) - #ifndef __PCTOOL__ /* * Initialize the viewportmanager, which in turns initializes the UI vp and * statusbar stuff */ void viewportmanager_init(void); -int viewportmanager_get_statusbar(void); -int viewportmanager_set_statusbar(const int enabled); -/* - * Initializes the given viewport with maximum dimensions minus status- and - * buttonbar - */ -void viewport_set_fullscreen(struct viewport *vp, - const enum screen_type screen); +void viewport_set_defaults(struct viewport *vp, + const enum screen_type screen); +void viewportmanager_theme_enable(enum screen_type screen, bool enable, + struct viewport *viewport); +void viewportmanager_theme_undo(enum screen_type screen, + const struct viewport *viewport); + #ifdef HAVE_LCD_BITMAP /* call this when a theme changed */ @@ -95,8 +64,6 @@ #endif #else /* HAVE_LCD_CHARCELL */ -#define viewport_set_current_vp(a) -#define viewport_get_current_vp() NULL #define viewportmanager_theme_changed(a) #endif Index: apps/menu.c =================================================================== --- apps/menu.c (revision 23718) +++ apps/menu.c (working copy) @@ -343,8 +343,8 @@ const struct menu_item_ex *temp, *menu; int ret = 0, i; bool redraw_lists; - int oldbars = viewportmanager_get_statusbar(); - viewportmanager_set_statusbar(hide_bars ? VP_SB_HIDE_ALL : oldbars); + FOR_NB_SCREENS(i) + viewportmanager_theme_enable(i, !hide_bars, NULL); const struct menu_item_ex *menu_stack[MAX_MENUS]; int menu_stack_selected_item[MAX_MENUS]; @@ -686,7 +686,8 @@ *start_selected = get_menu_selection( gui_synclist_get_sel_pos(&lists), menu); } - viewportmanager_set_statusbar(oldbars); + FOR_NB_SCREENS(i) + viewportmanager_theme_undo(i, NULL); return ret; } Index: apps/menus/eq_menu.c =================================================================== --- apps/menus/eq_menu.c (revision 23718) +++ apps/menus/eq_menu.c (working copy) @@ -391,7 +391,8 @@ enum eq_type current_type; char buf[24]; int i, w, h, height, start_item, nb_eq_sliders[NB_SCREENS]; - int barsenabled = viewportmanager_set_statusbar(VP_SB_HIDE_ALL); + FOR_NB_SCREENS(i) + viewportmanager_theme_enable(i, false, NULL); FOR_NB_SCREENS(i) { @@ -570,12 +571,13 @@ } /* Reset screen settings */ - FOR_NB_SCREENS(i) { + FOR_NB_SCREENS(i) + { screens[i].setfont(FONT_UI); screens[i].clear_display(); screens[i].set_viewport(NULL); + viewportmanager_theme_undo(i, NULL); } - viewportmanager_set_statusbar(barsenabled); return result; } Index: apps/plugin.c =================================================================== --- apps/plugin.c (revision 23718) +++ apps/plugin.c (working copy) @@ -230,7 +230,6 @@ lcd_remote_bitmap, #endif viewport_set_defaults, - viewportmanager_set_statusbar, /* list */ gui_synclist_init, @@ -680,7 +679,7 @@ int plugin_load(const char* plugin, const void* parameter) { - int rc; + int rc, i; int oldbars; struct plugin_header *hdr; #ifdef SIMULATOR @@ -787,7 +786,8 @@ lcd_remote_update(); #endif - oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL); + FOR_NB_SCREENS(i) + viewportmanager_theme_enable(i, false, NULL); cpucache_invalidate(); @@ -834,7 +834,8 @@ #endif #endif - viewportmanager_set_statusbar(oldbars); + FOR_NB_SCREENS(i) + viewportmanager_theme_undo(i, NULL); if (rc != PLUGIN_GOTO_WPS) { Index: apps/plugin.h =================================================================== --- apps/plugin.h (revision 23718) +++ apps/plugin.h (working copy) @@ -335,7 +335,6 @@ int height); #endif void (*viewport_set_defaults)(struct viewport *vp, enum screen_type screen); - int (*viewportmanager_set_statusbar)(int enable_status); /* list */ void (*gui_synclist_init)(struct gui_synclist * lists, list_get_name callback_get_item_name, void * data, Index: apps/debug_menu.c =================================================================== --- apps/debug_menu.c (revision 23718) +++ apps/debug_menu.c (working copy) @@ -2652,13 +2652,16 @@ }; static int menu_action_callback(int btn, struct gui_synclist *lists) { + int i; if (btn == ACTION_STD_OK) { - int oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL); + FOR_NB_SCREENS(i) + viewportmanager_theme_enable(i, false, NULL); menuitems[gui_synclist_get_sel_pos(lists)].function(); btn = ACTION_REDRAW; send_event(GUI_EVENT_REFRESH, NULL); - viewportmanager_set_statusbar(oldbars); + FOR_NB_SCREENS(i) + viewportmanager_theme_undo(i, NULL); } return btn; }