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 @@ | |||
38 | #define BG_FALLBACK LCD_DEFAULT_BG | 38 | #define BG_FALLBACK LCD_DEFAULT_BG |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | static void set_default_align_flags(struct viewport *vp); | ||
42 | |||
41 | /* all below isn't needed for pc tools (i.e. checkwps/wps editor) | 43 | /* all below isn't needed for pc tools (i.e. checkwps/wps editor) |
42 | * only viewport_parse_viewport() is */ | 44 | * only viewport_parse_viewport() is */ |
43 | #ifndef __PCTOOL__ | 45 | #ifndef __PCTOOL__ |
@@ -57,8 +59,6 @@ | |||
57 | static int statusbar_enabled = 0; | 59 | static int statusbar_enabled = 0; |
58 | 60 | ||
59 | #ifdef HAVE_LCD_BITMAP | 61 | #ifdef HAVE_LCD_BITMAP |
60 | static void set_default_align_flags(struct viewport *vp); | ||
61 | |||
62 | static struct { | 62 | static struct { |
63 | struct viewport* vp; | 63 | struct viewport* vp; |
64 | int active[NB_SCREENS]; | 64 | int active[NB_SCREENS]; |
@@ -98,91 +98,6 @@ static bool showing_bars(enum screen_type screen) | |||
98 | return false; | 98 | return false; |
99 | } | 99 | } |
100 | 100 | ||
101 | void viewport_set_fullscreen(struct viewport *vp, | ||
102 | const enum screen_type screen) | ||
103 | { | ||
104 | vp->x = 0; | ||
105 | vp->y = 0; | ||
106 | vp->width = screens[screen].lcdwidth; | ||
107 | vp->height = screens[screen].lcdheight; | ||
108 | |||
109 | #ifdef HAVE_LCD_BITMAP | ||
110 | set_default_align_flags(vp); | ||
111 | vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ | ||
112 | vp->drawmode = DRMODE_SOLID; | ||
113 | #if LCD_DEPTH > 1 | ||
114 | #ifdef HAVE_REMOTE_LCD | ||
115 | /* We only need this test if there is a remote LCD */ | ||
116 | if (screen == SCREEN_MAIN) | ||
117 | #endif | ||
118 | { | ||
119 | vp->fg_pattern = FG_FALLBACK; | ||
120 | vp->bg_pattern = BG_FALLBACK; | ||
121 | #ifdef HAVE_LCD_COLOR | ||
122 | vp->lss_pattern = global_settings.lss_color; | ||
123 | vp->lse_pattern = global_settings.lse_color; | ||
124 | vp->lst_pattern = global_settings.lst_color; | ||
125 | #endif | ||
126 | } | ||
127 | #endif | ||
128 | |||
129 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
130 | if (screen == SCREEN_REMOTE) | ||
131 | { | ||
132 | vp->fg_pattern = LCD_REMOTE_DEFAULT_FG; | ||
133 | vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; | ||
134 | } | ||
135 | #endif | ||
136 | #endif | ||
137 | } | ||
138 | |||
139 | void viewport_set_defaults(struct viewport *vp, | ||
140 | const enum screen_type screen) | ||
141 | { | ||
142 | /* Reposition: | ||
143 | 1) If the "ui viewport" setting is set, and a sbs is loaded which specifies a %Vi | ||
144 | return the intersection of those two viewports | ||
145 | 2) If only one of the "ui viewport" setting, or sbs %Vi is set | ||
146 | return it | ||
147 | 3) No user viewports set | ||
148 | return the full display | ||
149 | */ | ||
150 | #ifdef HAVE_LCD_BITMAP | ||
151 | |||
152 | struct viewport *sbs_area = NULL, *user_setting = NULL; | ||
153 | /* get the two viewports */ | ||
154 | if (ui_vp_info.active[screen]) | ||
155 | user_setting = &ui_vp_info.vp[screen]; | ||
156 | if (sb_skin_get_state(screen)) | ||
157 | sbs_area = sb_skin_get_info_vp(screen); | ||
158 | /* have both? get their intersection */ | ||
159 | if (sbs_area && user_setting) | ||
160 | { | ||
161 | struct viewport *a = sbs_area, *b = user_setting; | ||
162 | /* make sure they do actually overlap, | ||
163 | * if they dont its user error, so use the full display | ||
164 | * and live with redraw problems */ | ||
165 | if (a->x < b->x + b->width && | ||
166 | a->x + a->width > b->x && | ||
167 | a->y < b->y + b->height && | ||
168 | a->y + a->height > b->y) | ||
169 | { | ||
170 | vp->x = MAX(a->x, b->x); | ||
171 | vp->y = MAX(a->y, b->y); | ||
172 | vp->width = MIN(a->x + a->width, b->x + b->width) - vp->x; | ||
173 | vp->height = MIN(a->y + a->height, b->y + b->height) - vp->y; | ||
174 | } | ||
175 | } | ||
176 | /* only one so use it */ | ||
177 | else if (sbs_area) | ||
178 | *vp = *sbs_area; | ||
179 | else if (user_setting) | ||
180 | *vp = *user_setting; | ||
181 | /* have neither so its fullscreen which was fixed at the beginning */ | ||
182 | else | ||
183 | #endif /* HAVE_LCD_BITMAP */ | ||
184 | viewport_set_fullscreen(vp, screen); | ||
185 | } | ||
186 | 101 | ||
187 | void viewportmanager_init(void) | 102 | void viewportmanager_init(void) |
188 | { | 103 | { |
@@ -400,6 +315,94 @@ bool viewport_point_within_vp(const struct viewport *vp, | |||
400 | #define ARG_STRING(_depth) "dddddgg" | 315 | #define ARG_STRING(_depth) "dddddgg" |
401 | #endif | 316 | #endif |
402 | 317 | ||
318 | |||
319 | void viewport_set_fullscreen(struct viewport *vp, | ||
320 | const enum screen_type screen) | ||
321 | { | ||
322 | vp->x = 0; | ||
323 | vp->y = 0; | ||
324 | vp->width = screens[screen].lcdwidth; | ||
325 | vp->height = screens[screen].lcdheight; | ||
326 | |||
327 | #ifdef HAVE_LCD_BITMAP | ||
328 | set_default_align_flags(vp); | ||
329 | vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ | ||
330 | vp->drawmode = DRMODE_SOLID; | ||
331 | #if LCD_DEPTH > 1 | ||
332 | #ifdef HAVE_REMOTE_LCD | ||
333 | /* We only need this test if there is a remote LCD */ | ||
334 | if (screen == SCREEN_MAIN) | ||
335 | #endif | ||
336 | { | ||
337 | vp->fg_pattern = FG_FALLBACK; | ||
338 | vp->bg_pattern = BG_FALLBACK; | ||
339 | #ifdef HAVE_LCD_COLOR | ||
340 | vp->lss_pattern = global_settings.lss_color; | ||
341 | vp->lse_pattern = global_settings.lse_color; | ||
342 | vp->lst_pattern = global_settings.lst_color; | ||
343 | #endif | ||
344 | } | ||
345 | #endif | ||
346 | |||
347 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
348 | if (screen == SCREEN_REMOTE) | ||
349 | { | ||
350 | vp->fg_pattern = LCD_REMOTE_DEFAULT_FG; | ||
351 | vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; | ||
352 | } | ||
353 | #endif | ||
354 | #endif | ||
355 | } | ||
356 | |||
357 | void viewport_set_defaults(struct viewport *vp, | ||
358 | const enum screen_type screen) | ||
359 | { | ||
360 | /* Reposition: | ||
361 | 1) If the "ui viewport" setting is set, and a sbs is loaded which specifies a %Vi | ||
362 | return the intersection of those two viewports | ||
363 | 2) If only one of the "ui viewport" setting, or sbs %Vi is set | ||
364 | return it | ||
365 | 3) No user viewports set | ||
366 | return the full display | ||
367 | */ | ||
368 | #if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__) | ||
369 | |||
370 | struct viewport *sbs_area = NULL, *user_setting = NULL; | ||
371 | /* get the two viewports */ | ||
372 | if (ui_vp_info.active[screen]) | ||
373 | user_setting = &ui_vp_info.vp[screen]; | ||
374 | if (sb_skin_get_state(screen)) | ||
375 | sbs_area = sb_skin_get_info_vp(screen); | ||
376 | /* have both? get their intersection */ | ||
377 | if (sbs_area && user_setting) | ||
378 | { | ||
379 | struct viewport *a = sbs_area, *b = user_setting; | ||
380 | /* make sure they do actually overlap, | ||
381 | * if they dont its user error, so use the full display | ||
382 | * and live with redraw problems */ | ||
383 | if (a->x < b->x + b->width && | ||
384 | a->x + a->width > b->x && | ||
385 | a->y < b->y + b->height && | ||
386 | a->y + a->height > b->y) | ||
387 | { | ||
388 | vp->x = MAX(a->x, b->x); | ||
389 | vp->y = MAX(a->y, b->y); | ||
390 | vp->width = MIN(a->x + a->width, b->x + b->width) - vp->x; | ||
391 | vp->height = MIN(a->y + a->height, b->y + b->height) - vp->y; | ||
392 | } | ||
393 | } | ||
394 | /* only one so use it */ | ||
395 | else if (sbs_area) | ||
396 | *vp = *sbs_area; | ||
397 | else if (user_setting) | ||
398 | *vp = *user_setting; | ||
399 | /* have neither so its fullscreen which was fixed at the beginning */ | ||
400 | else | ||
401 | #endif /* HAVE_LCD_BITMAP */ | ||
402 | viewport_set_fullscreen(vp, screen); | ||
403 | } | ||
404 | |||
405 | |||
403 | #ifdef HAVE_LCD_BITMAP | 406 | #ifdef HAVE_LCD_BITMAP |
404 | 407 | ||
405 | static void set_default_align_flags(struct viewport *vp) | 408 | 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, | |||
231 | } | 231 | } |
232 | #endif | 232 | #endif |
233 | 233 | ||
234 | /* reimplement some simple stuff from viewport.c which doesnt change the skins | ||
235 | validity even if the values are not correct */ | ||
236 | void viewport_set_fullscreen(struct viewport *vp, | ||
237 | const enum screen_type screen) | ||
238 | { | ||
239 | vp->x = 0; | ||
240 | vp->y = 0; | ||
241 | vp->width = screens[screen].lcdwidth; | ||
242 | vp->height = screens[screen].lcdheight; | ||
243 | } | ||
244 | |||
245 | void viewport_set_defaults(struct viewport *vp, | ||
246 | const enum screen_type screen) | ||
247 | { | ||
248 | viewport_set_fullscreen(vp, screen); | ||
249 | } | ||
250 | |||
251 | |||
252 | int main(int argc, char **argv) | 234 | int main(int argc, char **argv) |
253 | { | 235 | { |
254 | int res; | 236 | int res; |