diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/viewport.c | 106 | ||||
-rw-r--r-- | apps/gui/viewport.h | 44 |
2 files changed, 81 insertions, 69 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 */ | ||
diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h index d431766ab5..9cabc00468 100644 --- a/apps/gui/viewport.h +++ b/apps/gui/viewport.h | |||
@@ -66,6 +66,7 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen); | |||
66 | #define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen) | 66 | #define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen) |
67 | #define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1)) | 67 | #define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1)) |
68 | 68 | ||
69 | #ifndef __PCTOOL__ | ||
69 | /* | 70 | /* |
70 | * Initialize the viewportmanager, which in turns initializes the UI vp and | 71 | * Initialize the viewportmanager, which in turns initializes the UI vp and |
71 | * statusbar stuff | 72 | * statusbar stuff |
@@ -86,25 +87,6 @@ void viewport_set_fullscreen(struct viewport *vp, enum screen_type screen); | |||
86 | #ifdef HAVE_LCD_BITMAP | 87 | #ifdef HAVE_LCD_BITMAP |
87 | 88 | ||
88 | /* | 89 | /* |
89 | * Parse a viewport definition (vp_def), which looks like: | ||
90 | * | ||
91 | * Screens with depth > 1: | ||
92 | * X|Y|width|height|font|foregorund color|background color | ||
93 | * Screens with depth = 1: | ||
94 | * X|Y|width|height|font | ||
95 | * | ||
96 | * | is a separator and can be specified via the parameter | ||
97 | * | ||
98 | * Returns the pointer to the char after the last character parsed | ||
99 | * if everything went OK or NULL if an error happened (some values | ||
100 | * not specified in the definition) | ||
101 | */ | ||
102 | const char* viewport_parse_viewport(struct viewport *vp, | ||
103 | enum screen_type screen, | ||
104 | const char *vp_def, | ||
105 | const char separator); | ||
106 | |||
107 | /* | ||
108 | * Returns a pointer to the current viewport | 90 | * Returns a pointer to the current viewport |
109 | * - That could be the UI vp, or a viewport passed to do_menu() or the like | 91 | * - That could be the UI vp, or a viewport passed to do_menu() or the like |
110 | */ | 92 | */ |
@@ -129,4 +111,28 @@ bool viewport_point_within_vp(const struct viewport *vp, int x, int y); | |||
129 | #define viewport_set_current_vp(a) | 111 | #define viewport_set_current_vp(a) |
130 | #define viewport_get_current_vp() NULL | 112 | #define viewport_get_current_vp() NULL |
131 | #endif | 113 | #endif |
114 | |||
115 | #endif /* __PCTOOL__ */ | ||
116 | |||
117 | #ifdef HAVE_LCD_BITMAP | ||
118 | |||
119 | /* | ||
120 | * Parse a viewport definition (vp_def), which looks like: | ||
121 | * | ||
122 | * Screens with depth > 1: | ||
123 | * X|Y|width|height|font|foregorund color|background color | ||
124 | * Screens with depth = 1: | ||
125 | * X|Y|width|height|font | ||
126 | * | ||
127 | * | is a separator and can be specified via the parameter | ||
128 | * | ||
129 | * Returns the pointer to the char after the last character parsed | ||
130 | * if everything went OK or NULL if an error happened (some values | ||
131 | * not specified in the definition) | ||
132 | */ | ||
133 | const char* viewport_parse_viewport(struct viewport *vp, | ||
134 | enum screen_type screen, | ||
135 | const char *vp_def, | ||
136 | const char separator); | ||
137 | #endif /* HAVE_LCD_BITMAP */ | ||
132 | #endif /* __VIEWPORT_H__ */ | 138 | #endif /* __VIEWPORT_H__ */ |