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 @@ #include "lcd.h" #include "lcd-remote.h" #include "font.h" -#include "sprintf.h" -#include "string.h" -#include "settings.h" -#include "kernel.h" -#include "system.h" -#include "misc.h" #include "viewport.h" -#include "statusbar.h" #include "screen_access.h" -#include "appevents.h" - - +#include "settings.h" +#include "misc.h" /*some short cuts for fg/bg/line selector handling */ #ifdef HAVE_LCD_COLOR @@ -54,6 +46,17 @@ #define BG_FALLBACK LCD_DEFAULT_BG #endif +/* all below isn't needed for pc tools (i.e. checkwps/wps editor) + * only viewport_parse_viewport() is */ +#ifndef __PCTOOL__ +#include "sprintf.h" +#include "string.h" +#include "kernel.h" +#include "system.h" +#include "statusbar.h" +#include "appevents.h" + + static int statusbar_enabled = 0; #ifdef HAVE_LCD_BITMAP @@ -295,12 +298,55 @@ bool viewport_ui_vp_get_state(enum screen_type screen) return ui_vp_info.active[screen]; } +/* + * (re)parse the UI vp from the settings + * - Returns + * 0 if no UI vp is used at all + * else the bit for the screen (1<<screen) is set + */ +static unsigned viewport_init_ui_vp(void) +{ + int screen; + unsigned ret = 0; + char *setting; + FOR_NB_SCREENS(screen) + { +#ifdef HAVE_REMOTE_LCD + if ((screen == SCREEN_REMOTE)) + setting = global_settings.remote_ui_vp_config; + else +#endif + setting = global_settings.ui_vp_config; + + + if (!(viewport_parse_viewport(&custom_vp[screen], screen, + setting, ','))) + viewport_set_fullscreen(&custom_vp[screen], screen); + else + ret |= BIT_N(screen); + } + return ret; +} + +#ifdef HAVE_TOUCHSCREEN +/* check if a point (x and y coordinates) are within a viewport */ +bool viewport_point_within_vp(const struct viewport *vp, int x, int y) +{ + bool is_x = (x >= vp->x && x < (vp->x + vp->width)); + bool is_y = (y >= vp->y && y < (vp->y + vp->height)); + return (is_x && is_y); +} +#endif /* HAVE_TOUCHSCREEN */ +#endif /* HAVE_LCD_BITMAP */ +#endif /* __PCTOOL__ */ + #ifdef HAVE_LCD_COLOR #define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc") #else #define ARG_STRING(_depth) "dddddgg" #endif +#ifdef HAVE_LCD_BITMAP const char* viewport_parse_viewport(struct viewport *vp, enum screen_type screen, const char *bufptr, @@ -386,44 +432,4 @@ const char* viewport_parse_viewport(struct viewport *vp, return ptr; } - -/* - * (re)parse the UI vp from the settings - * - Returns - * 0 if no UI vp is used at all - * else the bit for the screen (1<<screen) is set - */ -static unsigned viewport_init_ui_vp(void) -{ - int screen; - unsigned ret = 0; - char *setting; - FOR_NB_SCREENS(screen) - { -#ifdef HAVE_REMOTE_LCD - if ((screen == SCREEN_REMOTE)) - setting = global_settings.remote_ui_vp_config; - else #endif - setting = global_settings.ui_vp_config; - - - if (!(viewport_parse_viewport(&custom_vp[screen], screen, - setting, ','))) - viewport_set_fullscreen(&custom_vp[screen], screen); - else - ret |= BIT_N(screen); - } - return ret; -} - -#ifdef HAVE_TOUCHSCREEN -/* check if a point (x and y coordinates) are within a viewport */ -bool viewport_point_within_vp(const struct viewport *vp, int x, int y) -{ - bool is_x = (x >= vp->x && x < (vp->x + vp->width)); - bool is_y = (y >= vp->y && y < (vp->y + vp->height)); - return (is_x && is_y); -} -#endif /* HAVE_TOUCHSCREEN */ -#endif /* HAVE_LCD_BITMAP */ |