summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/list.c61
-rw-r--r--apps/gui/list.h1
-rw-r--r--apps/gui/viewport.c13
-rw-r--r--apps/gui/viewport.h5
4 files changed, 51 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);
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 8a36acb005..ed61889083 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -132,6 +132,7 @@ struct gui_synclist
132 132
133 133
134#ifdef HAVE_LCD_BITMAP 134#ifdef HAVE_LCD_BITMAP
135extern void list_init(void);
135/* parse global setting to static int */ 136/* parse global setting to static int */
136extern void gui_list_screen_scroll_step(int ofs); 137extern void gui_list_screen_scroll_step(int ofs);
137 138
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index 63f0b8fc20..281c04b2c5 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -208,6 +208,13 @@ static void statusbar_toggled(void* param)
208void viewportmanager_theme_changed(int which) 208void viewportmanager_theme_changed(int which)
209{ 209{
210 int i; 210 int i;
211#ifdef HAVE_BUTTONBAR
212 if (which & THEME_BUTTONBAR)
213 { /* don't handle further, the custom ui viewport ignores the buttonbar,
214 * as does viewport_set_defaults(), since only lists use it*/
215 screens[SCREEN_MAIN].has_buttonbar = global_settings.buttonbar;
216 }
217#endif
211 if (which & THEME_UI_VIEWPORT) 218 if (which & THEME_UI_VIEWPORT)
212 { 219 {
213 int retval = viewport_init_ui_vp(); 220 int retval = viewport_init_ui_vp();
@@ -245,6 +252,7 @@ void viewportmanager_theme_changed(int which)
245 viewport_set_fullscreen(&custom_vp[i], i); 252 viewport_set_fullscreen(&custom_vp[i], i);
246 } 253 }
247 } 254 }
255 send_event(GUI_EVENT_THEME_CHANGED, NULL);
248} 256}
249 257
250static void viewportmanager_ui_vp_changed(void *param) 258static void viewportmanager_ui_vp_changed(void *param)
@@ -279,6 +287,11 @@ struct viewport* viewport_get_current_vp(void)
279 return ui_vp_info.vp; 287 return ui_vp_info.vp;
280} 288}
281 289
290bool viewport_ui_vp_get_state(enum screen_type screen)
291{
292 return ui_vp_info.active[screen];
293}
294
282#ifdef HAVE_LCD_COLOR 295#ifdef HAVE_LCD_COLOR
283#define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc") 296#define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc")
284#else 297#else
diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h
index 93b5c70fc3..d431766ab5 100644
--- a/apps/gui/viewport.h
+++ b/apps/gui/viewport.h
@@ -58,6 +58,7 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen);
58 58
59#define THEME_STATUSBAR (BIT_N(0)) 59#define THEME_STATUSBAR (BIT_N(0))
60#define THEME_UI_VIEWPORT (BIT_N(1)) 60#define THEME_UI_VIEWPORT (BIT_N(1))
61#define THEME_BUTTONBAR (BIT_N(2))
61#define THEME_ALL (~(0u)) 62#define THEME_ALL (~(0u))
62 63
63#define VP_SB_HIDE_ALL 0 64#define VP_SB_HIDE_ALL 0
@@ -116,6 +117,10 @@ struct viewport* viewport_get_current_vp(void);
116 */ 117 */
117void viewport_set_current_vp(struct viewport* vp); 118void viewport_set_current_vp(struct viewport* vp);
118 119
120/*
121 * returns true if the ui viewport is active on the screen
122 */
123bool viewport_ui_vp_get_state(enum screen_type screen);
119#ifdef HAVE_TOUCHSCREEN 124#ifdef HAVE_TOUCHSCREEN
120bool viewport_point_within_vp(const struct viewport *vp, int x, int y); 125bool viewport_point_within_vp(const struct viewport *vp, int x, int y);
121#endif 126#endif