From 4c48b59be8ba41b80350d5329d0f13240229da0a Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 16 Aug 2009 22:20:11 +0000 Subject: User definable UI viewport, to be able to restrict the UI into a viewport for all bitmap displays. Flyspray: FS#8799 This will allow for pretty themes, for example those with nice glass effects on their backdrops (some might argue they're wasting screen space but it's upto them), as well as allowing for future background WPS updates in the main UI. Plugins are not converted yet, they simply use the full screen. Ideally, any plugin that does *not* want the UI viewport, should take care of that itself (i.e. plugins should normally use the UI viewport). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22365 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/list.c | 55 +++++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'apps/gui/list.c') diff --git a/apps/gui/list.c b/apps/gui/list.c index 8a65d3f298..3627f12221 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -55,29 +55,37 @@ static int offset_step = 16; /* pixels per screen scroll step */ /* should lines scroll out of the screen */ static bool offset_out_of_view = false; #endif -static int force_list_reinit = false; static void gui_list_select_at_offset(struct gui_synclist * gui_list, int offset); void list_draw(struct screen *display, struct gui_synclist *list); #ifdef HAVE_LCD_BITMAP -static struct viewport parent[NB_SCREENS]; -void list_init_viewports(struct gui_synclist *list) +static void list_init_viewports(struct gui_synclist *list) { + struct viewport* vp; int i; - struct viewport *vp; - FOR_NB_SCREENS(i) + bool parent_used = (*list->parent != NULL); + if (!parent_used) { - vp = &parent[i]; - if (!list || list->parent[i] == vp) - viewport_set_defaults(vp, i); + vp = viewport_get_current_vp(); + FOR_NB_SCREENS(i) + list->parent[i] = &vp[i]; } #ifdef HAVE_BUTTONBAR - if (list && (list->parent[0] == &parent[0]) && global_settings.buttonbar) + if (list && !parent_used[SCREEN_MAIN] && global_settings.buttonbar) list->parent[0]->height -= BUTTONBAR_HEIGHT; #endif - force_list_reinit = false; +} +#else +#define list_init_viewports(a) +#endif + +#ifdef HAVE_LCD_BITMAP +bool list_display_title(struct gui_synclist *list, enum screen_type screen) +{ + return list->title != NULL && + viewport_get_nb_lines(list->parent[screen])>2; } #else static struct viewport parent[NB_SCREENS] = @@ -90,20 +98,6 @@ static struct viewport parent[NB_SCREENS] = .height = LCD_HEIGHT }, }; -void list_init_viewports(struct gui_synclist *list) -{ - (void)list; - force_list_reinit = false; -} -#endif - -#ifdef HAVE_LCD_BITMAP -bool list_display_title(struct gui_synclist *list, enum screen_type screen) -{ - return list->title != NULL && - viewport_get_nb_lines(list->parent[screen])>2; -} -#else #define list_display_title(l, i) false #endif @@ -141,9 +135,12 @@ void gui_synclist_init(struct gui_synclist * gui_list, if (list_parent) gui_list->parent[i] = &list_parent[i]; else - { - gui_list->parent[i] = &parent[i]; - } + gui_list->parent[i] = +#ifdef HAVE_LCD_BITMAP + NULL; +#else + &parent[i]; +#endif } list_init_viewports(gui_list); gui_list->limit_scroll = false; @@ -162,7 +159,6 @@ void gui_synclist_init(struct gui_synclist * gui_list, gui_list->title_color = -1; gui_list->callback_get_item_color = NULL; #endif - force_list_reinit = true; } /* this toggles the selection bar or cursor */ @@ -218,7 +214,7 @@ void gui_synclist_draw(struct gui_synclist *gui_list) #ifdef HAVE_BUTTONBAR static bool last_buttonbar = false; #endif - if (force_list_reinit || + if ( #ifdef HAVE_BUTTONBAR last_buttonbar != screens[SCREEN_MAIN].has_buttonbar || #endif @@ -436,7 +432,6 @@ void gui_synclist_set_title(struct gui_synclist * gui_list, } else { gui_list->title_width = 0; } - force_list_reinit = true; } -- cgit v1.2.3