diff options
Diffstat (limited to 'apps/gui/viewport.c')
-rw-r--r-- | apps/gui/viewport.c | 104 |
1 files changed, 101 insertions, 3 deletions
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index d635c10481..52704d9f69 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c | |||
@@ -35,6 +35,15 @@ | |||
35 | #include "screen_access.h" | 35 | #include "screen_access.h" |
36 | #include "appevents.h" | 36 | #include "appevents.h" |
37 | 37 | ||
38 | |||
39 | |||
40 | #define LINE_SEL_FROM_SETTINGS(vp) \ | ||
41 | do { \ | ||
42 | vp->lss_pattern = global_settings.lss_color; \ | ||
43 | vp->lse_pattern = global_settings.lse_color; \ | ||
44 | vp->lst_pattern = global_settings.lst_color; \ | ||
45 | } while (0) | ||
46 | |||
38 | static int statusbar_enabled = 0; | 47 | static int statusbar_enabled = 0; |
39 | 48 | ||
40 | int viewport_get_nb_lines(struct viewport *vp) | 49 | int viewport_get_nb_lines(struct viewport *vp) |
@@ -88,9 +97,7 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen) | |||
88 | #ifdef HAVE_LCD_COLOR | 97 | #ifdef HAVE_LCD_COLOR |
89 | vp->fg_pattern = global_settings.fg_color; | 98 | vp->fg_pattern = global_settings.fg_color; |
90 | vp->bg_pattern = global_settings.bg_color; | 99 | vp->bg_pattern = global_settings.bg_color; |
91 | vp->lss_pattern = global_settings.lss_color; | 100 | LINE_SEL_FROM_SETTINGS(vp); |
92 | vp->lse_pattern = global_settings.lse_color; | ||
93 | vp->lst_pattern = global_settings.lst_color; | ||
94 | #elif LCD_DEPTH > 1 | 101 | #elif LCD_DEPTH > 1 |
95 | vp->fg_pattern = LCD_DEFAULT_FG; | 102 | vp->fg_pattern = LCD_DEFAULT_FG; |
96 | vp->bg_pattern = LCD_DEFAULT_BG; | 103 | vp->bg_pattern = LCD_DEFAULT_BG; |
@@ -151,3 +158,94 @@ void viewportmanager_statusbar_changed(void* data) | |||
151 | #endif | 158 | #endif |
152 | viewportmanager_set_statusbar(statusbar_enabled); | 159 | viewportmanager_set_statusbar(statusbar_enabled); |
153 | } | 160 | } |
161 | |||
162 | const char* viewport_parse_viewport(struct viewport *vp, | ||
163 | enum screen_type screen, | ||
164 | const char *bufptr, | ||
165 | const char separator) | ||
166 | { | ||
167 | /* parse the list to the viewport struct */ | ||
168 | const char *ptr = bufptr; | ||
169 | int depth; | ||
170 | uint32_t set = 0; | ||
171 | |||
172 | enum { | ||
173 | PL_X = 0, | ||
174 | PL_Y, | ||
175 | PL_WIDTH, | ||
176 | PL_HEIGHT, | ||
177 | PL_FONT, | ||
178 | PL_FG, | ||
179 | PL_BG, | ||
180 | }; | ||
181 | |||
182 | /* Work out the depth of this display */ | ||
183 | depth = screens[screen].depth; | ||
184 | #ifdef HAVE_LCD_COLOR | ||
185 | if (depth == 16) | ||
186 | { | ||
187 | if (!(ptr = parse_list("dddddcc", &set, separator, ptr, &vp->x, &vp->y, &vp->width, | ||
188 | &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern))) | ||
189 | return VP_ERROR; | ||
190 | } | ||
191 | else | ||
192 | #endif | ||
193 | #if (LCD_DEPTH == 2) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2) | ||
194 | if (depth == 2) { | ||
195 | if (!(ptr = parse_list("dddddgg", &set, separator, ptr, &vp->x, &vp->y, &vp->width, | ||
196 | &vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern))) | ||
197 | return VP_ERROR; | ||
198 | } | ||
199 | else | ||
200 | #endif | ||
201 | #if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1) | ||
202 | if (depth == 1) | ||
203 | { | ||
204 | if (!(ptr = parse_list("ddddd", &set, separator, ptr, &vp->x, &vp->y, &vp->width, | ||
205 | &vp->height, &vp->font))) | ||
206 | return VP_ERROR; | ||
207 | } | ||
208 | else | ||
209 | #endif | ||
210 | {} | ||
211 | |||
212 | /* X and Y *must* be set */ | ||
213 | if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y)) | ||
214 | return VP_ERROR; | ||
215 | |||
216 | /* fix defaults */ | ||
217 | if (!LIST_VALUE_PARSED(set, PL_WIDTH)) | ||
218 | vp->width = screens[screen].lcdwidth - vp->x; | ||
219 | if (!LIST_VALUE_PARSED(set, PL_HEIGHT)) | ||
220 | vp->height = screens[screen].lcdheight - vp->y; | ||
221 | |||
222 | #if (LCD_DEPTH > 1) | ||
223 | if (!LIST_VALUE_PARSED(set, PL_FG)) | ||
224 | vp->fg_pattern = global_settings.fg_color; | ||
225 | if (!LIST_VALUE_PARSED(set, PL_BG)) | ||
226 | vp->bg_pattern = global_settings.bg_color; | ||
227 | #endif | ||
228 | #ifdef HAVE_LCD_COLOR | ||
229 | LINE_SEL_FROM_SETTINGS(vp); | ||
230 | #endif | ||
231 | /* Validate the viewport dimensions - we know that the numbers are | ||
232 | non-negative integers, ignore bars and assume the viewport takes them | ||
233 | * into account */ | ||
234 | if ((vp->x >= screens[screen].lcdwidth) || | ||
235 | ((vp->x + vp->width) > screens[screen].lcdwidth) || | ||
236 | (vp->y >= screens[screen].lcdheight) || | ||
237 | ((vp->y + vp->height) > screens[screen].lcdheight)) | ||
238 | { | ||
239 | return VP_ERROR; | ||
240 | } | ||
241 | |||
242 | /* Default to using the user font if the font was an invalid number or '-'*/ | ||
243 | if (((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI)) | ||
244 | || !LIST_VALUE_PARSED(set, PL_FONT) | ||
245 | ) | ||
246 | vp->font = FONT_UI; | ||
247 | |||
248 | vp->drawmode = DRMODE_SOLID; | ||
249 | |||
250 | return ptr; | ||
251 | } | ||