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/gwps-common.c | |
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/gwps-common.c')
-rw-r--r-- | apps/gui/gwps-common.c | 133 |
1 files changed, 79 insertions, 54 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 |