diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-09-13 13:40:58 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-09-13 13:40:58 +0000 |
commit | c0f1c49178b4c205e1c990ea2fb25a417305528c (patch) | |
tree | 637fdedd15f2119125cdaa257fbf7798e8687e74 /apps/gui/viewport.c | |
parent | 541dd6fda5ae93073a0b9c499f62af2cf46f3529 (diff) | |
download | rockbox-c0f1c49178b4c205e1c990ea2fb25a417305528c.tar.gz rockbox-c0f1c49178b4c205e1c990ea2fb25a417305528c.zip |
Get rid of some of the code duplication from checkwps, it still duplicates a lot though.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22695 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/viewport.c')
-rw-r--r-- | apps/gui/viewport.c | 106 |
1 files changed, 56 insertions, 50 deletions
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index 06caa2379d..ff3a110936 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c | |||
@@ -24,18 +24,10 @@ | |||
24 | #include "lcd.h" | 24 | #include "lcd.h" |
25 | #include "lcd-remote.h" | 25 | #include "lcd-remote.h" |
26 | #include "font.h" | 26 | #include "font.h" |
27 | #include "sprintf.h" | ||
28 | #include "string.h" | ||
29 | #include "settings.h" | ||
30 | #include "kernel.h" | ||
31 | #include "system.h" | ||
32 | #include "misc.h" | ||
33 | #include "viewport.h" | 27 | #include "viewport.h" |
34 | #include "statusbar.h" | ||
35 | #include "screen_access.h" | 28 | #include "screen_access.h" |
36 | #include "appevents.h" | 29 | #include "settings.h" |
37 | 30 | #include "misc.h" | |
38 | |||
39 | 31 | ||
40 | /*some short cuts for fg/bg/line selector handling */ | 32 | /*some short cuts for fg/bg/line selector handling */ |
41 | #ifdef HAVE_LCD_COLOR | 33 | #ifdef HAVE_LCD_COLOR |
@@ -54,6 +46,17 @@ | |||
54 | #define BG_FALLBACK LCD_DEFAULT_BG | 46 | #define BG_FALLBACK LCD_DEFAULT_BG |
55 | #endif | 47 | #endif |
56 | 48 | ||
49 | /* all below isn't needed for pc tools (i.e. checkwps/wps editor) | ||
50 | * only viewport_parse_viewport() is */ | ||
51 | #ifndef __PCTOOL__ | ||
52 | #include "sprintf.h" | ||
53 | #include "string.h" | ||
54 | #include "kernel.h" | ||
55 | #include "system.h" | ||
56 | #include "statusbar.h" | ||
57 | #include "appevents.h" | ||
58 | |||
59 | |||
57 | static int statusbar_enabled = 0; | 60 | static int statusbar_enabled = 0; |
58 | 61 | ||
59 | #ifdef HAVE_LCD_BITMAP | 62 | #ifdef HAVE_LCD_BITMAP |
@@ -295,12 +298,55 @@ bool viewport_ui_vp_get_state(enum screen_type screen) | |||
295 | return ui_vp_info.active[screen]; | 298 | return ui_vp_info.active[screen]; |
296 | } | 299 | } |
297 | 300 | ||
301 | /* | ||
302 | * (re)parse the UI vp from the settings | ||
303 | * - Returns | ||
304 | * 0 if no UI vp is used at all | ||
305 | * else the bit for the screen (1<<screen) is set | ||
306 | */ | ||
307 | static unsigned viewport_init_ui_vp(void) | ||
308 | { | ||
309 | int screen; | ||
310 | unsigned ret = 0; | ||
311 | char *setting; | ||
312 | FOR_NB_SCREENS(screen) | ||
313 | { | ||
314 | #ifdef HAVE_REMOTE_LCD | ||
315 | if ((screen == SCREEN_REMOTE)) | ||
316 | setting = global_settings.remote_ui_vp_config; | ||
317 | else | ||
318 | #endif | ||
319 | setting = global_settings.ui_vp_config; | ||
320 | |||
321 | |||
322 | if (!(viewport_parse_viewport(&custom_vp[screen], screen, | ||
323 | setting, ','))) | ||
324 | viewport_set_fullscreen(&custom_vp[screen], screen); | ||
325 | else | ||
326 | ret |= BIT_N(screen); | ||
327 | } | ||
328 | return ret; | ||
329 | } | ||
330 | |||
331 | #ifdef HAVE_TOUCHSCREEN | ||
332 | /* check if a point (x and y coordinates) are within a viewport */ | ||
333 | bool viewport_point_within_vp(const struct viewport *vp, int x, int y) | ||
334 | { | ||
335 | bool is_x = (x >= vp->x && x < (vp->x + vp->width)); | ||
336 | bool is_y = (y >= vp->y && y < (vp->y + vp->height)); | ||
337 | return (is_x && is_y); | ||
338 | } | ||
339 | #endif /* HAVE_TOUCHSCREEN */ | ||
340 | #endif /* HAVE_LCD_BITMAP */ | ||
341 | #endif /* __PCTOOL__ */ | ||
342 | |||
298 | #ifdef HAVE_LCD_COLOR | 343 | #ifdef HAVE_LCD_COLOR |
299 | #define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc") | 344 | #define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc") |
300 | #else | 345 | #else |
301 | #define ARG_STRING(_depth) "dddddgg" | 346 | #define ARG_STRING(_depth) "dddddgg" |
302 | #endif | 347 | #endif |
303 | 348 | ||
349 | #ifdef HAVE_LCD_BITMAP | ||
304 | const char* viewport_parse_viewport(struct viewport *vp, | 350 | const char* viewport_parse_viewport(struct viewport *vp, |
305 | enum screen_type screen, | 351 | enum screen_type screen, |
306 | const char *bufptr, | 352 | const char *bufptr, |
@@ -386,44 +432,4 @@ const char* viewport_parse_viewport(struct viewport *vp, | |||
386 | 432 | ||
387 | return ptr; | 433 | return ptr; |
388 | } | 434 | } |
389 | |||
390 | /* | ||
391 | * (re)parse the UI vp from the settings | ||
392 | * - Returns | ||
393 | * 0 if no UI vp is used at all | ||
394 | * else the bit for the screen (1<<screen) is set | ||
395 | */ | ||
396 | static unsigned viewport_init_ui_vp(void) | ||
397 | { | ||
398 | int screen; | ||
399 | unsigned ret = 0; | ||
400 | char *setting; | ||
401 | FOR_NB_SCREENS(screen) | ||
402 | { | ||
403 | #ifdef HAVE_REMOTE_LCD | ||
404 | if ((screen == SCREEN_REMOTE)) | ||
405 | setting = global_settings.remote_ui_vp_config; | ||
406 | else | ||
407 | #endif | 435 | #endif |
408 | setting = global_settings.ui_vp_config; | ||
409 | |||
410 | |||
411 | if (!(viewport_parse_viewport(&custom_vp[screen], screen, | ||
412 | setting, ','))) | ||
413 | viewport_set_fullscreen(&custom_vp[screen], screen); | ||
414 | else | ||
415 | ret |= BIT_N(screen); | ||
416 | } | ||
417 | return ret; | ||
418 | } | ||
419 | |||
420 | #ifdef HAVE_TOUCHSCREEN | ||
421 | /* check if a point (x and y coordinates) are within a viewport */ | ||
422 | bool viewport_point_within_vp(const struct viewport *vp, int x, int y) | ||
423 | { | ||
424 | bool is_x = (x >= vp->x && x < (vp->x + vp->width)); | ||
425 | bool is_y = (y >= vp->y && y < (vp->y + vp->height)); | ||
426 | return (is_x && is_y); | ||
427 | } | ||
428 | #endif /* HAVE_TOUCHSCREEN */ | ||
429 | #endif /* HAVE_LCD_BITMAP */ | ||