summaryrefslogtreecommitdiff
path: root/apps/gui/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/list.c')
-rw-r--r--apps/gui/list.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 9b139dd47c..284b83012a 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -38,6 +38,7 @@
38#include "misc.h" 38#include "misc.h"
39#include "talk.h" 39#include "talk.h"
40#include "viewport.h" 40#include "viewport.h"
41#include "appevents.h"
41 42
42#ifdef HAVE_LCD_CHARCELLS 43#ifdef HAVE_LCD_CHARCELLS
43#define SCROLL_LIMIT 1 44#define SCROLL_LIMIT 1
@@ -61,21 +62,41 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list,
61void list_draw(struct screen *display, struct gui_synclist *list); 62void list_draw(struct screen *display, struct gui_synclist *list);
62 63
63#ifdef HAVE_LCD_BITMAP 64#ifdef HAVE_LCD_BITMAP
65static int list_need_reinit = false;
66static struct viewport parent[NB_SCREENS];
67
68static void list_force_reinit(void *param)
69{
70 (void)param;
71 list_need_reinit = true;
72}
73
74void list_init(void)
75{
76 add_event(GUI_EVENT_THEME_CHANGED, false, list_force_reinit);
77}
78
64static void list_init_viewports(struct gui_synclist *list) 79static void list_init_viewports(struct gui_synclist *list)
65{ 80{
66 struct viewport* vp; 81 int i, parent_used;
67 int i; 82
68 bool parent_used = (*list->parent != NULL); 83 if (!list)
84 return;
85
86 parent_used = (*list->parent != &parent[SCREEN_MAIN]);
87
69 if (!parent_used) 88 if (!parent_used)
70 { 89 {
71 vp = viewport_get_current_vp();
72 FOR_NB_SCREENS(i) 90 FOR_NB_SCREENS(i)
73 list->parent[i] = &vp[i]; 91 {
74 } 92 list->parent[i] = &parent[i];
93 viewport_set_defaults(&parent[i], i);
75#ifdef HAVE_BUTTONBAR 94#ifdef HAVE_BUTTONBAR
76 if (list && !parent_used && global_settings.buttonbar) 95 if (screens[i].has_buttonbar && !viewport_ui_vp_get_state(i))
77 list->parent[0]->height -= BUTTONBAR_HEIGHT; 96 list->parent[i]->height -= BUTTONBAR_HEIGHT;
78#endif 97#endif
98 }
99 }
79} 100}
80#else 101#else
81#define list_init_viewports(a) 102#define list_init_viewports(a)
@@ -135,12 +156,7 @@ void gui_synclist_init(struct gui_synclist * gui_list,
135 if (list_parent) 156 if (list_parent)
136 gui_list->parent[i] = &list_parent[i]; 157 gui_list->parent[i] = &list_parent[i];
137 else 158 else
138 gui_list->parent[i] = 159 gui_list->parent[i] = &parent[i];
139#ifdef HAVE_LCD_BITMAP
140 NULL;
141#else
142 &parent[i];
143#endif
144 } 160 }
145 list_init_viewports(gui_list); 161 list_init_viewports(gui_list);
146 gui_list->limit_scroll = false; 162 gui_list->limit_scroll = false;
@@ -209,26 +225,13 @@ int gui_list_get_item_offset(struct gui_synclist * gui_list,
209void gui_synclist_draw(struct gui_synclist *gui_list) 225void gui_synclist_draw(struct gui_synclist *gui_list)
210{ 226{
211 int i; 227 int i;
212 static struct gui_synclist *last_list = NULL; 228#ifdef HAVE_LCD_BITMAP
213 static int last_count = -1; 229 if (list_need_reinit)
214#ifdef HAVE_BUTTONBAR
215 static bool last_buttonbar = false;
216#endif
217 if (
218#ifdef HAVE_BUTTONBAR
219 last_buttonbar != screens[SCREEN_MAIN].has_buttonbar ||
220#endif
221 last_list != gui_list ||
222 gui_list->nb_items != last_count)
223 { 230 {
224 list_init_viewports(gui_list); 231 list_init_viewports(gui_list);
225 gui_synclist_select_item(gui_list, gui_list->selected_item); 232 gui_synclist_select_item(gui_list, gui_list->selected_item);
226 } 233 }
227#ifdef HAVE_BUTTONBAR
228 last_buttonbar = screens[SCREEN_MAIN].has_buttonbar;
229#endif 234#endif
230 last_count = gui_list->nb_items;
231 last_list = gui_list;
232 FOR_NB_SCREENS(i) 235 FOR_NB_SCREENS(i)
233 { 236 {
234 list_draw(&screens[i], gui_list); 237 list_draw(&screens[i], gui_list);