diff options
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_settings.c')
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.c | 145 |
1 files changed, 83 insertions, 62 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index e99823ed5c..720101706c 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c | |||
@@ -178,17 +178,56 @@ static void display_options(void) | |||
178 | menu_exit(menu_id); | 178 | menu_exit(menu_id); |
179 | } | 179 | } |
180 | 180 | ||
181 | #ifndef HAVE_LCD_COLOR | ||
182 | /* Cheapo splash implementation for the grey surface */ | ||
183 | static void grey_splash(int ticks, const unsigned char *fmt, ...) | ||
184 | { | ||
185 | unsigned char buffer[256]; | ||
186 | int x, y, w, h; | ||
187 | int oldfg, oldmode; | ||
188 | |||
189 | va_list ap; | ||
190 | va_start(ap, fmt); | ||
191 | |||
192 | rb->vsnprintf(buffer, sizeof (buffer), fmt, ap); | ||
193 | |||
194 | va_end(ap); | ||
195 | |||
196 | grey_getstringsize(buffer, &w, &h); | ||
197 | |||
198 | oldfg = grey_get_foreground(); | ||
199 | oldmode = grey_get_drawmode(); | ||
200 | |||
201 | grey_set_drawmode(DRMODE_FG); | ||
202 | grey_set_foreground(GREY_LIGHTGRAY); | ||
203 | |||
204 | x = (LCD_WIDTH - w) / 2; | ||
205 | y = (LCD_HEIGHT - h) / 2; | ||
206 | |||
207 | grey_fillrect(x - 1, y - 1, w + 2, h + 2); | ||
208 | |||
209 | grey_set_foreground(GREY_BLACK); | ||
210 | |||
211 | grey_putsxy(x, y, buffer); | ||
212 | grey_drawrect(x - 2, y - 2, w + 4, h + 4); | ||
213 | |||
214 | grey_set_foreground(oldfg); | ||
215 | grey_set_drawmode(oldmode); | ||
216 | |||
217 | grey_update(); | ||
218 | |||
219 | if (ticks > 0) | ||
220 | rb->sleep(ticks); | ||
221 | } | ||
222 | #endif /* !HAVE_LCD_COLOR */ | ||
223 | |||
181 | static void show_loading(struct vo_rect *rc) | 224 | static void show_loading(struct vo_rect *rc) |
182 | { | 225 | { |
183 | int oldmode; | 226 | int oldmode = lcd_(get_drawmode)(); |
184 | #ifndef HAVE_LCD_COLOR | 227 | lcd_(set_drawmode)(DRMODE_SOLID | DRMODE_INVERSEVID); |
185 | stream_gray_show(false); | 228 | lcd_(fillrect)(rc->l-1, rc->t-1, rc->r - rc->l + 2, rc->b - rc->t + 2); |
186 | #endif | 229 | lcd_(set_drawmode)(oldmode); |
187 | oldmode = rb->lcd_get_drawmode(); | 230 | lcd_(splash)(0, "Loading..."); |
188 | rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); | ||
189 | rb->lcd_fillrect(rc->l-1, rc->t-1, rc->r - rc->l + 2, rc->b - rc->t + 2); | ||
190 | rb->lcd_set_drawmode(oldmode); | ||
191 | rb->splash(0, "Loading..."); | ||
192 | } | 231 | } |
193 | 232 | ||
194 | void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc) | 233 | void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc) |
@@ -211,36 +250,36 @@ void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc) | |||
211 | /* Put positition on left */ | 250 | /* Put positition on left */ |
212 | ts_to_hms(pos, &hms); | 251 | ts_to_hms(pos, &hms); |
213 | hms_format(str, sizeof(str), &hms); | 252 | hms_format(str, sizeof(str), &hms); |
214 | rb->lcd_getstringsize(str, NULL, &text_h); | 253 | lcd_(getstringsize)(str, NULL, &text_h); |
215 | text_y = SLIDER_Y - SLIDER_TEXTMARGIN - text_h; | 254 | text_y = SLIDER_Y - SLIDER_TEXTMARGIN - text_h; |
216 | 255 | ||
217 | if (rc == NULL) | 256 | if (rc == NULL) |
218 | { | 257 | { |
219 | int oldmode = rb->lcd_get_drawmode(); | 258 | int oldmode = lcd_(get_drawmode)(); |
220 | rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); | 259 | lcd_(set_drawmode)(DRMODE_BG | DRMODE_INVERSEVID); |
221 | rb->lcd_fillrect(SLIDER_X, text_y, SLIDER_WIDTH, | 260 | lcd_(fillrect)(SLIDER_X, text_y, SLIDER_WIDTH, |
222 | LCD_HEIGHT - SLIDER_BMARGIN - text_y | 261 | LCD_HEIGHT - SLIDER_BMARGIN - text_y |
223 | - SLIDER_TMARGIN); | 262 | - SLIDER_TMARGIN); |
224 | rb->lcd_set_drawmode(oldmode); | 263 | lcd_(set_drawmode)(oldmode); |
225 | 264 | ||
226 | rb->lcd_putsxy(SLIDER_X, text_y, str); | 265 | lcd_(putsxy)(SLIDER_X, text_y, str); |
227 | 266 | ||
228 | /* Put duration on right */ | 267 | /* Put duration on right */ |
229 | ts_to_hms(range, &hms); | 268 | ts_to_hms(range, &hms); |
230 | hms_format(str, sizeof(str), &hms); | 269 | hms_format(str, sizeof(str), &hms); |
231 | rb->lcd_getstringsize(str, &text_w, NULL); | 270 | lcd_(getstringsize)(str, &text_w, NULL); |
232 | 271 | ||
233 | rb->lcd_putsxy(SLIDER_X + SLIDER_WIDTH - text_w, text_y, str); | 272 | lcd_(putsxy)(SLIDER_X + SLIDER_WIDTH - text_w, text_y, str); |
234 | 273 | ||
235 | /* Draw slider */ | 274 | /* Draw slider */ |
236 | rb->lcd_drawrect(SLIDER_X, SLIDER_Y, SLIDER_WIDTH, SLIDER_HEIGHT); | 275 | lcd_(drawrect)(SLIDER_X, SLIDER_Y, SLIDER_WIDTH, SLIDER_HEIGHT); |
237 | rb->lcd_fillrect(SLIDER_X, SLIDER_Y, | 276 | lcd_(fillrect)(SLIDER_X, SLIDER_Y, |
238 | muldiv_uint32(pos, SLIDER_WIDTH, range), | 277 | muldiv_uint32(pos, SLIDER_WIDTH, range), |
239 | SLIDER_HEIGHT); | 278 | SLIDER_HEIGHT); |
240 | 279 | ||
241 | /* Update screen */ | 280 | /* Update screen */ |
242 | rb->lcd_update_rect(SLIDER_X, text_y - SLIDER_TMARGIN, SLIDER_WIDTH, | 281 | lcd_(update_rect)(SLIDER_X, text_y - SLIDER_TMARGIN, SLIDER_WIDTH, |
243 | LCD_HEIGHT - SLIDER_BMARGIN - text_y + SLIDER_TEXTMARGIN); | 282 | LCD_HEIGHT - SLIDER_BMARGIN - text_y + SLIDER_TEXTMARGIN); |
244 | } | 283 | } |
245 | else | 284 | else |
246 | { | 285 | { |
@@ -256,33 +295,28 @@ bool display_thumb_image(const struct vo_rect *rc) | |||
256 | { | 295 | { |
257 | if (!stream_display_thumb(rc)) | 296 | if (!stream_display_thumb(rc)) |
258 | { | 297 | { |
259 | rb->splash(0, "Frame not available"); | 298 | lcd_(splash)(0, "Frame not available"); |
260 | return false; | 299 | return false; |
261 | } | 300 | } |
262 | 301 | ||
263 | #ifdef HAVE_LCD_COLOR | ||
264 | /* Draw a raised border around the frame */ | 302 | /* Draw a raised border around the frame */ |
265 | int oldcolor = rb->lcd_get_foreground(); | 303 | int oldcolor = lcd_(get_foreground)(); |
266 | rb->lcd_set_foreground(LCD_LIGHTGRAY); | 304 | lcd_(set_foreground)(DRAW_LIGHTGRAY); |
267 | 305 | ||
268 | rb->lcd_hline(rc->l-1, rc->r-1, rc->t-1); | 306 | lcd_(hline)(rc->l-1, rc->r-1, rc->t-1); |
269 | rb->lcd_vline(rc->l-1, rc->t, rc->b-1); | 307 | lcd_(vline)(rc->l-1, rc->t, rc->b-1); |
270 | 308 | ||
271 | rb->lcd_set_foreground(LCD_DARKGRAY); | 309 | lcd_(set_foreground)(DRAW_DARKGRAY); |
272 | 310 | ||
273 | rb->lcd_hline(rc->l-1, rc->r, rc->b); | 311 | lcd_(hline)(rc->l-1, rc->r, rc->b); |
274 | rb->lcd_vline(rc->r, rc->t-1, rc->b); | 312 | lcd_(vline)(rc->r, rc->t-1, rc->b); |
275 | 313 | ||
276 | rb->lcd_set_foreground(oldcolor); | 314 | lcd_(set_foreground)(oldcolor); |
277 | 315 | ||
278 | rb->lcd_update_rect(rc->l-1, rc->t-1, rc->r - rc->l + 2, 1); | 316 | lcd_(update_rect)(rc->l-1, rc->t-1, rc->r - rc->l + 2, 1); |
279 | rb->lcd_update_rect(rc->l-1, rc->t, 1, rc->b - rc->t); | 317 | lcd_(update_rect)(rc->l-1, rc->t, 1, rc->b - rc->t); |
280 | rb->lcd_update_rect(rc->l-1, rc->b, rc->r - rc->l + 2, 1); | 318 | lcd_(update_rect)(rc->l-1, rc->b, rc->r - rc->l + 2, 1); |
281 | rb->lcd_update_rect(rc->r, rc->t, 1, rc->b - rc->t); | 319 | lcd_(update_rect)(rc->r, rc->t, 1, rc->b - rc->t); |
282 | #else | ||
283 | /* Just show the thumbnail */ | ||
284 | stream_gray_show(true); | ||
285 | #endif | ||
286 | 320 | ||
287 | return true; | 321 | return true; |
288 | } | 322 | } |
@@ -320,18 +354,12 @@ int get_start_time(uint32_t duration) | |||
320 | 354 | ||
321 | enum state_enum slider_state = state0; | 355 | enum state_enum slider_state = state0; |
322 | 356 | ||
323 | rb->lcd_clear_display(); | 357 | lcd_(clear_display)(); |
324 | rb->lcd_update(); | 358 | lcd_(update)(); |
325 | 359 | ||
326 | draw_slider(0, 100, &rc_bound); | 360 | draw_slider(0, 100, &rc_bound); |
327 | rc_bound.b = rc_bound.t - SLIDER_TMARGIN; | 361 | rc_bound.b = rc_bound.t - SLIDER_TMARGIN; |
328 | #ifdef HAVE_LCD_COLOR | ||
329 | rc_bound.t = SCREEN_MARGIN; | 362 | rc_bound.t = SCREEN_MARGIN; |
330 | #else | ||
331 | rc_bound.t = 0; | ||
332 | rc_bound.l = 0; | ||
333 | rc_bound.r = LCD_WIDTH; | ||
334 | #endif | ||
335 | 363 | ||
336 | DEBUGF("rc_bound: %d, %d, %d, %d\n", rc_bound.l, rc_bound.t, | 364 | DEBUGF("rc_bound: %d, %d, %d, %d\n", rc_bound.l, rc_bound.t, |
337 | rc_bound.r, rc_bound.b); | 365 | rc_bound.r, rc_bound.b); |
@@ -344,12 +372,6 @@ int get_start_time(uint32_t duration) | |||
344 | rc_vid.b = rc_bound.b - rc_bound.t; | 372 | rc_vid.b = rc_bound.b - rc_bound.t; |
345 | } | 373 | } |
346 | 374 | ||
347 | #if !defined (HAVE_LCD_COLOR) | ||
348 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | ||
349 | rc_bound.b &= ~7; /* Align bottom edge */ | ||
350 | #endif | ||
351 | #endif | ||
352 | |||
353 | /* Get aspect ratio of bounding rectangle and video in u16.16 */ | 375 | /* Get aspect ratio of bounding rectangle and video in u16.16 */ |
354 | aspect_bound = ((rc_bound.r - rc_bound.l) << 16) / | 376 | aspect_bound = ((rc_bound.r - rc_bound.l) << 16) / |
355 | (rc_bound.b - rc_bound.t); | 377 | (rc_bound.b - rc_bound.t); |
@@ -398,8 +420,8 @@ int get_start_time(uint32_t duration) | |||
398 | rc_vid.r, rc_vid.b); | 420 | rc_vid.r, rc_vid.b); |
399 | 421 | ||
400 | #ifndef HAVE_LCD_COLOR | 422 | #ifndef HAVE_LCD_COLOR |
401 | /* Set gray overlay to the bounding rectangle */ | 423 | /* Restore gray overlay dimensions */ |
402 | stream_set_gray_rect(&rc_bound); | 424 | stream_gray_show(true); |
403 | #endif | 425 | #endif |
404 | 426 | ||
405 | while(slider_state < state9) | 427 | while(slider_state < state9) |
@@ -487,10 +509,9 @@ int get_start_time(uint32_t duration) | |||
487 | } | 509 | } |
488 | 510 | ||
489 | #ifndef HAVE_LCD_COLOR | 511 | #ifndef HAVE_LCD_COLOR |
490 | /* Restore gray overlay dimensions */ | ||
491 | stream_gray_show(false); | 512 | stream_gray_show(false); |
492 | rc_bound.b = LCD_HEIGHT; | 513 | grey_clear_display(); |
493 | stream_set_gray_rect(&rc_bound); | 514 | grey_update(); |
494 | #endif | 515 | #endif |
495 | 516 | ||
496 | cancel_cpu_boost(); | 517 | cancel_cpu_boost(); |