summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-04-11 11:18:45 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-04-11 11:18:45 +0000
commit442174635748c8a619f0dbb248c8c526290b43d1 (patch)
treeb430088c13bc70a97b5fbf34ee3b25f4c146c213 /apps
parent9d633740a402d9b390120b30798661d325fad049 (diff)
downloadrockbox-442174635748c8a619f0dbb248c8c526290b43d1.zip
rockbox-442174635748c8a619f0dbb248c8c526290b43d1.tar.gz
rockbox-442174635748c8a619f0dbb248c8c526290b43d1.tar.bz2
rockbox-442174635748c8a619f0dbb248c8c526290b43d1.tar.xz
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
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/skin_engine/skin_display.c30
-rw-r--r--apps/gui/skin_engine/skin_parser.c27
-rw-r--r--apps/gui/skin_engine/skin_tokens.h1
-rw-r--r--apps/gui/skin_engine/wps_internals.h3
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 845ea18..de070d8 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 70ffe0b..73702cb 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|<label>|<rest of tags>| */
skin_vp->hidden_flags = 0;
skin_vp->label = VP_NO_LABEL;
- skin_vp->pb = NULL;
skin_vp->lines = NULL;
if (curr_line)
{
@@ -1118,7 +1118,7 @@ static int parse_timeout(const char *wps_bufptr,
return skip;
}
-
+
static int parse_progressbar(const char *wps_bufptr,
struct wps_token *token,
struct wps_data *wps_data)
@@ -1153,6 +1153,7 @@ static int parse_progressbar(const char *wps_bufptr,
line_num++;
line = line->next;
}
+ pb->vp = vp;
pb->have_bitmap_pb = false;
pb->bm.data = NULL; /* no bitmap specified */
pb->follow_lang_direction = follow_lang_direction > 0;
@@ -1163,8 +1164,8 @@ static int parse_progressbar(const char *wps_bufptr,
pb->width = vp->width;
pb->height = SYSFONT_HEIGHT-2;
pb->y = -line_num - 1; /* Will be computed during the rendering */
-
- curr_vp->pb = pb;
+ if (token->type == WPS_TOKEN_VOLUME)
+ return 0; /* dont add it, let the regular token handling do the work */
add_to_ll_chain(&wps_data->progressbars, item);
return 0;
}
@@ -1220,19 +1221,20 @@ static int parse_progressbar(const char *wps_bufptr,
else
pb->y = -line_num - 1; /* Will be computed during the rendering */
- curr_vp->pb = pb;
add_to_ll_chain(&wps_data->progressbars, item);
-
+ if (token->type == WPS_TOKEN_VOLUME)
+ token->type = WPS_TOKEN_VOLUMEBAR;
+ pb->type = token->type;
/* Skip the rest of the line */
return skip_end_of_line(wps_bufptr)-1;
#else
(void)token;
- if (*(wps_bufptr-1) == 'f')
- wps_data->full_line_progressbar = true;
- else
- wps_data->full_line_progressbar = false;
-
+ if (token->type != WPS_TOKEN_VOLUME)
+ {
+ wps_data->full_line_progressbar =
+ token->type == WPS_TOKEN_PLAYER_PROGRESSBAR;
+ }
return 0;
#endif
@@ -2205,7 +2207,6 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
/* Initialise the first (default) viewport */
curr_vp->label = VP_DEFAULT_LABEL;
- curr_vp->pb = NULL;
curr_vp->hidden_flags = 0;
curr_vp->lines = NULL;
diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h
index c953ccb..e727c25 100644
--- a/apps/gui/skin_engine/skin_tokens.h
+++ b/apps/gui/skin_engine/skin_tokens.h
@@ -202,6 +202,7 @@ enum wps_token_type {
#endif
/* Volume level */
WPS_TOKEN_VOLUME,
+ WPS_TOKEN_VOLUMEBAR,
/* hold */
WPS_TOKEN_MAIN_HOLD,
#ifdef HAS_REMOTE_BUTTON_HOLD
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index b0f5f36..9549280 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -91,6 +91,8 @@ struct gui_img {
struct progressbar {
+ enum wps_token_type type;
+ struct viewport *vp;
/* regular pb */
short x;
/* >=0: explicitly set in the tag -> y-coord within the viewport
@@ -202,7 +204,6 @@ struct skin_line {
#define VP_INFO_LABEL '_'
struct skin_viewport {
struct viewport vp; /* The LCD viewport struct */
- struct progressbar *pb;
struct skin_line *lines;
char hidden_flags;
char label;