diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2008-06-23 06:04:17 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2008-06-23 06:04:17 +0000 |
commit | 5a169bb71707dae31a886e1b932341b70eacf2df (patch) | |
tree | e6823f6addf964c292383182e1cbb077328c770d /apps/gui | |
parent | 66530722928b5e3c9870feb121c261e138807492 (diff) | |
download | rockbox-5a169bb71707dae31a886e1b932341b70eacf2df.tar.gz rockbox-5a169bb71707dae31a886e1b932341b70eacf2df.zip |
commit FS#9027 - conditional viewports
** BREAKS CURRENT WPS's **
* %P has been removed, merged with the new %pb
* %pb is now %pb or %pb|bitmap|x|y|width|height| (any of those params can be - to use sane defaults... check wiki/task for more explaination)
* New %Vl and %Vd tags which are used to setup and display conditionaly displayed viewports (%Vl|<id>|<usual %V params>| to set up, then %Vd<id> to enable the viewport
* bumps the max allowed viewport count to 24
* you can setup 3 different progressbars in a WPS... max of one per viewport though
http://www.rockbox.org/tracker/task/9027?getfile=16785 is a simple perl script to convert old %P/%pb to the new %pb syntax
I'll commit changes to the cabbie wps soon which shows how to use %Vl/%Vd properly...
Reminder: %m will be removed soonish also so when fixing your WPS's remember to use conditional viewports to replace %m
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17759 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/gwps-common.c | 133 | ||||
-rw-r--r-- | apps/gui/gwps.h | 31 | ||||
-rw-r--r-- | apps/gui/wps_debug.c | 4 | ||||
-rw-r--r-- | apps/gui/wps_parser.c | 178 |
4 files changed, 231 insertions, 115 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 634d199461..6e159b88b4 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -506,53 +506,33 @@ void display_keylock_text(bool locked) | |||
506 | 506 | ||
507 | #ifdef HAVE_LCD_BITMAP | 507 | #ifdef HAVE_LCD_BITMAP |
508 | 508 | ||
509 | static void draw_progressbar(struct gui_wps *gwps, int line) | 509 | static void draw_progressbar(struct gui_wps *gwps, |
510 | struct progressbar *pb) | ||
510 | { | 511 | { |
511 | struct wps_data *data = gwps->data; | ||
512 | struct screen *display = gwps->display; | 512 | struct screen *display = gwps->display; |
513 | struct wps_state *state = gwps->state; | 513 | struct wps_state *state = gwps->state; |
514 | int h = font_get(display->getfont())->height; | 514 | if (pb->have_bitmap_pb) |
515 | 515 | gui_bitmap_scrollbar_draw(display, pb->bm, | |
516 | int sb_y; | 516 | pb->x, pb->y, pb->width, pb->bm.height, |
517 | if (data->progress_top < 0) | ||
518 | sb_y = line*h + display->getymargin() + | ||
519 | ((h > data->progress_height + 1) | ||
520 | ? (h - data->progress_height) / 2 : 1); | ||
521 | else | ||
522 | sb_y = data->progress_top; | ||
523 | |||
524 | if (!data->progress_end) | ||
525 | data->progress_end=display->getwidth(); | ||
526 | |||
527 | if (gwps->data->progressbar.have_bitmap_pb) | ||
528 | gui_bitmap_scrollbar_draw(display, data->progressbar.bm, | ||
529 | data->progress_start, sb_y, | ||
530 | data->progress_end-data->progress_start, | ||
531 | data->progressbar.bm.height, | ||
532 | state->id3->length ? state->id3->length : 1, 0, | 517 | state->id3->length ? state->id3->length : 1, 0, |
533 | state->id3->length ? state->id3->elapsed | 518 | state->id3->length ? state->id3->elapsed |
534 | + state->ff_rewind_count : 0, | 519 | + state->ff_rewind_count : 0, |
535 | HORIZONTAL); | 520 | HORIZONTAL); |
536 | else | 521 | else |
537 | gui_scrollbar_draw(display, data->progress_start, sb_y, | 522 | gui_scrollbar_draw(display, pb->x, pb->y, pb->width, pb->height, |
538 | data->progress_end-data->progress_start, | ||
539 | data->progress_height, | ||
540 | state->id3->length ? state->id3->length : 1, 0, | 523 | state->id3->length ? state->id3->length : 1, 0, |
541 | state->id3->length ? state->id3->elapsed | 524 | state->id3->length ? state->id3->elapsed |
542 | + state->ff_rewind_count : 0, | 525 | + state->ff_rewind_count : 0, |
543 | HORIZONTAL); | 526 | HORIZONTAL); |
544 | |||
545 | #ifdef AB_REPEAT_ENABLE | 527 | #ifdef AB_REPEAT_ENABLE |
546 | if ( ab_repeat_mode_enabled() && state->id3->length != 0 ) | 528 | if ( ab_repeat_mode_enabled() && state->id3->length != 0 ) |
547 | ab_draw_markers(display, state->id3->length, | 529 | ab_draw_markers(display, state->id3->length, |
548 | data->progress_start, data->progress_end, sb_y, | 530 | pb->x, pb->x + pb->width, pb->y, pb->height); |
549 | data->progress_height); | ||
550 | #endif | 531 | #endif |
551 | 532 | ||
552 | if ( cuesheet_is_enabled() && state->id3->cuesheet_type ) | 533 | if ( cuesheet_is_enabled() && state->id3->cuesheet_type ) |
553 | cue_draw_markers(display, state->id3->length, | 534 | cue_draw_markers(display, state->id3->length, |
554 | data->progress_start, data->progress_end, | 535 | pb->x, pb->x + pb->width, pb->y+1, pb->height-2); |
555 | sb_y+1, data->progress_height-2); | ||
556 | } | 536 | } |
557 | 537 | ||
558 | /* clears the area where the image was shown */ | 538 | /* clears the area where the image was shown */ |
@@ -1621,7 +1601,24 @@ static bool get_line(struct gui_wps *gwps, | |||
1621 | *buf++ = 0; | 1601 | *buf++ = 0; |
1622 | cur_align_start = buf; | 1602 | cur_align_start = buf; |
1623 | break; | 1603 | break; |
1624 | 1604 | case WPS_VIEWPORT_ENABLE: | |
1605 | { | ||
1606 | char label = data->tokens[i].value.i; | ||
1607 | int j; | ||
1608 | char temp = VP_DRAW_HIDEABLE; | ||
1609 | for(j=0;j<data->num_viewports;j++) | ||
1610 | { | ||
1611 | temp = VP_DRAW_HIDEABLE; | ||
1612 | if ((data->viewports[j].hidden_flags&VP_DRAW_HIDEABLE) && | ||
1613 | (data->viewports[j].label == label)) | ||
1614 | { | ||
1615 | if (data->viewports[j].hidden_flags&VP_DRAW_WASHIDDEN) | ||
1616 | temp |= VP_DRAW_WASHIDDEN; | ||
1617 | data->viewports[j].hidden_flags = temp; | ||
1618 | } | ||
1619 | } | ||
1620 | } | ||
1621 | break; | ||
1625 | default: | 1622 | default: |
1626 | { | 1623 | { |
1627 | /* get the value of the tag and copy it to the buffer */ | 1624 | /* get the value of the tag and copy it to the buffer */ |
@@ -1945,6 +1942,7 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
1945 | int v, line, i, subline_idx; | 1942 | int v, line, i, subline_idx; |
1946 | unsigned char flags; | 1943 | unsigned char flags; |
1947 | char linebuf[MAX_PATH]; | 1944 | char linebuf[MAX_PATH]; |
1945 | unsigned char vp_refresh_mode; | ||
1948 | 1946 | ||
1949 | struct align_pos align; | 1947 | struct align_pos align; |
1950 | align.left = NULL; | 1948 | align.left = NULL; |
@@ -1994,14 +1992,21 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
1994 | 1992 | ||
1995 | state->ff_rewind_count = ffwd_offset; | 1993 | state->ff_rewind_count = ffwd_offset; |
1996 | 1994 | ||
1995 | /* disable any viewports which are conditionally displayed */ | ||
1997 | for (v = 0; v < data->num_viewports; v++) | 1996 | for (v = 0; v < data->num_viewports; v++) |
1998 | { | 1997 | { |
1999 | display->set_viewport(&data->viewports[v].vp); | 1998 | if (data->viewports[v].hidden_flags&VP_DRAW_HIDEABLE) |
2000 | |||
2001 | if (refresh_mode == WPS_REFRESH_ALL) | ||
2002 | { | 1999 | { |
2003 | display->clear_viewport(); | 2000 | if (data->viewports[v].hidden_flags&VP_DRAW_HIDDEN) |
2001 | data->viewports[v].hidden_flags |= VP_DRAW_WASHIDDEN; | ||
2002 | else | ||
2003 | data->viewports[v].hidden_flags |= VP_DRAW_HIDDEN; | ||
2004 | } | 2004 | } |
2005 | } | ||
2006 | for (v = 0; v < data->num_viewports; v++) | ||
2007 | { | ||
2008 | display->set_viewport(&data->viewports[v].vp); | ||
2009 | vp_refresh_mode = refresh_mode; | ||
2005 | 2010 | ||
2006 | #ifdef HAVE_LCD_BITMAP | 2011 | #ifdef HAVE_LCD_BITMAP |
2007 | /* Set images to not to be displayed */ | 2012 | /* Set images to not to be displayed */ |
@@ -2010,7 +2015,26 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
2010 | data->img[i].display = -1; | 2015 | data->img[i].display = -1; |
2011 | } | 2016 | } |
2012 | #endif | 2017 | #endif |
2013 | 2018 | /* dont redraw the viewport if its disabled */ | |
2019 | if ((data->viewports[v].hidden_flags&VP_DRAW_HIDDEN)) | ||
2020 | { | ||
2021 | if (!(data->viewports[v].hidden_flags&VP_DRAW_WASHIDDEN)) | ||
2022 | display->scroll_stop(&data->viewports[v].vp); | ||
2023 | data->viewports[v].hidden_flags |= VP_DRAW_WASHIDDEN; | ||
2024 | continue; | ||
2025 | } | ||
2026 | else if (((data->viewports[v].hidden_flags& | ||
2027 | (VP_DRAW_WASHIDDEN|VP_DRAW_HIDEABLE)) | ||
2028 | == (VP_DRAW_WASHIDDEN|VP_DRAW_HIDEABLE))) | ||
2029 | { | ||
2030 | vp_refresh_mode = WPS_REFRESH_ALL; | ||
2031 | data->viewports[v].hidden_flags = VP_DRAW_HIDEABLE; | ||
2032 | } | ||
2033 | if (vp_refresh_mode == WPS_REFRESH_ALL) | ||
2034 | { | ||
2035 | display->clear_viewport(); | ||
2036 | } | ||
2037 | |||
2014 | for (line = data->viewports[v].first_line; | 2038 | for (line = data->viewports[v].first_line; |
2015 | line <= data->viewports[v].last_line; line++) | 2039 | line <= data->viewports[v].last_line; line++) |
2016 | { | 2040 | { |
@@ -2024,30 +2048,21 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
2024 | data->lines[line].curr_subline); | 2048 | data->lines[line].curr_subline); |
2025 | flags = data->sublines[subline_idx].line_type; | 2049 | flags = data->sublines[subline_idx].line_type; |
2026 | 2050 | ||
2027 | if (refresh_mode == WPS_REFRESH_ALL || (flags & refresh_mode) | 2051 | if (vp_refresh_mode == WPS_REFRESH_ALL || (flags & vp_refresh_mode) |
2028 | || new_subline_refresh) | 2052 | || new_subline_refresh) |
2029 | { | 2053 | { |
2030 | /* get_line tells us if we need to update the line */ | 2054 | /* get_line tells us if we need to update the line */ |
2031 | update_line = get_line(gwps, line, data->lines[line].curr_subline, | 2055 | update_line = get_line(gwps, line, data->lines[line].curr_subline, |
2032 | &align, linebuf, sizeof(linebuf)); | 2056 | &align, linebuf, sizeof(linebuf)); |
2033 | } | 2057 | } |
2034 | |||
2035 | #ifdef HAVE_LCD_BITMAP | 2058 | #ifdef HAVE_LCD_BITMAP |
2036 | /* progressbar */ | ||
2037 | if (flags & refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) | ||
2038 | { | ||
2039 | /* the progressbar should be alone on its line */ | ||
2040 | update_line = false; | ||
2041 | draw_progressbar(gwps, line - data->viewports[v].first_line); | ||
2042 | } | ||
2043 | |||
2044 | /* peakmeter */ | 2059 | /* peakmeter */ |
2045 | if (flags & refresh_mode & WPS_REFRESH_PEAK_METER) | 2060 | if (flags & vp_refresh_mode & WPS_REFRESH_PEAK_METER) |
2046 | { | 2061 | { |
2047 | /* the peakmeter should be alone on its line */ | 2062 | /* the peakmeter should be alone on its line */ |
2048 | update_line = false; | 2063 | update_line = false; |
2049 | 2064 | ||
2050 | int h = font_get(display->getfont())->height; | 2065 | int h = font_get(data->viewports[v].vp.font)->height; |
2051 | int peak_meter_y = display->getymargin() + (line - data->viewports[v].first_line)* h; | 2066 | int peak_meter_y = display->getymargin() + (line - data->viewports[v].first_line)* h; |
2052 | 2067 | ||
2053 | /* The user might decide to have the peak meter in the last | 2068 | /* The user might decide to have the peak meter in the last |
@@ -2066,7 +2081,7 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
2066 | #else /* HAVE_LCD_CHARCELL */ | 2081 | #else /* HAVE_LCD_CHARCELL */ |
2067 | 2082 | ||
2068 | /* progressbar */ | 2083 | /* progressbar */ |
2069 | if (flags & refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) | 2084 | if (flags & vp_refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) |
2070 | { | 2085 | { |
2071 | if (data->full_line_progressbar) | 2086 | if (data->full_line_progressbar) |
2072 | draw_player_fullbar(gwps, linebuf, sizeof(linebuf)); | 2087 | draw_player_fullbar(gwps, linebuf, sizeof(linebuf)); |
@@ -2075,22 +2090,32 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
2075 | } | 2090 | } |
2076 | #endif | 2091 | #endif |
2077 | 2092 | ||
2078 | if (update_line) | 2093 | if (update_line && |
2094 | /* conditionals clear the line which means if the %Vd is put into the default | ||
2095 | viewport there will be a blank line. | ||
2096 | To get around this we dont allow any actual drawing to happen in the | ||
2097 | deault vp if other vp's are defined */ | ||
2098 | ((data->num_viewports>1 && v!=0) || data->num_viewports == 1)) | ||
2079 | { | 2099 | { |
2080 | if (flags & WPS_REFRESH_SCROLL) | 2100 | if (flags & WPS_REFRESH_SCROLL) |
2081 | { | 2101 | { |
2082 | /* if the line is a scrolling one we don't want to update | 2102 | /* if the line is a scrolling one we don't want to update |
2083 | too often, so that it has the time to scroll */ | 2103 | too often, so that it has the time to scroll */ |
2084 | if ((refresh_mode & WPS_REFRESH_SCROLL) || new_subline_refresh) | 2104 | if ((vp_refresh_mode & WPS_REFRESH_SCROLL) || new_subline_refresh) |
2085 | write_line(display, &align, line - data->viewports[v].first_line, true); | 2105 | write_line(display, &align, line - data->viewports[v].first_line, true); |
2086 | } | 2106 | } |
2087 | else | 2107 | else |
2088 | write_line(display, &align, line - data->viewports[v].first_line, false); | 2108 | write_line(display, &align, line - data->viewports[v].first_line, false); |
2089 | } | 2109 | } |
2090 | |||
2091 | } | 2110 | } |
2092 | 2111 | ||
2093 | #ifdef HAVE_LCD_BITMAP | 2112 | #ifdef HAVE_LCD_BITMAP |
2113 | /* progressbar */ | ||
2114 | if (vp_refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) | ||
2115 | { | ||
2116 | if (data->viewports[v].pb) | ||
2117 | draw_progressbar(gwps, data->viewports[v].pb); | ||
2118 | } | ||
2094 | /* Now display any images in this viewport */ | 2119 | /* Now display any images in this viewport */ |
2095 | wps_display_images(gwps, &data->viewports[v].vp); | 2120 | wps_display_images(gwps, &data->viewports[v].vp); |
2096 | #endif | 2121 | #endif |
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index 494d12a084..25cfc08505 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h | |||
@@ -70,7 +70,13 @@ struct gui_img{ | |||
70 | bool always_display; /* not using the preload/display mechanism */ | 70 | bool always_display; /* not using the preload/display mechanism */ |
71 | }; | 71 | }; |
72 | 72 | ||
73 | struct prog_img{ /*progressbar image*/ | 73 | struct progressbar { |
74 | /* regular pb */ | ||
75 | short x; | ||
76 | short y; | ||
77 | short width; | ||
78 | short height; | ||
79 | /*progressbar image*/ | ||
74 | struct bitmap bm; | 80 | struct bitmap bm; |
75 | bool have_bitmap_pb; | 81 | bool have_bitmap_pb; |
76 | }; | 82 | }; |
@@ -85,6 +91,7 @@ struct align_pos { | |||
85 | #ifdef HAVE_LCD_BITMAP | 91 | #ifdef HAVE_LCD_BITMAP |
86 | 92 | ||
87 | #define MAX_IMAGES (26*2) /* a-z and A-Z */ | 93 | #define MAX_IMAGES (26*2) /* a-z and A-Z */ |
94 | #define MAX_PROGRESSBARS 3 | ||
88 | 95 | ||
89 | /* The image buffer is big enough to store one full-screen native bitmap, | 96 | /* The image buffer is big enough to store one full-screen native bitmap, |
90 | plus two full-screen mono bitmaps. */ | 97 | plus two full-screen mono bitmaps. */ |
@@ -92,7 +99,7 @@ struct align_pos { | |||
92 | #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \ | 99 | #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \ |
93 | + (2*LCD_HEIGHT*LCD_WIDTH/8)) | 100 | + (2*LCD_HEIGHT*LCD_WIDTH/8)) |
94 | 101 | ||
95 | #define WPS_MAX_VIEWPORTS 16 | 102 | #define WPS_MAX_VIEWPORTS 24 |
96 | #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2) | 103 | #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2) |
97 | #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3) | 104 | #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3) |
98 | #define WPS_MAX_TOKENS 1024 | 105 | #define WPS_MAX_TOKENS 1024 |
@@ -271,8 +278,11 @@ enum wps_token_type { | |||
271 | 278 | ||
272 | #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) | 279 | #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) |
273 | /* Virtual LED */ | 280 | /* Virtual LED */ |
274 | WPS_TOKEN_VLED_HDD | 281 | WPS_TOKEN_VLED_HDD, |
275 | #endif | 282 | #endif |
283 | |||
284 | /* Viewport display */ | ||
285 | WPS_VIEWPORT_ENABLE | ||
276 | }; | 286 | }; |
277 | 287 | ||
278 | struct wps_token { | 288 | struct wps_token { |
@@ -323,12 +333,17 @@ struct wps_line { | |||
323 | long subline_expire_time; | 333 | long subline_expire_time; |
324 | }; | 334 | }; |
325 | 335 | ||
336 | #define VP_DRAW_HIDEABLE 0x1 | ||
337 | #define VP_DRAW_HIDDEN 0x2 | ||
338 | #define VP_DRAW_WASHIDDEN 0x4 | ||
326 | struct wps_viewport { | 339 | struct wps_viewport { |
327 | struct viewport vp; /* The LCD viewport struct */ | 340 | struct viewport vp; /* The LCD viewport struct */ |
328 | 341 | struct progressbar *pb; | |
329 | /* Indexes of the first and last lines belonging to this viewport in the | 342 | /* Indexes of the first and last lines belonging to this viewport in the |
330 | lines[] array */ | 343 | lines[] array */ |
331 | int first_line, last_line; | 344 | int first_line, last_line; |
345 | char hidden_flags; | ||
346 | char label; | ||
332 | }; | 347 | }; |
333 | 348 | ||
334 | /* wps_data | 349 | /* wps_data |
@@ -338,17 +353,15 @@ struct wps_data | |||
338 | { | 353 | { |
339 | #ifdef HAVE_LCD_BITMAP | 354 | #ifdef HAVE_LCD_BITMAP |
340 | struct gui_img img[MAX_IMAGES]; | 355 | struct gui_img img[MAX_IMAGES]; |
341 | struct prog_img progressbar; | ||
342 | unsigned char img_buf[IMG_BUFSIZE]; | 356 | unsigned char img_buf[IMG_BUFSIZE]; |
343 | unsigned char* img_buf_ptr; | 357 | unsigned char* img_buf_ptr; |
344 | int img_buf_free; | 358 | int img_buf_free; |
345 | bool wps_sb_tag; | 359 | bool wps_sb_tag; |
346 | bool show_sb_on_wps; | 360 | bool show_sb_on_wps; |
347 | 361 | ||
348 | short progress_top; | 362 | struct progressbar progressbar[MAX_PROGRESSBARS]; |
349 | short progress_height; | 363 | short progressbar_count; |
350 | short progress_start; | 364 | |
351 | short progress_end; | ||
352 | bool peak_meter_enabled; | 365 | bool peak_meter_enabled; |
353 | 366 | ||
354 | #ifdef HAVE_ALBUMART | 367 | #ifdef HAVE_ALBUMART |
diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c index 9bff1d23ae..4fa12167f2 100644 --- a/apps/gui/wps_debug.c +++ b/apps/gui/wps_debug.c | |||
@@ -431,6 +431,10 @@ static char *get_token_desc(struct wps_token *token, struct wps_data *data, | |||
431 | snprintf(buf, bufsize, "pitch value"); | 431 | snprintf(buf, bufsize, "pitch value"); |
432 | break; | 432 | break; |
433 | #endif | 433 | #endif |
434 | case WPS_VIEWPORT_ENABLE: | ||
435 | snprintf(buf, bufsize, "enable VP:%d", | ||
436 | token->value.i); | ||
437 | break; | ||
434 | 438 | ||
435 | default: | 439 | default: |
436 | snprintf(buf, bufsize, "FIXME (code: %d)", | 440 | snprintf(buf, bufsize, "FIXME (code: %d)", |
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 53605e27cc..dc9abd98fb 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -80,13 +80,13 @@ static int line; | |||
80 | #ifdef HAVE_LCD_BITMAP | 80 | #ifdef HAVE_LCD_BITMAP |
81 | 81 | ||
82 | #if LCD_DEPTH > 1 | 82 | #if LCD_DEPTH > 1 |
83 | #define MAX_BITMAPS (MAX_IMAGES+2) /* WPS images + pbar bitmap + backdrop */ | 83 | #define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS+1) /* WPS images + pbar bitmap + backdrop */ |
84 | #else | 84 | #else |
85 | #define MAX_BITMAPS (MAX_IMAGES+1) /* WPS images + pbar bitmap */ | 85 | #define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS) /* WPS images + pbar bitmap */ |
86 | #endif | 86 | #endif |
87 | 87 | ||
88 | #define PROGRESSBAR_BMP MAX_IMAGES | 88 | #define PROGRESSBAR_BMP MAX_IMAGES |
89 | #define BACKDROP_BMP (MAX_IMAGES+1) | 89 | #define BACKDROP_BMP (MAX_BITMAPS-1) |
90 | 90 | ||
91 | /* pointers to the bitmap filenames in the WPS source */ | 91 | /* pointers to the bitmap filenames in the WPS source */ |
92 | static const char *bmp_names[MAX_BITMAPS]; | 92 | static const char *bmp_names[MAX_BITMAPS]; |
@@ -129,6 +129,8 @@ static int parse_dir_level(const char *wps_bufptr, | |||
129 | struct wps_token *token, struct wps_data *wps_data); | 129 | struct wps_token *token, struct wps_data *wps_data); |
130 | 130 | ||
131 | #ifdef HAVE_LCD_BITMAP | 131 | #ifdef HAVE_LCD_BITMAP |
132 | static int parse_viewport_display(const char *wps_bufptr, | ||
133 | struct wps_token *token, struct wps_data *wps_data); | ||
132 | static int parse_viewport(const char *wps_bufptr, | 134 | static int parse_viewport(const char *wps_bufptr, |
133 | struct wps_token *token, struct wps_data *wps_data); | 135 | struct wps_token *token, struct wps_data *wps_data); |
134 | static int parse_leftmargin(const char *wps_bufptr, | 136 | static int parse_leftmargin(const char *wps_bufptr, |
@@ -317,13 +319,14 @@ static const struct wps_tag all_tags[] = { | |||
317 | parse_image_display }, | 319 | parse_image_display }, |
318 | 320 | ||
319 | { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, | 321 | { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, |
320 | { WPS_TOKEN_IMAGE_PROGRESS_BAR, "P", 0, parse_image_special }, | ||
321 | #ifdef HAVE_ALBUMART | 322 | #ifdef HAVE_ALBUMART |
322 | { WPS_NO_TOKEN, "Cl", 0, parse_albumart_load }, | 323 | { WPS_NO_TOKEN, "Cl", 0, parse_albumart_load }, |
323 | { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC, | 324 | { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC, |
324 | parse_albumart_conditional }, | 325 | parse_albumart_conditional }, |
325 | #endif | 326 | #endif |
326 | 327 | ||
328 | { WPS_VIEWPORT_ENABLE, "Vd", WPS_REFRESH_DYNAMIC, | ||
329 | parse_viewport_display }, | ||
327 | { WPS_NO_TOKEN, "V", 0, parse_viewport }, | 330 | { WPS_NO_TOKEN, "V", 0, parse_viewport }, |
328 | 331 | ||
329 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) | 332 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) |
@@ -536,6 +539,22 @@ static int parse_image_load(const char *wps_bufptr, | |||
536 | return skip_end_of_line(wps_bufptr); | 539 | return skip_end_of_line(wps_bufptr); |
537 | } | 540 | } |
538 | 541 | ||
542 | static int parse_viewport_display(const char *wps_bufptr, | ||
543 | struct wps_token *token, | ||
544 | struct wps_data *wps_data) | ||
545 | { | ||
546 | (void)wps_data; | ||
547 | char letter = wps_bufptr[0]; | ||
548 | |||
549 | if (letter < 'a' || letter > 'z') | ||
550 | { | ||
551 | /* invalid viewport tag */ | ||
552 | return WPS_ERROR_INVALID_PARAM; | ||
553 | } | ||
554 | token->value.i = letter; | ||
555 | return 1; | ||
556 | } | ||
557 | |||
539 | static int parse_viewport(const char *wps_bufptr, | 558 | static int parse_viewport(const char *wps_bufptr, |
540 | struct wps_token *token, | 559 | struct wps_token *token, |
541 | struct wps_data *wps_data) | 560 | struct wps_data *wps_data) |
@@ -563,17 +582,35 @@ static int parse_viewport(const char *wps_bufptr, | |||
563 | } | 582 | } |
564 | #endif | 583 | #endif |
565 | 584 | ||
566 | if (*wps_bufptr != '|') | ||
567 | return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */ | ||
568 | |||
569 | ptr = wps_bufptr + 1; | ||
570 | /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ | ||
571 | |||
572 | if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS) | 585 | if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS) |
573 | return WPS_ERROR_INVALID_PARAM; | 586 | return WPS_ERROR_INVALID_PARAM; |
574 | 587 | ||
575 | wps_data->num_viewports++; | 588 | wps_data->num_viewports++; |
589 | /* check for the optional letter to signify its a hideable viewport */ | ||
590 | /* %Vl|<label>|<rest of tags>| */ | ||
591 | wps_data->viewports[wps_data->num_viewports].hidden_flags = 0; | ||
592 | |||
593 | if (*ptr == 'l') | ||
594 | { | ||
595 | if (*(ptr+1) == '|') | ||
596 | { | ||
597 | char label = *(ptr+2); | ||
598 | if (label >= 'a' && label < 'a' + WPS_MAX_VIEWPORTS) | ||
599 | { | ||
600 | wps_data->viewports[wps_data->num_viewports].hidden_flags = VP_DRAW_HIDEABLE; | ||
601 | wps_data->viewports[wps_data->num_viewports].label = label; | ||
602 | } | ||
603 | else | ||
604 | return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */ | ||
605 | ptr += 3; | ||
606 | } | ||
607 | } | ||
608 | if (*ptr != '|') | ||
609 | return WPS_ERROR_INVALID_PARAM; | ||
610 | |||
611 | ptr++; | ||
576 | vp = &wps_data->viewports[wps_data->num_viewports].vp; | 612 | vp = &wps_data->viewports[wps_data->num_viewports].vp; |
613 | /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ | ||
577 | 614 | ||
578 | /* Set the defaults for fields not user-specified */ | 615 | /* Set the defaults for fields not user-specified */ |
579 | vp->drawmode = DRMODE_SOLID; | 616 | vp->drawmode = DRMODE_SOLID; |
@@ -687,14 +724,8 @@ static int parse_image_special(const char *wps_bufptr, | |||
687 | 724 | ||
688 | if (pos > newline) | 725 | if (pos > newline) |
689 | return WPS_ERROR_INVALID_PARAM; | 726 | return WPS_ERROR_INVALID_PARAM; |
690 | |||
691 | if (token->type == WPS_TOKEN_IMAGE_PROGRESS_BAR) | ||
692 | { | ||
693 | /* format: %P|filename.bmp| */ | ||
694 | bmp_names[PROGRESSBAR_BMP] = wps_bufptr + 1; | ||
695 | } | ||
696 | #if LCD_DEPTH > 1 | 727 | #if LCD_DEPTH > 1 |
697 | else if (token->type == WPS_TOKEN_IMAGE_BACKDROP) | 728 | if (token->type == WPS_TOKEN_IMAGE_BACKDROP) |
698 | { | 729 | { |
699 | /* format: %X|filename.bmp| */ | 730 | /* format: %X|filename.bmp| */ |
700 | bmp_names[BACKDROP_BMP] = wps_bufptr + 1; | 731 | bmp_names[BACKDROP_BMP] = wps_bufptr + 1; |
@@ -762,40 +793,82 @@ static int parse_progressbar(const char *wps_bufptr, | |||
762 | struct wps_data *wps_data) | 793 | struct wps_data *wps_data) |
763 | { | 794 | { |
764 | (void)token; /* Kill warnings */ | 795 | (void)token; /* Kill warnings */ |
796 | /* %pb or %pb|filename|x|y|width|height| | ||
797 | using - for any of the params uses "sane" values */ | ||
765 | #ifdef HAVE_LCD_BITMAP | 798 | #ifdef HAVE_LCD_BITMAP |
799 | enum { | ||
800 | PB_FILENAME = 0, | ||
801 | PB_X, | ||
802 | PB_Y, | ||
803 | PB_WIDTH, | ||
804 | PB_HEIGHT | ||
805 | }; | ||
806 | const char *filename; | ||
807 | int x, y, height, width, set = 0; | ||
808 | const char *ptr = wps_bufptr; | ||
809 | struct progressbar *pb; | ||
810 | struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp; | ||
811 | int font_height = font_get(vp->font)->height; | ||
812 | int line_y_pos = font_height*(wps_data->num_lines - | ||
813 | wps_data->viewports[wps_data->num_viewports].first_line); | ||
814 | |||
815 | /** Remove this bit when the remove lcd margins patch goes in **/ | ||
816 | bool draw_sb = global_settings.statusbar; | ||
766 | 817 | ||
767 | short *vals[] = { | 818 | if (wps_data->wps_sb_tag) |
768 | &wps_data->progress_height, | 819 | draw_sb = wps_data->show_sb_on_wps; |
769 | &wps_data->progress_start, | ||
770 | &wps_data->progress_end, | ||
771 | &wps_data->progress_top }; | ||
772 | |||
773 | /* default values : */ | ||
774 | wps_data->progress_height = 6; | ||
775 | wps_data->progress_start = 0; | ||
776 | wps_data->progress_end = 0; | ||
777 | wps_data->progress_top = -1; | ||
778 | |||
779 | int i = 0; | ||
780 | char *newline = strchr(wps_bufptr, '\n'); | ||
781 | char *prev = strchr(wps_bufptr, '|'); | ||
782 | if (prev && prev < newline) { | ||
783 | char *next = strchr(prev+1, '|'); | ||
784 | while (i < 4 && next && next < newline) | ||
785 | { | ||
786 | *(vals[i++]) = atoi(++prev); | ||
787 | prev = strchr(prev, '|'); | ||
788 | next = strchr(++next, '|'); | ||
789 | } | ||
790 | 820 | ||
791 | if (wps_data->progress_height < 3) | 821 | if (wps_data->num_viewports == 0 && draw_sb) |
792 | wps_data->progress_height = 3; | 822 | line_y_pos += STATUSBAR_HEIGHT; |
793 | if (wps_data->progress_end < wps_data->progress_start + 3) | 823 | /** Remove the above bit when the remove lcd margins patch goes in **/ |
794 | wps_data->progress_end = 0; | 824 | |
825 | if (wps_data->progressbar_count +1 >= MAX_PROGRESSBARS) | ||
826 | return WPS_ERROR_INVALID_PARAM; | ||
827 | |||
828 | pb = &wps_data->progressbar[wps_data->progressbar_count]; | ||
829 | pb->have_bitmap_pb = false; | ||
830 | |||
831 | if (*wps_bufptr != '|') /* regular old style */ | ||
832 | { | ||
833 | pb->x = 0; | ||
834 | pb->width = vp->width; | ||
835 | pb->height = SYSFONT_HEIGHT-2; | ||
836 | pb->y = line_y_pos + (font_height-pb->height)/2; | ||
837 | |||
838 | wps_data->viewports[wps_data->num_viewports].pb = | ||
839 | &wps_data->progressbar[wps_data->progressbar_count]; | ||
840 | wps_data->progressbar_count++; | ||
841 | return 0; | ||
795 | } | 842 | } |
796 | 843 | ptr = wps_bufptr + 1; | |
797 | return newline - wps_bufptr; | 844 | |
798 | 845 | if (!(ptr = parse_list("sdddd", &set, '|', ptr, &filename, | |
846 | &x, &y, &width, &height))) | ||
847 | return WPS_ERROR_INVALID_PARAM; | ||
848 | if (LIST_VALUE_PARSED(set, PB_FILENAME)) /* filename */ | ||
849 | bmp_names[PROGRESSBAR_BMP+wps_data->progressbar_count] = filename; | ||
850 | if (LIST_VALUE_PARSED(set, PB_X)) /* x */ | ||
851 | pb->x = x; | ||
852 | else | ||
853 | pb->x = vp->x; | ||
854 | if (LIST_VALUE_PARSED(set, PB_WIDTH)) /* width */ | ||
855 | pb->width = width; | ||
856 | else | ||
857 | pb->width = vp->width - pb->x; | ||
858 | if (LIST_VALUE_PARSED(set, PB_HEIGHT)) /* height, default to font height */ | ||
859 | pb->height = height; | ||
860 | else | ||
861 | pb->height = font_height; | ||
862 | if (LIST_VALUE_PARSED(set, PB_Y)) /* y */ | ||
863 | pb->y = y; | ||
864 | else | ||
865 | pb->y = line_y_pos + (font_height-pb->height)/2; | ||
866 | wps_data->progressbar[wps_data->progressbar_count].have_bitmap_pb = false; | ||
867 | wps_data->viewports[wps_data->num_viewports].pb = | ||
868 | &wps_data->progressbar[wps_data->progressbar_count]; | ||
869 | wps_data->progressbar_count++; | ||
870 | /* Skip the rest of the line */ | ||
871 | return skip_end_of_line(wps_bufptr)-1; | ||
799 | #else | 872 | #else |
800 | 873 | ||
801 | if (*(wps_bufptr-1) == 'f') | 874 | if (*(wps_bufptr-1) == 'f') |
@@ -1359,7 +1432,6 @@ static void wps_images_clear(struct wps_data *data) | |||
1359 | data->img[i].always_display = false; | 1432 | data->img[i].always_display = false; |
1360 | data->img[i].num_subimages = 1; | 1433 | data->img[i].num_subimages = 1; |
1361 | } | 1434 | } |
1362 | data->progressbar.have_bitmap_pb = false; | ||
1363 | } | 1435 | } |
1364 | #endif | 1436 | #endif |
1365 | 1437 | ||
@@ -1373,6 +1445,8 @@ void wps_data_init(struct wps_data *wps_data) | |||
1373 | wps_data->img_buf_ptr = wps_data->img_buf; /* where in image buffer */ | 1445 | wps_data->img_buf_ptr = wps_data->img_buf; /* where in image buffer */ |
1374 | wps_data->img_buf_free = IMG_BUFSIZE; /* free space in image buffer */ | 1446 | wps_data->img_buf_free = IMG_BUFSIZE; /* free space in image buffer */ |
1375 | wps_data->peak_meter_enabled = false; | 1447 | wps_data->peak_meter_enabled = false; |
1448 | /* progress bars */ | ||
1449 | wps_data->progressbar_count = 0; | ||
1376 | #else /* HAVE_LCD_CHARCELLS */ | 1450 | #else /* HAVE_LCD_CHARCELLS */ |
1377 | int i; | 1451 | int i; |
1378 | for (i = 0; i < 8; i++) | 1452 | for (i = 0; i < 8; i++) |
@@ -1414,10 +1488,10 @@ static bool load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) | |||
1414 | get_image_filename(bmp_names[n], bmpdir, | 1488 | get_image_filename(bmp_names[n], bmpdir, |
1415 | img_path, sizeof(img_path)); | 1489 | img_path, sizeof(img_path)); |
1416 | 1490 | ||
1417 | if (n == PROGRESSBAR_BMP) { | 1491 | if (n >= PROGRESSBAR_BMP ) { |
1418 | /* progressbar bitmap */ | 1492 | /* progressbar bitmap */ |
1419 | bitmap = &wps_data->progressbar.bm; | 1493 | bitmap = &wps_data->progressbar[n-PROGRESSBAR_BMP].bm; |
1420 | loaded = &wps_data->progressbar.have_bitmap_pb; | 1494 | loaded = &wps_data->progressbar[n-PROGRESSBAR_BMP].have_bitmap_pb; |
1421 | } else { | 1495 | } else { |
1422 | /* regular bitmap */ | 1496 | /* regular bitmap */ |
1423 | bitmap = &wps_data->img[n].bm; | 1497 | bitmap = &wps_data->img[n].bm; |