summaryrefslogtreecommitdiff
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
parent9d633740a402d9b390120b30798661d325fad049 (diff)
downloadrockbox-442174635748c8a619f0dbb248c8c526290b43d1.tar.gz
rockbox-442174635748c8a619f0dbb248c8c526290b43d1.zip
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
-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 845ea18608..de070d830f 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -26,6 +26,7 @@
26#include "font.h" 26#include "font.h"
27#include "system.h" 27#include "system.h"
28#include "rbunicode.h" 28#include "rbunicode.h"
29#include "sound.h"
29#ifdef DEBUG 30#ifdef DEBUG
30#include "debug.h" 31#include "debug.h"
31#endif 32#endif
@@ -115,28 +116,35 @@ void skin_statusbar_changed(struct gui_wps *skin)
115} 116}
116 117
117static void draw_progressbar(struct gui_wps *gwps, 118static void draw_progressbar(struct gui_wps *gwps,
118 struct skin_viewport *wps_vp) 119 struct progressbar *pb)
119{ 120{
120 struct screen *display = gwps->display; 121 struct screen *display = gwps->display;
122 struct viewport *vp = pb->vp;
121 struct wps_state *state = gwps->state; 123 struct wps_state *state = gwps->state;
122 struct progressbar *pb = wps_vp->pb;
123 struct mp3entry *id3 = state->id3; 124 struct mp3entry *id3 = state->id3;
124 int y = pb->y, height = pb->height; 125 int y = pb->y, height = pb->height;
125 unsigned long length, elapsed; 126 unsigned long length, elapsed;
126 127
127 if (height < 0) 128 if (height < 0)
128 height = font_get(wps_vp->vp.font)->height; 129 height = font_get(vp->font)->height;
129 130
130 if (y < 0) 131 if (y < 0)
131 { 132 {
132 int line_height = font_get(wps_vp->vp.font)->height; 133 int line_height = font_get(vp->font)->height;
133 /* center the pb in the line, but only if the line is higher than the pb */ 134 /* center the pb in the line, but only if the line is higher than the pb */
134 int center = (line_height-height)/2; 135 int center = (line_height-height)/2;
135 /* if Y was not set calculate by font height,Y is -line_number-1 */ 136 /* if Y was not set calculate by font height,Y is -line_number-1 */
136 y = (-y -1)*line_height + (0 > center ? 0 : center); 137 y = (-y -1)*line_height + (0 > center ? 0 : center);
137 } 138 }
138 139
139 if (id3 && id3->length) 140 if (pb->type == WPS_TOKEN_VOLUMEBAR)
141 {
142 int minvol = sound_min(SOUND_VOLUME);
143 int maxvol = sound_max(SOUND_VOLUME);
144 length = maxvol-minvol;
145 elapsed = global_settings.volume-minvol;
146 }
147 else if (id3 && id3->length)
140 { 148 {
141 length = id3->length; 149 length = id3->length;
142 elapsed = id3->elapsed + state->ff_rewind_count; 150 elapsed = id3->elapsed + state->ff_rewind_count;
@@ -155,7 +163,7 @@ static void draw_progressbar(struct gui_wps *gwps,
155 gui_scrollbar_draw(display, pb->x, y, pb->width, height, 163 gui_scrollbar_draw(display, pb->x, y, pb->width, height,
156 length, 0, elapsed, HORIZONTAL); 164 length, 0, elapsed, HORIZONTAL);
157 165
158 if (id3 && id3->length) 166 if (pb->type == WPS_TOKEN_PROGRESSBAR && id3 && id3->length)
159 { 167 {
160#ifdef AB_REPEAT_ENABLE 168#ifdef AB_REPEAT_ENABLE
161 if (ab_repeat_mode_enabled()) 169 if (ab_repeat_mode_enabled())
@@ -1248,9 +1256,15 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
1248 /* progressbar */ 1256 /* progressbar */
1249 if (vp_refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) 1257 if (vp_refresh_mode & WPS_REFRESH_PLAYER_PROGRESS)
1250 { 1258 {
1251 if (skin_viewport->pb) 1259 struct skin_token_list *bar = gwps->data->progressbars;
1260 while (bar)
1252 { 1261 {
1253 draw_progressbar(gwps, skin_viewport); 1262 struct progressbar *thisbar = (struct progressbar*)bar->token->value.data;
1263 if (thisbar->vp == &skin_viewport->vp)
1264 {
1265 draw_progressbar(gwps, thisbar);
1266 }
1267 bar = bar->next;
1254 } 1268 }
1255 } 1269 }
1256 /* Now display any images in this viewport */ 1270 /* 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 70ffe0b516..73702cbf09 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[] = {
322 { WPS_TOKEN_PROGRESSBAR, "pb", WPS_REFRESH_PLAYER_PROGRESS, 322 { WPS_TOKEN_PROGRESSBAR, "pb", WPS_REFRESH_PLAYER_PROGRESS,
323 parse_progressbar }, 323 parse_progressbar },
324 324
325 { WPS_TOKEN_VOLUME, "pv", WPS_REFRESH_DYNAMIC, NULL }, 325 { WPS_TOKEN_VOLUME, "pv", WPS_REFRESH_DYNAMIC,
326 parse_progressbar },
326 327
327 { WPS_TOKEN_TRACK_ELAPSED_PERCENT, "px", WPS_REFRESH_DYNAMIC, NULL }, 328 { WPS_TOKEN_TRACK_ELAPSED_PERCENT, "px", WPS_REFRESH_DYNAMIC, NULL },
328 { WPS_TOKEN_TRACK_TIME_ELAPSED, "pc", WPS_REFRESH_DYNAMIC, NULL }, 329 { WPS_TOKEN_TRACK_TIME_ELAPSED, "pc", WPS_REFRESH_DYNAMIC, NULL },
@@ -900,7 +901,6 @@ static int parse_viewport(const char *wps_bufptr,
900 /* %Vl|<label>|<rest of tags>| */ 901 /* %Vl|<label>|<rest of tags>| */
901 skin_vp->hidden_flags = 0; 902 skin_vp->hidden_flags = 0;
902 skin_vp->label = VP_NO_LABEL; 903 skin_vp->label = VP_NO_LABEL;
903 skin_vp->pb = NULL;
904 skin_vp->lines = NULL; 904 skin_vp->lines = NULL;
905 if (curr_line) 905 if (curr_line)
906 { 906 {
@@ -1118,7 +1118,7 @@ static int parse_timeout(const char *wps_bufptr,
1118 1118
1119 return skip; 1119 return skip;
1120} 1120}
1121 1121
1122static int parse_progressbar(const char *wps_bufptr, 1122static int parse_progressbar(const char *wps_bufptr,
1123 struct wps_token *token, 1123 struct wps_token *token,
1124 struct wps_data *wps_data) 1124 struct wps_data *wps_data)
@@ -1153,6 +1153,7 @@ static int parse_progressbar(const char *wps_bufptr,
1153 line_num++; 1153 line_num++;
1154 line = line->next; 1154 line = line->next;
1155 } 1155 }
1156 pb->vp = vp;
1156 pb->have_bitmap_pb = false; 1157 pb->have_bitmap_pb = false;
1157 pb->bm.data = NULL; /* no bitmap specified */ 1158 pb->bm.data = NULL; /* no bitmap specified */
1158 pb->follow_lang_direction = follow_lang_direction > 0; 1159 pb->follow_lang_direction = follow_lang_direction > 0;
@@ -1163,8 +1164,8 @@ static int parse_progressbar(const char *wps_bufptr,
1163 pb->width = vp->width; 1164 pb->width = vp->width;
1164 pb->height = SYSFONT_HEIGHT-2; 1165 pb->height = SYSFONT_HEIGHT-2;
1165 pb->y = -line_num - 1; /* Will be computed during the rendering */ 1166 pb->y = -line_num - 1; /* Will be computed during the rendering */
1166 1167 if (token->type == WPS_TOKEN_VOLUME)
1167 curr_vp->pb = pb; 1168 return 0; /* dont add it, let the regular token handling do the work */
1168 add_to_ll_chain(&wps_data->progressbars, item); 1169 add_to_ll_chain(&wps_data->progressbars, item);
1169 return 0; 1170 return 0;
1170 } 1171 }
@@ -1220,19 +1221,20 @@ static int parse_progressbar(const char *wps_bufptr,
1220 else 1221 else
1221 pb->y = -line_num - 1; /* Will be computed during the rendering */ 1222 pb->y = -line_num - 1; /* Will be computed during the rendering */
1222 1223
1223 curr_vp->pb = pb;
1224 add_to_ll_chain(&wps_data->progressbars, item); 1224 add_to_ll_chain(&wps_data->progressbars, item);
1225 1225 if (token->type == WPS_TOKEN_VOLUME)
1226 token->type = WPS_TOKEN_VOLUMEBAR;
1227 pb->type = token->type;
1226 /* Skip the rest of the line */ 1228 /* Skip the rest of the line */
1227 return skip_end_of_line(wps_bufptr)-1; 1229 return skip_end_of_line(wps_bufptr)-1;
1228#else 1230#else
1229 (void)token; 1231 (void)token;
1230 1232
1231 if (*(wps_bufptr-1) == 'f') 1233 if (token->type != WPS_TOKEN_VOLUME)
1232 wps_data->full_line_progressbar = true; 1234 {
1233 else 1235 wps_data->full_line_progressbar =
1234 wps_data->full_line_progressbar = false; 1236 token->type == WPS_TOKEN_PLAYER_PROGRESSBAR;
1235 1237 }
1236 return 0; 1238 return 0;
1237 1239
1238#endif 1240#endif
@@ -2205,7 +2207,6 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
2205 2207
2206 /* Initialise the first (default) viewport */ 2208 /* Initialise the first (default) viewport */
2207 curr_vp->label = VP_DEFAULT_LABEL; 2209 curr_vp->label = VP_DEFAULT_LABEL;
2208 curr_vp->pb = NULL;
2209 curr_vp->hidden_flags = 0; 2210 curr_vp->hidden_flags = 0;
2210 curr_vp->lines = NULL; 2211 curr_vp->lines = NULL;
2211 2212
diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h
index c953ccbffc..e727c255a1 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 {
202#endif 202#endif
203 /* Volume level */ 203 /* Volume level */
204 WPS_TOKEN_VOLUME, 204 WPS_TOKEN_VOLUME,
205 WPS_TOKEN_VOLUMEBAR,
205 /* hold */ 206 /* hold */
206 WPS_TOKEN_MAIN_HOLD, 207 WPS_TOKEN_MAIN_HOLD,
207#ifdef HAS_REMOTE_BUTTON_HOLD 208#ifdef HAS_REMOTE_BUTTON_HOLD
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index b0f5f36eb5..954928085f 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -91,6 +91,8 @@ struct gui_img {
91 91
92 92
93struct progressbar { 93struct progressbar {
94 enum wps_token_type type;
95 struct viewport *vp;
94 /* regular pb */ 96 /* regular pb */
95 short x; 97 short x;
96 /* >=0: explicitly set in the tag -> y-coord within the viewport 98 /* >=0: explicitly set in the tag -> y-coord within the viewport
@@ -202,7 +204,6 @@ struct skin_line {
202#define VP_INFO_LABEL '_' 204#define VP_INFO_LABEL '_'
203struct skin_viewport { 205struct skin_viewport {
204 struct viewport vp; /* The LCD viewport struct */ 206 struct viewport vp; /* The LCD viewport struct */
205 struct progressbar *pb;
206 struct skin_line *lines; 207 struct skin_line *lines;
207 char hidden_flags; 208 char hidden_flags;
208 char label; 209 char label;