summaryrefslogtreecommitdiff
path: root/apps/gui/viewport.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-11-04 05:10:53 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-11-04 05:10:53 +0000
commita7d784b1d5912b68ca9d921961639fe948404811 (patch)
tree096d85a7f013a250c6affe29f8ab22ececfb34b2 /apps/gui/viewport.c
parent5ce8e2cb0d2361606f3646e9fa59a39393500ba8 (diff)
Fix viewport "UI area" to work based on what was agreed on last week in the mailing lists and IRC:
* viewport_set_defaults() will always set the viewport to the intersection of the user setting and any sbs set user viewport * viewport_set_fullscreen() will always set the viewport to the full display, take care to disable the statusbars if you use this! This patch is from FS#10709 and contains code which will be removed once the current inbuilt statusbar is finally removed. This *may* break themes which dont use the %we or %wd token.. follow up commit to fix this coming... git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23507 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/viewport.c')
-rw-r--r--apps/gui/viewport.c67
1 files changed, 42 insertions, 25 deletions
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index b5696842e3..5c6caebbc5 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -102,28 +102,9 @@ void viewport_set_fullscreen(struct viewport *vp,
const enum screen_type screen)
{
vp->x = 0;
+ vp->y = 0;
vp->width = screens[screen].lcdwidth;
-
-#ifdef HAVE_LCD_BITMAP
- struct viewport *sb_skin_vp = sb_skin_get_info_vp(screen);
- if (sb_skin_vp && sb_skin_get_state(screen)
- && statusbar_enabled & VP_SB_ONSCREEN(screen))
- {
- *vp = *sb_skin_vp;
- }
- else
- {
- if (statusbar_position(screen) != STATUSBAR_BOTTOM && showing_bars(screen))
- vp->y = STATUSBAR_HEIGHT;
- else
- vp->y = 0;
-#else
- {
- vp->y = 0;
-#endif
- vp->height = screens[screen].lcdheight
- - (showing_bars(screen)?STATUSBAR_HEIGHT:0);
- }
+ vp->height = screens[screen].lcdheight;
#ifdef HAVE_LCD_BITMAP
set_default_align_flags(vp);
@@ -158,13 +139,49 @@ void viewport_set_fullscreen(struct viewport *vp,
void viewport_set_defaults(struct viewport *vp,
const enum screen_type screen)
{
+ /* Reposition:
+ 1) If the "ui viewport" setting is set, and a sbs is loaded which specifies a %Vi
+ return the intersection of those two viewports
+ 2) If only one of the "ui viewport" setting, or sbs %Vi is set
+ return it
+ 3) No user viewports set
+ return the full display
+ */
#ifdef HAVE_LCD_BITMAP
+
+ struct viewport *sbs_area = NULL, *user_setting = NULL;
+ /* get the two viewports */
if (ui_vp_info.active[screen])
- *vp = ui_vp_info.vp[screen];
+ user_setting = &ui_vp_info.vp[screen];
+ if (sb_skin_get_state(screen))
+ sbs_area = sb_skin_get_info_vp(screen);
+ /* have both? get their intersection */
+ if (sbs_area && user_setting)
+ {
+ struct viewport *a = sbs_area, *b = user_setting;
+ /* make sure they do actually overlap,
+ * if they dont its user error, so use the full display
+ * and live with redraw problems */
+ if (a->x < b->x + b->width &&
+ a->x + a->width > b->x &&
+ a->y < b->y + b->height &&
+ a->y + a->height > b->y)
+ {
+ vp->x = MAX(a->x, b->x);
+ vp->y = MAX(a->y, b->y);
+ vp->width = MIN(a->x + a->width, b->x + b->width) - vp->x;
+ vp->height = MIN(a->y + a->height, b->y + b->height) - vp->y;
+ }
+ }
+ /* only one so use it */
+ else if (sbs_area)
+ *vp = *sbs_area;
+ else if (user_setting)
+ *vp = *user_setting;
+ /* have neither so its fullscreen which was fixed at the beginning */
else
-#endif
- viewport_set_fullscreen(vp, screen);
-
+ viewport_set_fullscreen(vp, screen);
+#endif /* HAVE_LCD_BITMAP */
}
void viewportmanager_init(void)