summaryrefslogtreecommitdiff
path: root/apps/gui/viewport.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/viewport.c')
-rw-r--r--apps/gui/viewport.c91
1 files changed, 8 insertions, 83 deletions
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index fd38b18d75..78b6379bd7 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -109,11 +109,11 @@ static void toggle_theme(enum screen_type screen, bool force)
109 109
110 if (is_theme_enabled(screen)) 110 if (is_theme_enabled(screen))
111 { 111 {
112#if LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1)
113 screens[screen].backdrop_show(BACKDROP_MAIN);
114#endif
115 /* remove the left overs from the previous screen. 112 /* remove the left overs from the previous screen.
116 * could cause a tiny flicker. Redo your screen code if that happens */ 113 * could cause a tiny flicker. Redo your screen code if that happens */
114#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
115 screens[screen].backdrop_show(sb_get_backdrop(screen));
116#endif
117 if (!was_enabled[screen] || force) 117 if (!was_enabled[screen] || force)
118 { 118 {
119 struct viewport deadspace, user; 119 struct viewport deadspace, user;
@@ -165,7 +165,7 @@ static void toggle_theme(enum screen_type screen, bool force)
165 else 165 else
166 { 166 {
167#if LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1) 167#if LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1)
168 screens[screen].backdrop_hide(); 168 screens[screen].backdrop_show(NULL);
169#endif 169#endif
170 screens[screen].stop_scroll(); 170 screens[screen].stop_scroll();
171 } 171 }
@@ -204,11 +204,6 @@ static bool is_theme_enabled(enum screen_type screen)
204 int top = theme_stack_top[screen]; 204 int top = theme_stack_top[screen];
205 return theme_stack[screen][top].enabled; 205 return theme_stack[screen][top].enabled;
206} 206}
207
208static bool custom_vp_loaded_ok[NB_SCREENS];
209static struct viewport custom_vp[NB_SCREENS];
210
211static unsigned viewport_init_ui_vp(void);
212#endif /* HAVE_LCD_BITMAP */ 207#endif /* HAVE_LCD_BITMAP */
213 208
214int viewport_get_nb_lines(const struct viewport *vp) 209int viewport_get_nb_lines(const struct viewport *vp)
@@ -263,7 +258,6 @@ void viewportmanager_theme_changed(const int which)
263#endif 258#endif
264 if (which & THEME_UI_VIEWPORT) 259 if (which & THEME_UI_VIEWPORT)
265 { 260 {
266 viewport_init_ui_vp();
267 } 261 }
268 if (which & THEME_LANGUAGE) 262 if (which & THEME_LANGUAGE)
269 { 263 {
@@ -281,34 +275,6 @@ void viewportmanager_theme_changed(const int which)
281 send_event(GUI_EVENT_THEME_CHANGED, NULL); 275 send_event(GUI_EVENT_THEME_CHANGED, NULL);
282} 276}
283 277
284/*
285 * (re)parse the UI vp from the settings
286 * - Returns
287 * 0 if no UI vp is used at all
288 * else the bit for the screen (1<<screen) is set
289 */
290static unsigned viewport_init_ui_vp(void)
291{
292 int screen;
293 const char *ret = NULL;
294 char *setting;
295 FOR_NB_SCREENS(screen)
296 {
297#ifdef HAVE_REMOTE_LCD
298 if ((screen == SCREEN_REMOTE))
299 setting = global_settings.remote_ui_vp_config;
300 else
301#endif
302 setting = global_settings.ui_vp_config;
303
304 ret = viewport_parse_viewport(&custom_vp[screen], screen,
305 setting, ',');
306
307 custom_vp_loaded_ok[screen] = (ret != NULL);
308 }
309 return true; /* meh fixme */
310}
311
312#ifdef HAVE_TOUCHSCREEN 278#ifdef HAVE_TOUCHSCREEN
313/* check if a point (x and y coordinates) are within a viewport */ 279/* check if a point (x and y coordinates) are within a viewport */
314bool viewport_point_within_vp(const struct viewport *vp, 280bool viewport_point_within_vp(const struct viewport *vp,
@@ -380,59 +346,18 @@ void viewport_set_fullscreen(struct viewport *vp,
380void viewport_set_defaults(struct viewport *vp, 346void viewport_set_defaults(struct viewport *vp,
381 const enum screen_type screen) 347 const enum screen_type screen)
382{ 348{
383 /* Reposition:
384 1) If the "ui viewport" setting is set, and a sbs is loaded which specifies a %Vi
385 return the intersection of those two viewports
386 2) If only one of the "ui viewport" setting, or sbs %Vi is set
387 return it
388 3) No user viewports set
389 return the full display
390 */
391#if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__) 349#if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__)
392 350
393 struct viewport *sbs_area = NULL, *user_setting = NULL; 351 struct viewport *sbs_area = NULL;
394 if (!is_theme_enabled(screen)) 352 if (!is_theme_enabled(screen))
395 { 353 {
396 viewport_set_fullscreen(vp, screen); 354 viewport_set_fullscreen(vp, screen);
397 return; 355 return;
398 }
399 /* get the two viewports */
400 if (custom_vp_loaded_ok[screen])
401 user_setting = &custom_vp[screen];
402 if (sb_skin_get_state(screen))
403 sbs_area = sb_skin_get_info_vp(screen);
404
405 /* have both? get their intersection */
406 if (sbs_area && user_setting)
407 {
408 struct viewport *a = sbs_area, *b = user_setting;
409 /* if ui vp and info vp overlap, intersect */
410 if (a->x < b->x + b->width &&
411 a->x + a->width > b->x &&
412 a->y < b->y + b->height &&
413 a->y + a->height > b->y)
414 {
415 /* copy from ui vp first (for other field),fix coordinates after */
416 *vp = *user_setting;
417 set_default_align_flags(vp);
418 vp->x = MAX(a->x, b->x);
419 vp->y = MAX(a->y, b->y);
420 vp->width = MIN(a->x + a->width, b->x + b->width) - vp->x;
421 vp->height = MIN(a->y + a->height, b->y + b->height) - vp->y;
422 return;
423 }
424 /* else (no overlap at all) fall back to info vp from sbs, that
425 * has no redraw problems */
426 } 356 }
427 357 sbs_area = sb_skin_get_info_vp(screen);
428 /* if only one is active use it 358
429 * or if the above check for overlapping failed, use info vp then, because
430 * that doesn't give redraw problems */
431 if (sbs_area) 359 if (sbs_area)
432 *vp = *sbs_area; 360 *vp = *sbs_area;
433 else if (user_setting)
434 *vp = *user_setting;
435 /* have neither so its fullscreen which was fixed at the beginning */
436 else 361 else
437#endif /* HAVE_LCD_BITMAP */ 362#endif /* HAVE_LCD_BITMAP */
438 viewport_set_fullscreen(vp, screen); 363 viewport_set_fullscreen(vp, screen);