summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/appevents.h4
-rw-r--r--apps/debug_menu.c2
-rw-r--r--apps/filetree.c15
-rw-r--r--apps/gui/list.c55
-rw-r--r--apps/gui/list.h2
-rw-r--r--apps/gui/statusbar.c2
-rw-r--r--apps/gui/viewport.c169
-rw-r--r--apps/gui/viewport.h82
-rw-r--r--apps/gui/wps.c1
-rw-r--r--apps/main.c11
-rw-r--r--apps/menu.c4
-rw-r--r--apps/menus/display_menu.c4
-rw-r--r--apps/menus/theme_menu.c2
-rw-r--r--apps/plugin.c19
-rw-r--r--apps/recorder/keyboard.c7
-rw-r--r--apps/recorder/recording.c5
-rw-r--r--apps/root_menu.c1
-rw-r--r--apps/settings.c12
-rw-r--r--apps/settings.h7
-rw-r--r--apps/settings_list.c11
20 files changed, 313 insertions, 102 deletions
diff --git a/apps/appevents.h b/apps/appevents.h
index e3c4a92ff8..f7e695d4a9 100644
--- a/apps/appevents.h
+++ b/apps/appevents.h
@@ -48,9 +48,9 @@ enum {
48 48
49/** Generic GUI class events **/ 49/** Generic GUI class events **/
50enum { 50enum {
51 GUI_EVENT_THEME_CHANGED = (EVENT_CLASS_GUI|1), 51 GUI_EVENT_STATUSBAR_TOGGLE = (EVENT_CLASS_GUI|1),
52 GUI_EVENT_STATUSBAR_TOGGLE,
53 GUI_EVENT_ACTIONUPDATE, 52 GUI_EVENT_ACTIONUPDATE,
53 GUI_EVENT_REFRESH,
54}; 54};
55 55
56#endif 56#endif
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index a4a399d616..ea53d445fd 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -100,6 +100,7 @@
100#if CONFIG_RTC == RTC_PCF50605 100#if CONFIG_RTC == RTC_PCF50605
101#include "pcf50605.h" 101#include "pcf50605.h"
102#endif 102#endif
103#include "appevents.h"
103 104
104#if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \ 105#if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \
105 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 || CONFIG_CPU == JZ4732 106 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 || CONFIG_CPU == JZ4732
@@ -2790,6 +2791,7 @@ static int menu_action_callback(int btn, struct gui_synclist *lists)
2790 int oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL); 2791 int oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL);
2791 menuitems[gui_synclist_get_sel_pos(lists)].function(); 2792 menuitems[gui_synclist_get_sel_pos(lists)].function();
2792 btn = ACTION_REDRAW; 2793 btn = ACTION_REDRAW;
2794 send_event(GUI_EVENT_REFRESH, NULL);
2793 viewportmanager_set_statusbar(oldbars); 2795 viewportmanager_set_statusbar(oldbars);
2794 } 2796 }
2795 return btn; 2797 return btn;
diff --git a/apps/filetree.c b/apps/filetree.c
index 2d05bd54cf..ec7932435d 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -181,6 +181,11 @@ static void check_file_thumbnails(struct tree_context* c)
181 closedir(dir); 181 closedir(dir);
182} 182}
183 183
184static void filetree_drawlists(void)
185{
186 gui_synclist_draw(&tree_lists);
187}
188
184/* support function for qsort() */ 189/* support function for qsort() */
185static int compare(const void* p1, const void* p2) 190static int compare(const void* p1, const void* p2)
186{ 191{
@@ -508,7 +513,13 @@ int ft_enter(struct tree_context* c)
508 splash(0, ID2P(LANG_WAIT)); 513 splash(0, ID2P(LANG_WAIT));
509 if (!settings_load_config(buf,true)) 514 if (!settings_load_config(buf,true))
510 break; 515 break;
511 gui_synclist_draw(&tree_lists); 516 /* do both steps seperately so that the redrawing after theme
517 * changing is independant of whether the theme has a custom ui
518 * vp or not */
519 send_event(GUI_EVENT_REFRESH, NULL);
520 /* for the statusbar */
521 send_event(GUI_EVENT_ACTIONUPDATE, (void*)true);
522 filetree_drawlists();
512 splash(HZ, ID2P(LANG_SETTINGS_LOADED)); 523 splash(HZ, ID2P(LANG_SETTINGS_LOADED));
513 break; 524 break;
514 525
@@ -618,6 +629,8 @@ int ft_enter(struct tree_context* c)
618 } 629 }
619 } 630 }
620 631
632 send_event(GUI_EVENT_REFRESH, filetree_drawlists);
633
621 if ( play ) { 634 if ( play ) {
622 /* the resume_index must always be the index in the 635 /* the resume_index must always be the index in the
623 shuffled list in case shuffle is enabled */ 636 shuffled list in case shuffle is enabled */
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 */
55/* should lines scroll out of the screen */ 55/* should lines scroll out of the screen */
56static bool offset_out_of_view = false; 56static bool offset_out_of_view = false;
57#endif 57#endif
58static int force_list_reinit = false;
59 58
60static void gui_list_select_at_offset(struct gui_synclist * gui_list, 59static void gui_list_select_at_offset(struct gui_synclist * gui_list,
61 int offset); 60 int offset);
62void list_draw(struct screen *display, struct gui_synclist *list); 61void list_draw(struct screen *display, struct gui_synclist *list);
63 62
64#ifdef HAVE_LCD_BITMAP 63#ifdef HAVE_LCD_BITMAP
65static struct viewport parent[NB_SCREENS]; 64static void list_init_viewports(struct gui_synclist *list)
66void list_init_viewports(struct gui_synclist *list)
67{ 65{
66 struct viewport* vp;
68 int i; 67 int i;
69 struct viewport *vp; 68 bool parent_used = (*list->parent != NULL);
70 FOR_NB_SCREENS(i) 69 if (!parent_used)
71 { 70 {
72 vp = &parent[i]; 71 vp = viewport_get_current_vp();
73 if (!list || list->parent[i] == vp) 72 FOR_NB_SCREENS(i)
74 viewport_set_defaults(vp, i); 73 list->parent[i] = &vp[i];
75 } 74 }
76#ifdef HAVE_BUTTONBAR 75#ifdef HAVE_BUTTONBAR
77 if (list && (list->parent[0] == &parent[0]) && global_settings.buttonbar) 76 if (list && !parent_used[SCREEN_MAIN] && global_settings.buttonbar)
78 list->parent[0]->height -= BUTTONBAR_HEIGHT; 77 list->parent[0]->height -= BUTTONBAR_HEIGHT;
79#endif 78#endif
80 force_list_reinit = false; 79}
80#else
81#define list_init_viewports(a)
82#endif
83
84#ifdef HAVE_LCD_BITMAP
85bool list_display_title(struct gui_synclist *list, enum screen_type screen)
86{
87 return list->title != NULL &&
88 viewport_get_nb_lines(list->parent[screen])>2;
81} 89}
82#else 90#else
83static struct viewport parent[NB_SCREENS] = 91static struct viewport parent[NB_SCREENS] =
@@ -90,20 +98,6 @@ static struct viewport parent[NB_SCREENS] =
90 .height = LCD_HEIGHT 98 .height = LCD_HEIGHT
91 }, 99 },
92}; 100};
93void list_init_viewports(struct gui_synclist *list)
94{
95 (void)list;
96 force_list_reinit = false;
97}
98#endif
99
100#ifdef HAVE_LCD_BITMAP
101bool list_display_title(struct gui_synclist *list, enum screen_type screen)
102{
103 return list->title != NULL &&
104 viewport_get_nb_lines(list->parent[screen])>2;
105}
106#else
107#define list_display_title(l, i) false 101#define list_display_title(l, i) false
108#endif 102#endif
109 103
@@ -141,9 +135,12 @@ void gui_synclist_init(struct gui_synclist * gui_list,
141 if (list_parent) 135 if (list_parent)
142 gui_list->parent[i] = &list_parent[i]; 136 gui_list->parent[i] = &list_parent[i];
143 else 137 else
144 { 138 gui_list->parent[i] =
145 gui_list->parent[i] = &parent[i]; 139#ifdef HAVE_LCD_BITMAP
146 } 140 NULL;
141#else
142 &parent[i];
143#endif
147 } 144 }
148 list_init_viewports(gui_list); 145 list_init_viewports(gui_list);
149 gui_list->limit_scroll = false; 146 gui_list->limit_scroll = false;
@@ -162,7 +159,6 @@ void gui_synclist_init(struct gui_synclist * gui_list,
162 gui_list->title_color = -1; 159 gui_list->title_color = -1;
163 gui_list->callback_get_item_color = NULL; 160 gui_list->callback_get_item_color = NULL;
164#endif 161#endif
165 force_list_reinit = true;
166} 162}
167 163
168/* this toggles the selection bar or cursor */ 164/* this toggles the selection bar or cursor */
@@ -218,7 +214,7 @@ void gui_synclist_draw(struct gui_synclist *gui_list)
218#ifdef HAVE_BUTTONBAR 214#ifdef HAVE_BUTTONBAR
219 static bool last_buttonbar = false; 215 static bool last_buttonbar = false;
220#endif 216#endif
221 if (force_list_reinit || 217 if (
222#ifdef HAVE_BUTTONBAR 218#ifdef HAVE_BUTTONBAR
223 last_buttonbar != screens[SCREEN_MAIN].has_buttonbar || 219 last_buttonbar != screens[SCREEN_MAIN].has_buttonbar ||
224#endif 220#endif
@@ -436,7 +432,6 @@ void gui_synclist_set_title(struct gui_synclist * gui_list,
436 } else { 432 } else {
437 gui_list->title_width = 0; 433 gui_list->title_width = 0;
438 } 434 }
439 force_list_reinit = true;
440} 435}
441 436
442 437
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 50aaebe93a..23997e8a65 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -139,8 +139,6 @@ extern void gui_list_screen_scroll_step(int ofs);
139extern void gui_list_screen_scroll_out_of_view(bool enable); 139extern void gui_list_screen_scroll_out_of_view(bool enable);
140#endif /* HAVE_LCD_BITMAP */ 140#endif /* HAVE_LCD_BITMAP */
141 141
142void list_init_viewports(struct gui_synclist * lists);
143
144extern void gui_synclist_init( 142extern void gui_synclist_init(
145 struct gui_synclist * lists, 143 struct gui_synclist * lists,
146 list_get_name callback_get_item_name, 144 list_get_name callback_get_item_name,
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index 5e215090f5..024ade330f 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -263,7 +263,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
263 memcmp(&(bar->info), &(bar->lastinfo), sizeof(struct status_info))) 263 memcmp(&(bar->info), &(bar->lastinfo), sizeof(struct status_info)))
264 { 264 {
265 struct viewport vp; 265 struct viewport vp;
266 viewport_set_defaults(&vp, display->screen_type); 266 viewport_set_fullscreen(&vp, display->screen_type);
267 vp.height = STATUSBAR_HEIGHT; 267 vp.height = STATUSBAR_HEIGHT;
268 vp.x = STATUSBAR_X_POS; 268 vp.x = STATUSBAR_X_POS;
269 if (statusbar_position(display->screen_type) != STATUSBAR_BOTTOM) 269 if (statusbar_position(display->screen_type) != STATUSBAR_BOTTOM)
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index ef527d90cc..bb4c291cc0 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -56,6 +56,22 @@
56 56
57static int statusbar_enabled = 0; 57static int statusbar_enabled = 0;
58 58
59#ifdef HAVE_LCD_BITMAP
60
61static struct {
62 struct viewport* vp;
63 int active;
64} ui_vp_info;
65
66static struct viewport custom_vp[NB_SCREENS];
67
68/* callbacks for GUI_EVENT_* events */
69static void viewportmanager_ui_vp_changed(void *param);
70static void statusbar_toggled(void* param);
71static int viewport_init_ui_vp(void);
72#endif
73static void viewportmanager_redraw(void* data);
74
59int viewport_get_nb_lines(struct viewport *vp) 75int viewport_get_nb_lines(struct viewport *vp)
60{ 76{
61#ifdef HAVE_LCD_BITMAP 77#ifdef HAVE_LCD_BITMAP
@@ -78,9 +94,9 @@ static bool showing_bars(enum screen_type screen)
78#endif 94#endif
79 } 95 }
80 return false; 96 return false;
81} 97}
82 98
83void viewport_set_defaults(struct viewport *vp, enum screen_type screen) 99void viewport_set_fullscreen(struct viewport *vp, enum screen_type screen)
84{ 100{
85 vp->x = 0; 101 vp->x = 0;
86 vp->width = screens[screen].lcdwidth; 102 vp->width = screens[screen].lcdwidth;
@@ -120,6 +136,30 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen)
120#endif 136#endif
121} 137}
122 138
139void viewport_set_defaults(struct viewport *vp, enum screen_type screen)
140{
141#ifdef HAVE_LCD_BITMAP
142 if (ui_vp_info.active)
143 *vp = custom_vp[screen];
144 else
145#endif
146 viewport_set_fullscreen(vp, screen);
147}
148
149void viewportmanager_init(void)
150{
151 viewportmanager_set_statusbar(VP_SB_ALLSCREENS);
152#ifdef HAVE_LCD_BITMAP
153 add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggled);
154 ui_vp_info.active = viewport_init_ui_vp();
155 ui_vp_info.vp = custom_vp;
156#endif
157}
158
159int viewportmanager_get_statusbar(void)
160{
161 return statusbar_enabled;
162}
123 163
124int viewportmanager_set_statusbar(int enabled) 164int viewportmanager_set_statusbar(int enabled)
125{ 165{
@@ -133,37 +173,101 @@ int viewportmanager_set_statusbar(int enabled)
133 if (showing_bars(i)) 173 if (showing_bars(i))
134 gui_statusbar_draw(&statusbars.statusbars[i], true); 174 gui_statusbar_draw(&statusbars.statusbars[i], true);
135 } 175 }
136 add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_draw_statusbars); 176 add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw);
137 } 177 }
138 else 178 else
139 { 179 {
140 remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_draw_statusbars); 180 remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw);
141 } 181 }
142 return old; 182 return old;
143} 183}
144 184
145void viewportmanager_draw_statusbars(void* data) 185static void viewportmanager_redraw(void* data)
146{ 186{
147 int i; 187 int i;
148 188
149 FOR_NB_SCREENS(i) 189 FOR_NB_SCREENS(i)
150 { 190 {
151 if (showing_bars(i)) 191 if (showing_bars(i))
152 gui_statusbar_draw(&statusbars.statusbars[i], (bool)data); 192 gui_statusbar_draw(&statusbars.statusbars[i], NULL != data);
153 } 193 }
154} 194}
195#ifdef HAVE_LCD_BITMAP
155 196
156void viewportmanager_statusbar_changed(void* data) 197static void statusbar_toggled(void* param)
157{ 198{
158 (void)data; 199 (void)param;
159 statusbar_enabled = 0; 200 /* update vp manager for the new setting and reposition vps
160 if (global_settings.statusbar != STATUSBAR_OFF) 201 * if necessary */
161 statusbar_enabled = VP_SB_ONSCREEN(SCREEN_MAIN); 202 viewportmanager_theme_changed(THEME_STATUSBAR);
203}
204
205void viewportmanager_theme_changed(int which)
206{
207 if (which & THEME_UI_VIEWPORT)
208 {
209 /* reset the ui viewport */
210 if ((ui_vp_info.active = viewport_init_ui_vp()))
211 add_event(GUI_EVENT_REFRESH, false, viewportmanager_ui_vp_changed);
212 else
213 remove_event(GUI_EVENT_REFRESH, viewportmanager_ui_vp_changed);
214 /* and point to it */
215 ui_vp_info.vp = custom_vp;
216 }
217 if (which & THEME_STATUSBAR)
218 {
219 statusbar_enabled = 0;
220 if (global_settings.statusbar != STATUSBAR_OFF)
221 statusbar_enabled = VP_SB_ONSCREEN(SCREEN_MAIN);
162#ifdef HAVE_REMOTE_LCD 222#ifdef HAVE_REMOTE_LCD
163 if (global_settings.remote_statusbar != STATUSBAR_OFF) 223 if (global_settings.remote_statusbar != STATUSBAR_OFF)
164 statusbar_enabled |= VP_SB_ONSCREEN(SCREEN_REMOTE); 224 statusbar_enabled |= VP_SB_ONSCREEN(SCREEN_REMOTE);
165#endif 225#endif
226 if (statusbar_enabled)
227 add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw);
228 else
229 remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw);
230
231 /* reposition viewport to fit statusbar, only if not using the ui vp */
232 if (!ui_vp_info.active)
233 {
234 int i;
235 FOR_NB_SCREENS(i)
236 viewport_set_fullscreen(&custom_vp[i], i);
237 }
238 }
239}
240
241static void viewportmanager_ui_vp_changed(void *param)
242{
243 /* if the user changed the theme, we need to initiate a full redraw */
244 int i;
245 /* cast param to a function */
246 void (*draw_func)(void) = ((void(*)(void))param);
247 /* start with clearing the screen */
248 FOR_NB_SCREENS(i)
249 screens[i].clear_display();
250 /* redraw the statusbar if it was enabled */
166 viewportmanager_set_statusbar(statusbar_enabled); 251 viewportmanager_set_statusbar(statusbar_enabled);
252 /* call the passed function which will redraw the content of
253 * the current screen */
254 if (param != NULL)
255 draw_func();
256 FOR_NB_SCREENS(i)
257 screens[i].update();
258}
259
260void viewport_set_current_vp(struct viewport* vp)
261{
262 if (vp != NULL)
263 ui_vp_info.vp = vp;
264 else
265 ui_vp_info.vp = custom_vp;
266}
267
268struct viewport* viewport_get_current_vp(void)
269{
270 return ui_vp_info.vp;
167} 271}
168 272
169#ifdef HAVE_LCD_COLOR 273#ifdef HAVE_LCD_COLOR
@@ -172,7 +276,6 @@ void viewportmanager_statusbar_changed(void* data)
172#define ARG_STRING(_depth) "dddddgg" 276#define ARG_STRING(_depth) "dddddgg"
173#endif 277#endif
174 278
175#ifdef HAVE_LCD_BITMAP
176const char* viewport_parse_viewport(struct viewport *vp, 279const char* viewport_parse_viewport(struct viewport *vp,
177 enum screen_type screen, 280 enum screen_type screen,
178 const char *bufptr, 281 const char *bufptr,
@@ -213,9 +316,9 @@ const char* viewport_parse_viewport(struct viewport *vp,
213 return NULL; 316 return NULL;
214 } 317 }
215 else 318 else
216#undef ARG_STRING
217#endif 319#endif
218 {} 320 {}
321#undef ARG_STRING
219 322
220 /* X and Y *must* be set */ 323 /* X and Y *must* be set */
221 if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y)) 324 if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y))
@@ -259,4 +362,40 @@ const char* viewport_parse_viewport(struct viewport *vp,
259 return ptr; 362 return ptr;
260} 363}
261 364
365/*
366 * (re)parse the UI vp from the settings
367 * - Returns
368 * 0 if no UI vp is used
369 * >0 if it's used at least partly (on multiscreen targets)
370 * NB_SCREENS if all screens have a UI vp
371 */
372static int viewport_init_ui_vp(void)
373{
374 int screen, ret = NB_SCREENS;
375 FOR_NB_SCREENS(screen)
376 {
377#ifdef HAVE_REMOTE_LCD
378 if ((screen == SCREEN_REMOTE))
379 {
380 if(!(viewport_parse_viewport(&custom_vp[screen], screen,
381 global_settings.remote_ui_vp_config, ',')))
382 {
383 viewport_set_fullscreen(&custom_vp[screen], screen);
384 ret--;
385 }
386 }
387 else
388#endif
389 {
390 if (!(viewport_parse_viewport(&custom_vp[screen], screen,
391 global_settings.ui_vp_config, ',')))
392 {
393 viewport_set_fullscreen(&custom_vp[screen], screen);
394 ret--;
395 }
396 }
397 }
398 return ret;
399}
400
262#endif /* HAVE_LCD_BITMAP */ 401#endif /* HAVE_LCD_BITMAP */
diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h
index 6c3fb92998..2ed138b365 100644
--- a/apps/gui/viewport.h
+++ b/apps/gui/viewport.h
@@ -34,26 +34,6 @@ int viewport_get_nb_lines(struct viewport *vp);
34 34
35void viewport_set_defaults(struct viewport *vp, enum screen_type screen); 35void viewport_set_defaults(struct viewport *vp, enum screen_type screen);
36 36
37/* Parse a viewport definition (vp_def), which looks like:
38 *
39 * Screens with depth > 1:
40 * X|Y|width|height|font|foregorund color|background color
41 * Screens with depth = 1:
42 * X|Y|width|height|font
43 *
44 * | is a separator and can be specified via the parameter
45 *
46 * Returns the pointer to the char after the last character parsed
47 * if everything went OK or NULL if an error happened (some values
48 * not specified in the definition)
49 */
50#ifdef HAVE_LCD_BITMAP
51const char* viewport_parse_viewport(struct viewport *vp,
52 enum screen_type screen,
53 const char *vp_def,
54 const char separator);
55#endif
56
57/* Used to specify which screens the statusbar (SB) should be displayed on. 37/* Used to specify which screens the statusbar (SB) should be displayed on.
58 * 38 *
59 * The parameter is a bit OR'ed combination of the following (screen is 39 * The parameter is a bit OR'ed combination of the following (screen is
@@ -74,14 +54,70 @@ const char* viewport_parse_viewport(struct viewport *vp,
74 * Returns the status before the call. This value can be used to restore the 54 * Returns the status before the call. This value can be used to restore the
75 * SB "displaying rules". 55 * SB "displaying rules".
76 */ 56 */
57
58
59#define THEME_STATUSBAR (BIT_N(0))
60#define THEME_UI_VIEWPORT (BIT_N(1))
61#define THEME_ALL (~(0u))
62
77#define VP_SB_HIDE_ALL 0 63#define VP_SB_HIDE_ALL 0
78#define VP_SB_ONSCREEN(screen) BIT_N(screen) 64#define VP_SB_ONSCREEN(screen) BIT_N(screen)
79#define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen) 65#define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen)
80#define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1)) 66#define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1))
67
68/*
69 * Initialize the viewportmanager, which in turns initializes the UI vp and
70 * statusbar stuff
71 */
72void viewportmanager_init(void);
73int viewportmanager_get_statusbar(void);
81int viewportmanager_set_statusbar(int enabled); 74int viewportmanager_set_statusbar(int enabled);
82 75
83/* callbacks for GUI_EVENT_* events */ 76/* call this when a theme changed */
84void viewportmanager_draw_statusbars(void*data); 77void viewportmanager_theme_changed(int);
85void viewportmanager_statusbar_changed(void* data); 78
79/*
80 * Initializes the given viewport with maximum dimensions minus status- and
81 * buttonbar
82 */
83void viewport_set_fullscreen(struct viewport *vp, enum screen_type screen);
86 84
85#ifdef HAVE_LCD_BITMAP
86
87/*
88 * Parse a viewport definition (vp_def), which looks like:
89 *
90 * Screens with depth > 1:
91 * X|Y|width|height|font|foregorund color|background color
92 * Screens with depth = 1:
93 * X|Y|width|height|font
94 *
95 * | is a separator and can be specified via the parameter
96 *
97 * Returns the pointer to the char after the last character parsed
98 * if everything went OK or NULL if an error happened (some values
99 * not specified in the definition)
100 */
101const char* viewport_parse_viewport(struct viewport *vp,
102 enum screen_type screen,
103 const char *vp_def,
104 const char separator);
105
106/*
107 * Returns a pointer to the current viewport
108 * - That could be the UI vp, or a viewport passed to do_menu() or the like
109 */
110struct viewport* viewport_get_current_vp(void);
111
112/*
113 * Set the UI vp pointer to a different one - NULL to reset to the UI vp
114 *
115 * This is needed since the UI viewport needs is kept in RAM.
116 */
117void viewport_set_current_vp(struct viewport* vp);
118
119#else /* HAVE_LCD_CHARCELL */
120#define viewport_set_current_vp(a)
121#define viewport_get_current_vp() NULL
122#endif
87#endif /* __VIEWPORT_H__ */ 123#endif /* __VIEWPORT_H__ */
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index b57f06d2b5..055f8d01e6 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -565,6 +565,7 @@ static void gwps_leave_wps(void)
565 /* Play safe and unregister the hook */ 565 /* Play safe and unregister the hook */
566 lcd_activation_set_hook(NULL); 566 lcd_activation_set_hook(NULL);
567#endif 567#endif
568 send_event(GUI_EVENT_REFRESH, NULL);
568} 569}
569 570
570void gwps_draw_statusbars(void) 571void gwps_draw_statusbars(void)
diff --git a/apps/main.c b/apps/main.c
index d0fba3fcce..49542e8b01 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -72,6 +72,7 @@
72#include "eeprom_settings.h" 72#include "eeprom_settings.h"
73#include "scrobbler.h" 73#include "scrobbler.h"
74#include "icon.h" 74#include "icon.h"
75#include "viewport.h"
75 76
76#ifdef IPOD_ACCESSORY_PROTOCOL 77#ifdef IPOD_ACCESSORY_PROTOCOL
77#include "iap.h" 78#include "iap.h"
@@ -135,9 +136,8 @@ static void app_main(void)
135 screens[i].update(); 136 screens[i].update();
136 } 137 }
137 tree_gui_init(); 138 tree_gui_init();
138 viewportmanager_set_statusbar(VP_SB_ALLSCREENS); 139 gui_syncstatusbar_init(&statusbars);
139 add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, 140 viewportmanager_init();
140 viewportmanager_statusbar_changed);
141#ifdef HAVE_USBSTACK 141#ifdef HAVE_USBSTACK
142 /* All threads should be created and public queues registered by now */ 142 /* All threads should be created and public queues registered by now */
143 usb_start_monitoring(); 143 usb_start_monitoring();
@@ -296,8 +296,6 @@ static void init(void)
296#ifdef DEBUG 296#ifdef DEBUG
297 debug_init(); 297 debug_init();
298#endif 298#endif
299 /* Must be done before any code uses the multi-screen APi */
300 gui_syncstatusbar_init(&statusbars);
301 storage_init(); 299 storage_init();
302 settings_reset(); 300 settings_reset();
303 settings_load(SETTINGS_ALL); 301 settings_load(SETTINGS_ALL);
@@ -419,9 +417,6 @@ static void init(void)
419 radio_init(); 417 radio_init();
420#endif 418#endif
421 419
422 /* Must be done before any code uses the multi-screen APi */
423 gui_syncstatusbar_init(&statusbars);
424
425#if CONFIG_CHARGING && (CONFIG_CPU == SH7034) 420#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
426 /* charger_inserted() can't be used here because power_thread() 421 /* charger_inserted() can't be used here because power_thread()
427 hasn't checked power_input_status() yet */ 422 hasn't checked power_input_status() yet */
diff --git a/apps/menu.c b/apps/menu.c
index 96140cf4f8..539dc900a5 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -342,8 +342,8 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
342 const struct menu_item_ex *temp, *menu; 342 const struct menu_item_ex *temp, *menu;
343 int ret = 0, i; 343 int ret = 0, i;
344 bool redraw_lists; 344 bool redraw_lists;
345 int oldbars = viewportmanager_set_statusbar( 345 int oldbars = viewportmanager_get_statusbar();
346 hide_bars ? VP_SB_HIDE_ALL : VP_SB_ALLSCREENS); 346 viewportmanager_set_statusbar(hide_bars ? VP_SB_HIDE_ALL : oldbars);
347 347
348 const struct menu_item_ex *menu_stack[MAX_MENUS]; 348 const struct menu_item_ex *menu_stack[MAX_MENUS];
349 int menu_stack_selected_item[MAX_MENUS]; 349 int menu_stack_selected_item[MAX_MENUS];
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c
index 05b5bd268d..3989a6381b 100644
--- a/apps/menus/display_menu.c
+++ b/apps/menus/display_menu.c
@@ -39,6 +39,7 @@
39#ifdef HAVE_TOUCHSCREEN 39#ifdef HAVE_TOUCHSCREEN
40#include "screens.h" 40#include "screens.h"
41#endif 41#endif
42#include "viewport.h"
42 43
43#ifdef HAVE_BACKLIGHT 44#ifdef HAVE_BACKLIGHT
44static int filterfirstkeypress_callback(int action,const struct menu_item_ex *this_item) 45static int filterfirstkeypress_callback(int action,const struct menu_item_ex *this_item)
@@ -313,8 +314,7 @@ static int statusbar_callback(int action,const struct menu_item_ex *this_item)
313 { 314 {
314 case ACTION_EXIT_MENUITEM: 315 case ACTION_EXIT_MENUITEM:
315 send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL); 316 send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL);
316 /* this should be changed so only the viewports are reloaded */ 317 send_event(GUI_EVENT_ACTIONUPDATE, (void*)true);
317 settings_apply(false);
318 break; 318 break;
319 } 319 }
320 return action; 320 return action;
diff --git a/apps/menus/theme_menu.c b/apps/menus/theme_menu.c
index d71ca71928..233d673da1 100644
--- a/apps/menus/theme_menu.c
+++ b/apps/menus/theme_menu.c
@@ -37,6 +37,7 @@
37#include "lcd-remote.h" 37#include "lcd-remote.h"
38#include "backdrop.h" 38#include "backdrop.h"
39#include "exported_menus.h" 39#include "exported_menus.h"
40#include "appevents.h"
40 41
41#if LCD_DEPTH > 1 42#if LCD_DEPTH > 1
42/** 43/**
@@ -47,6 +48,7 @@ static int clear_main_backdrop(void)
47 global_settings.backdrop_file[0]=0; 48 global_settings.backdrop_file[0]=0;
48 backdrop_unload(BACKDROP_MAIN); 49 backdrop_unload(BACKDROP_MAIN);
49 backdrop_show(BACKDROP_MAIN); 50 backdrop_show(BACKDROP_MAIN);
51 send_event(GUI_EVENT_REFRESH, NULL);
50 settings_save(); 52 settings_save();
51 return 0; 53 return 0;
52} 54}
diff --git a/apps/plugin.c b/apps/plugin.c
index 238a01c322..e9acc97824 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -673,10 +673,10 @@ static const struct plugin_api rockbox_api = {
673 673
674int plugin_load(const char* plugin, const void* parameter) 674int plugin_load(const char* plugin, const void* parameter)
675{ 675{
676 int rc; 676 int rc, i;
677 int i;
678 int oldbars; 677 int oldbars;
679 struct plugin_header *hdr; 678 struct plugin_header *hdr;
679 struct viewport plugin_vp[NB_SCREENS];
680#ifdef SIMULATOR 680#ifdef SIMULATOR
681 void *pd; 681 void *pd;
682#else /* !SIMULATOR */ 682#else /* !SIMULATOR */
@@ -781,8 +781,14 @@ int plugin_load(const char* plugin, const void* parameter)
781 lcd_remote_update(); 781 lcd_remote_update();
782#endif 782#endif
783 783
784 cpucache_invalidate();
785 oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL); 784 oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL);
785
786 FOR_NB_SCREENS(i)
787 viewport_set_fullscreen(&plugin_vp[i], i);
788
789 viewport_set_current_vp(plugin_vp);
790
791 cpucache_invalidate();
786 792
787#ifdef HAVE_TOUCHSCREEN 793#ifdef HAVE_TOUCHSCREEN
788 touchscreen_set_mode(TOUCHSCREEN_BUTTON); 794 touchscreen_set_mode(TOUCHSCREEN_BUTTON);
@@ -826,14 +832,11 @@ int plugin_load(const char* plugin, const void* parameter)
826 832
827 if (rc != PLUGIN_GOTO_WPS) 833 if (rc != PLUGIN_GOTO_WPS)
828 { 834 {
829 FOR_NB_SCREENS(i) 835 send_event(GUI_EVENT_REFRESH, NULL);
830 {
831 screens[i].clear_display();
832 screens[i].update();
833 }
834 } 836 }
835 837
836 viewportmanager_set_statusbar(oldbars); 838 viewportmanager_set_statusbar(oldbars);
839 viewport_set_current_vp(NULL);
837 if (pfn_tsr_exit == NULL) 840 if (pfn_tsr_exit == NULL)
838 plugin_loaded = false; 841 plugin_loaded = false;
839 842
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index 0fa1d32503..160779f7ae 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -39,6 +39,7 @@
39#include "viewport.h" 39#include "viewport.h"
40#include "file.h" 40#include "file.h"
41#include "splash.h" 41#include "splash.h"
42#include "appevents.h"
42 43
43#ifndef O_BINARY 44#ifndef O_BINARY
44#define O_BINARY 0 45#define O_BINARY 0
@@ -1243,11 +1244,13 @@ int kbd_input(char* text, int buflen)
1243 global_settings.buttonbar = buttonbar_config; 1244 global_settings.buttonbar = buttonbar_config;
1244#endif 1245#endif
1245 1246
1247 if (ret < 0)
1248 splash(HZ/2, ID2P(LANG_CANCEL));
1249
1246 FOR_NB_SCREENS(l) 1250 FOR_NB_SCREENS(l)
1247 screens[l].setfont(FONT_UI); 1251 screens[l].setfont(FONT_UI);
1248 viewportmanager_set_statusbar(oldbars); 1252 viewportmanager_set_statusbar(oldbars);
1253 send_event(GUI_EVENT_REFRESH, NULL);
1249 1254
1250 if (ret < 0)
1251 splash(HZ/2, ID2P(LANG_CANCEL));
1252 return ret; 1255 return ret;
1253} 1256}
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 9bcbf8be68..2716d932b5 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -76,6 +76,7 @@
76#include "viewport.h" 76#include "viewport.h"
77#include "list.h" 77#include "list.h"
78#include "general.h" 78#include "general.h"
79#include "appevents.h"
79 80
80#ifdef HAVE_RECORDING 81#ifdef HAVE_RECORDING
81/* This array holds the record timer interval lengths, in seconds */ 82/* This array holds the record timer interval lengths, in seconds */
@@ -1924,9 +1925,11 @@ rec_abort:
1924 rec_status &= ~RCSTAT_IN_RECSCREEN; 1925 rec_status &= ~RCSTAT_IN_RECSCREEN;
1925 sound_settings_apply(); 1926 sound_settings_apply();
1926 1927
1927 viewportmanager_set_statusbar(oldbars);
1928 FOR_NB_SCREENS(i) 1928 FOR_NB_SCREENS(i)
1929 screens[i].setfont(FONT_UI); 1929 screens[i].setfont(FONT_UI);
1930
1931 viewportmanager_set_statusbar(oldbars);
1932 send_event(GUI_EVENT_REFRESH, NULL);
1930 1933
1931 /* if the directory was created or recording happened, make sure the 1934 /* if the directory was created or recording happened, make sure the
1932 browser is updated */ 1935 browser is updated */
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 848440a40c..a06caba176 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -192,6 +192,7 @@ static int browser(void* param)
192 } 192 }
193 } 193 }
194 } 194 }
195 send_event(GUI_EVENT_REFRESH, NULL);
195 if (!tagcache_is_usable()) 196 if (!tagcache_is_usable())
196 return GO_TO_PREVIOUS; 197 return GO_TO_PREVIOUS;
197 filter = SHOW_ID3DB; 198 filter = SHOW_ID3DB;
diff --git a/apps/settings.c b/apps/settings.c
index 1b0abfbf46..48571db20e 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -65,12 +65,12 @@
65#include "filetypes.h" 65#include "filetypes.h"
66#include "option_select.h" 66#include "option_select.h"
67#include "backdrop.h" 67#include "backdrop.h"
68#include "appevents.h"
69#if CONFIG_TUNER 68#if CONFIG_TUNER
70#include "radio.h" 69#include "radio.h"
71#endif 70#endif
72#include "wps.h" 71#include "wps.h"
73#include "skin_engine/skin_engine.h" 72#include "skin_engine/skin_engine.h"
73#include "viewport.h"
74 74
75#if CONFIG_CODEC == MAS3507D 75#if CONFIG_CODEC == MAS3507D
76void dac_line_in(bool enable); 76void dac_line_in(bool enable);
@@ -761,6 +761,7 @@ void settings_apply_skins(void)
761 761
762void settings_apply(bool read_disk) 762void settings_apply(bool read_disk)
763{ 763{
764
764 char buf[64]; 765 char buf[64];
765#if CONFIG_CODEC == SWCODEC 766#if CONFIG_CODEC == SWCODEC
766 int i; 767 int i;
@@ -985,9 +986,9 @@ void settings_apply(bool read_disk)
985#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC 986#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
986 enc_global_settings_apply(); 987 enc_global_settings_apply();
987#endif 988#endif
988 send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL); 989#ifdef HAVE_LCD_BITMAP
989 list_init_viewports(NULL); 990 viewportmanager_theme_changed(THEME_ALL);
990 send_event(GUI_EVENT_ACTIONUPDATE, (void*)true); 991#endif
991} 992}
992 993
993 994
@@ -1109,7 +1110,8 @@ bool set_int_ex(const unsigned char* string,
1109 item.lang_id = -1; 1110 item.lang_id = -1;
1110 item.cfg_vals = (char*)string; 1111 item.cfg_vals = (char*)string;
1111 item.setting = (void *)variable; 1112 item.setting = (void *)variable;
1112 return option_screen(&item, NULL, false, NULL); 1113 return option_screen(&item,
1114 viewport_get_current_vp(), false, NULL);
1113} 1115}
1114 1116
1115 1117
diff --git a/apps/settings.h b/apps/settings.h
index becf164a8f..998fdc1cd9 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -762,6 +762,13 @@ struct user_settings
762 /* If values are just added to the end, no need to bump plugin API 762 /* If values are just added to the end, no need to bump plugin API
763 version. */ 763 version. */
764 /* new stuff to be added at the end */ 764 /* new stuff to be added at the end */
765
766#ifdef HAVE_LCD_BITMAP
767 unsigned char ui_vp_config[64]; /* viewport string for the lists */
768#ifdef HAVE_REMOTE_LCD
769 unsigned char remote_ui_vp_config[64]; /* viewport string for the remote lists */
770#endif
771#endif
765}; 772};
766 773
767/** global variables **/ 774/** global variables **/
diff --git a/apps/settings_list.c b/apps/settings_list.c
index c03731f2b7..98dd900e3c 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -180,6 +180,10 @@
180 {.custom = (void*)default}, name, NULL, \ 180 {.custom = (void*)default}, name, NULL, \
181 {.custom_setting = (struct custom_setting[]){ \ 181 {.custom_setting = (struct custom_setting[]){ \
182 {load_from_cfg, write_to_cfg, is_change, set_default}}}} 182 {load_from_cfg, write_to_cfg, is_change, set_default}}}}
183
184#define VIEWPORT_SETTING(var,name,default) \
185 TEXT_SETTING(0,var,name,default, NULL, NULL)
186
183/* some sets of values which are used more than once, to save memory */ 187/* some sets of values which are used more than once, to save memory */
184static const char off_on[] = "off,on"; 188static const char off_on[] = "off,on";
185static const char off_on_ask[] = "off,on,ask"; 189static const char off_on_ask[] = "off,on,ask";
@@ -1539,6 +1543,13 @@ const struct settings_list settings[] = {
1539#endif 1543#endif
1540#endif 1544#endif
1541 1545
1546 /* Customizable list */
1547#ifdef HAVE_LCD_BITMAP
1548 VIEWPORT_SETTING(ui_vp_config, "ui viewport", ""),
1549#ifdef HAVE_REMOTE_LCD
1550 VIEWPORT_SETTING(remote_ui_vp_config, "remote ui viewport", ""),
1551#endif
1552#endif
1542}; 1553};
1543 1554
1544const int nb_settings = sizeof(settings)/sizeof(*settings); 1555const int nb_settings = sizeof(settings)/sizeof(*settings);