From e6b08e124b65017202bc776b15e3f46a54033cfd Mon Sep 17 00:00:00 2001 From: jdgordon Date: Sun, 11 Apr 2010 11:18:45 +0000 Subject: [PATCH] Rework how progressbars are managed so you can have as many bars in a viewport as you want (!). Change %pv (volume) to be able to be drawn in the same style as %pb (using a line or a bmp). %pv - no change, %pv|bmp|x|y|width|height| exactly like %pb DO NOT use %?pv|....| because it will draw when you dont want it to! git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25584 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_display.c | 30 ++++++++++++++++++++++-------- apps/gui/skin_engine/skin_parser.c | 27 ++++++++++++++------------- apps/gui/skin_engine/skin_tokens.h | 1 + apps/gui/skin_engine/wps_internals.h | 3 ++- 4 files changed, 39 insertions(+), 22 deletions(-) diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 845ea1860..de070d830 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -26,6 +26,7 @@ #include "font.h" #include "system.h" #include "rbunicode.h" +#include "sound.h" #ifdef DEBUG #include "debug.h" #endif @@ -115,28 +116,35 @@ void skin_statusbar_changed(struct gui_wps *skin) } static void draw_progressbar(struct gui_wps *gwps, - struct skin_viewport *wps_vp) + struct progressbar *pb) { struct screen *display = gwps->display; + struct viewport *vp = pb->vp; struct wps_state *state = gwps->state; - struct progressbar *pb = wps_vp->pb; struct mp3entry *id3 = state->id3; int y = pb->y, height = pb->height; unsigned long length, elapsed; if (height < 0) - height = font_get(wps_vp->vp.font)->height; + height = font_get(vp->font)->height; if (y < 0) { - int line_height = font_get(wps_vp->vp.font)->height; + int line_height = font_get(vp->font)->height; /* center the pb in the line, but only if the line is higher than the pb */ int center = (line_height-height)/2; /* if Y was not set calculate by font height,Y is -line_number-1 */ y = (-y -1)*line_height + (0 > center ? 0 : center); } - if (id3 && id3->length) + if (pb->type == WPS_TOKEN_VOLUMEBAR) + { + int minvol = sound_min(SOUND_VOLUME); + int maxvol = sound_max(SOUND_VOLUME); + length = maxvol-minvol; + elapsed = global_settings.volume-minvol; + } + else if (id3 && id3->length) { length = id3->length; elapsed = id3->elapsed + state->ff_rewind_count; @@ -155,7 +163,7 @@ static void draw_progressbar(struct gui_wps *gwps, gui_scrollbar_draw(display, pb->x, y, pb->width, height, length, 0, elapsed, HORIZONTAL); - if (id3 && id3->length) + if (pb->type == WPS_TOKEN_PROGRESSBAR && id3 && id3->length) { #ifdef AB_REPEAT_ENABLE if (ab_repeat_mode_enabled()) @@ -1248,9 +1256,15 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) /* progressbar */ if (vp_refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) { - if (skin_viewport->pb) + struct skin_token_list *bar = gwps->data->progressbars; + while (bar) { - draw_progressbar(gwps, skin_viewport); + struct progressbar *thisbar = (struct progressbar*)bar->token->value.data; + if (thisbar->vp == &skin_viewport->vp) + { + draw_progressbar(gwps, thisbar); + } + bar = bar->next; } } /* Now display any images in this viewport */ diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 70ffe0b51..73702cbf0 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -322,7 +322,8 @@ static const struct wps_tag all_tags[] = { { WPS_TOKEN_PROGRESSBAR, "pb", WPS_REFRESH_PLAYER_PROGRESS, parse_progressbar }, - { WPS_TOKEN_VOLUME, "pv", WPS_REFRESH_DYNAMIC, NULL }, + { WPS_TOKEN_VOLUME, "pv", WPS_REFRESH_DYNAMIC, + parse_progressbar }, { WPS_TOKEN_TRACK_ELAPSED_PERCENT, "px", WPS_REFRESH_DYNAMIC, NULL }, { WPS_TOKEN_TRACK_TIME_ELAPSED, "pc", WPS_REFRESH_DYNAMIC, NULL }, @@ -900,7 +901,6 @@ static int parse_viewport(const char *wps_bufptr, /* %Vl|