diff options
-rw-r--r-- | apps/gui/viewport.c | 177 | ||||
-rw-r--r-- | tools/checkwps/checkwps.c | 18 |
2 files changed, 90 insertions, 105 deletions
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index d9d37f8a6a..b2fed557c0 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -38,6 +38,8 @@ #define BG_FALLBACK LCD_DEFAULT_BG #endif +static void set_default_align_flags(struct viewport *vp); + /* all below isn't needed for pc tools (i.e. checkwps/wps editor) * only viewport_parse_viewport() is */ #ifndef __PCTOOL__ @@ -57,8 +59,6 @@ static int statusbar_enabled = 0; #ifdef HAVE_LCD_BITMAP -static void set_default_align_flags(struct viewport *vp); - static struct { struct viewport* vp; int active[NB_SCREENS]; @@ -98,91 +98,6 @@ static bool showing_bars(enum screen_type screen) return false; } -void viewport_set_fullscreen(struct viewport *vp, - const enum screen_type screen) -{ - vp->x = 0; - vp->y = 0; - vp->width = screens[screen].lcdwidth; - vp->height = screens[screen].lcdheight; - -#ifdef HAVE_LCD_BITMAP - set_default_align_flags(vp); - vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ - vp->drawmode = DRMODE_SOLID; -#if LCD_DEPTH > 1 -#ifdef HAVE_REMOTE_LCD - /* We only need this test if there is a remote LCD */ - if (screen == SCREEN_MAIN) -#endif - { - vp->fg_pattern = FG_FALLBACK; - vp->bg_pattern = BG_FALLBACK; -#ifdef HAVE_LCD_COLOR - vp->lss_pattern = global_settings.lss_color; - vp->lse_pattern = global_settings.lse_color; - vp->lst_pattern = global_settings.lst_color; -#endif - } -#endif - -#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 - if (screen == SCREEN_REMOTE) - { - vp->fg_pattern = LCD_REMOTE_DEFAULT_FG; - vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; - } -#endif -#endif -} - -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]) - 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 /* HAVE_LCD_BITMAP */ - viewport_set_fullscreen(vp, screen); -} void viewportmanager_init(void) { @@ -400,6 +315,94 @@ bool viewport_point_within_vp(const struct viewport *vp, #define ARG_STRING(_depth) "dddddgg" #endif + +void viewport_set_fullscreen(struct viewport *vp, + const enum screen_type screen) +{ + vp->x = 0; + vp->y = 0; + vp->width = screens[screen].lcdwidth; + vp->height = screens[screen].lcdheight; + +#ifdef HAVE_LCD_BITMAP + set_default_align_flags(vp); + vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ + vp->drawmode = DRMODE_SOLID; +#if LCD_DEPTH > 1 +#ifdef HAVE_REMOTE_LCD + /* We only need this test if there is a remote LCD */ + if (screen == SCREEN_MAIN) +#endif + { + vp->fg_pattern = FG_FALLBACK; + vp->bg_pattern = BG_FALLBACK; +#ifdef HAVE_LCD_COLOR + vp->lss_pattern = global_settings.lss_color; + vp->lse_pattern = global_settings.lse_color; + vp->lst_pattern = global_settings.lst_color; +#endif + } +#endif + +#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 + if (screen == SCREEN_REMOTE) + { + vp->fg_pattern = LCD_REMOTE_DEFAULT_FG; + vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; + } +#endif +#endif +} + +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 + */ +#if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__) + + struct viewport *sbs_area = NULL, *user_setting = NULL; + /* get the two viewports */ + if (ui_vp_info.active[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 /* HAVE_LCD_BITMAP */ + viewport_set_fullscreen(vp, screen); +} + + #ifdef HAVE_LCD_BITMAP static void set_default_align_flags(struct viewport *vp) diff --git a/tools/checkwps/checkwps.c b/tools/checkwps/checkwps.c index 596082a798..14a1f69c0d 100644 --- a/tools/checkwps/checkwps.c +++ b/tools/checkwps/checkwps.c @@ -231,24 +231,6 @@ void screen_clear_area(struct screen * display, int xstart, int ystart, } #endif -/* reimplement some simple stuff from viewport.c which doesnt change the skins - validity even if the values are not correct */ -void viewport_set_fullscreen(struct viewport *vp, - const enum screen_type screen) -{ - vp->x = 0; - vp->y = 0; - vp->width = screens[screen].lcdwidth; - vp->height = screens[screen].lcdheight; -} - -void viewport_set_defaults(struct viewport *vp, - const enum screen_type screen) -{ - viewport_set_fullscreen(vp, screen); -} - - int main(int argc, char **argv) { int res; |