diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-10-12 12:17:39 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-10-12 12:17:39 +0000 |
commit | 3eb5826c8a289d2ff2af246388e17d4aa6483da4 (patch) | |
tree | 343690ac844a3d96cec667e1c84793076affa067 | |
parent | 69e379a47b6c7830fc17e912eecde6eb5100037f (diff) | |
download | rockbox-3eb5826c8a289d2ff2af246388e17d4aa6483da4.tar.gz rockbox-3eb5826c8a289d2ff2af246388e17d4aa6483da4.zip |
improvement for bar tag with slider.
-fix bug the slider is drawn outside of the bounds (FS#11658).
-offset the slider position so that the center of the slider indicates current position.
-add nobar option. if this option is set, the bar isn't drawn at all.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28248 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 58 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 3 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 1 | ||||
-rw-r--r-- | manual/appendix/wps_tags.tex | 8 |
4 files changed, 48 insertions, 22 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 24e976d393..1418d91b57 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -131,7 +131,7 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
131 | struct viewport *vp = pb->vp; | 131 | struct viewport *vp = pb->vp; |
132 | struct wps_state *state = skin_get_global_state(); | 132 | struct wps_state *state = skin_get_global_state(); |
133 | struct mp3entry *id3 = state->id3; | 133 | struct mp3entry *id3 = state->id3; |
134 | int y = pb->y, height = pb->height; | 134 | int x = pb->x, y = pb->y, width = pb->width, height = pb->height; |
135 | unsigned long length, end; | 135 | unsigned long length, end; |
136 | int flags = HORIZONTAL; | 136 | int flags = HORIZONTAL; |
137 | 137 | ||
@@ -194,29 +194,48 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
194 | flags |= INNER_NOFILL; | 194 | flags |= INNER_NOFILL; |
195 | } | 195 | } |
196 | 196 | ||
197 | if (pb->have_bitmap_pb) | 197 | if (pb->slider) |
198 | gui_bitmap_scrollbar_draw(display, &pb->bm, | 198 | { |
199 | pb->x, y, pb->width, height, | 199 | struct gui_img *img = pb->slider; |
200 | length, 0, end, flags); | 200 | /* clear the slider */ |
201 | else | 201 | screen_clear_area(display, x, y, width, height); |
202 | gui_scrollbar_draw(display, pb->x, y, pb->width, height, | 202 | |
203 | length, 0, end, flags); | 203 | /* shrink the bar so the slider is inside bounds */ |
204 | if (flags&HORIZONTAL) | ||
205 | { | ||
206 | width -= img->bm.width; | ||
207 | x += img->bm.width / 2; | ||
208 | } | ||
209 | else | ||
210 | { | ||
211 | height -= img->bm.height; | ||
212 | y += img->bm.height / 2; | ||
213 | } | ||
214 | } | ||
215 | if (!pb->nobar) | ||
216 | { | ||
217 | if (pb->have_bitmap_pb) | ||
218 | gui_bitmap_scrollbar_draw(display, &pb->bm, | ||
219 | x, y, width, height, | ||
220 | length, 0, end, flags); | ||
221 | else | ||
222 | gui_scrollbar_draw(display, x, y, width, height, | ||
223 | length, 0, end, flags); | ||
224 | } | ||
204 | 225 | ||
205 | if (pb->slider) | 226 | if (pb->slider) |
206 | { | 227 | { |
207 | int xoff = 0, yoff = 0; | 228 | int xoff = 0, yoff = 0; |
208 | int w = pb->width, h = height; | 229 | int w = width, h = height; |
209 | struct gui_img *img = pb->slider; | 230 | struct gui_img *img = pb->slider; |
210 | 231 | ||
211 | if (flags&HORIZONTAL) | 232 | if (flags&HORIZONTAL) |
212 | { | 233 | { |
213 | w = img->bm.width; | 234 | w = img->bm.width; |
214 | xoff = pb->width * end / length; | 235 | xoff = width * end / length; |
215 | if (flags&INVERTFILL) | 236 | if (flags&INVERTFILL) |
216 | xoff = pb->width - xoff; | 237 | xoff = width - xoff; |
217 | #if 0 /* maybe add this in later, make the slider bmp overlap abit */ | ||
218 | xoff -= w / 2; | 238 | xoff -= w / 2; |
219 | #endif | ||
220 | } | 239 | } |
221 | else | 240 | else |
222 | { | 241 | { |
@@ -224,23 +243,21 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
224 | yoff = height * end / length; | 243 | yoff = height * end / length; |
225 | if (flags&INVERTFILL) | 244 | if (flags&INVERTFILL) |
226 | yoff = height - yoff; | 245 | yoff = height - yoff; |
227 | #if 0 /* maybe add this in later, make the slider bmp overlap abit */ | ||
228 | yoff -= h / 2; | 246 | yoff -= h / 2; |
229 | #endif | ||
230 | } | 247 | } |
231 | #if LCD_DEPTH > 1 | 248 | #if LCD_DEPTH > 1 |
232 | if(img->bm.format == FORMAT_MONO) { | 249 | if(img->bm.format == FORMAT_MONO) { |
233 | #endif | 250 | #endif |
234 | display->mono_bitmap_part(img->bm.data, | 251 | display->mono_bitmap_part(img->bm.data, |
235 | 0, 0, img->bm.width, | 252 | 0, 0, img->bm.width, |
236 | pb->x + xoff, y + yoff, w, h); | 253 | x + xoff, y + yoff, w, h); |
237 | #if LCD_DEPTH > 1 | 254 | #if LCD_DEPTH > 1 |
238 | } else { | 255 | } else { |
239 | display->transparent_bitmap_part((fb_data *)img->bm.data, | 256 | display->transparent_bitmap_part((fb_data *)img->bm.data, |
240 | 0, 0, | 257 | 0, 0, |
241 | STRIDE(display->screen_type, | 258 | STRIDE(display->screen_type, |
242 | img->bm.width, img->bm.height), | 259 | img->bm.width, img->bm.height), |
243 | pb->x + xoff, y + yoff, w, h); | 260 | x + xoff, y + yoff, w, h); |
244 | } | 261 | } |
245 | #endif | 262 | #endif |
246 | } | 263 | } |
@@ -251,18 +268,17 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
251 | { | 268 | { |
252 | #ifdef AB_REPEAT_ENABLE | 269 | #ifdef AB_REPEAT_ENABLE |
253 | if (ab_repeat_mode_enabled()) | 270 | if (ab_repeat_mode_enabled()) |
254 | ab_draw_markers(display, id3->length, | 271 | ab_draw_markers(display, id3->length, x, y, width, height); |
255 | pb->x, y, pb->width, height); | ||
256 | #endif | 272 | #endif |
257 | 273 | ||
258 | if (id3->cuesheet) | 274 | if (id3->cuesheet) |
259 | cue_draw_markers(display, id3->cuesheet, id3->length, | 275 | cue_draw_markers(display, id3->cuesheet, id3->length, |
260 | pb->x, y+1, pb->width, height-2); | 276 | x, y+1, width, height-2); |
261 | } | 277 | } |
262 | #if 0 /* disable for now CONFIG_TUNER */ | 278 | #if 0 /* disable for now CONFIG_TUNER */ |
263 | else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) | 279 | else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) |
264 | { | 280 | { |
265 | presets_draw_markers(display, pb->x, y, pb->width, height); | 281 | presets_draw_markers(display, x, y, width, height); |
266 | } | 282 | } |
267 | #endif | 283 | #endif |
268 | } | 284 | } |
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 5c169c81de..f5923747ab 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -600,6 +600,7 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
600 | pb->bm.data = NULL; /* no bitmap specified */ | 600 | pb->bm.data = NULL; /* no bitmap specified */ |
601 | pb->follow_lang_direction = follow_lang_direction > 0; | 601 | pb->follow_lang_direction = follow_lang_direction > 0; |
602 | pb->nofill = false; | 602 | pb->nofill = false; |
603 | pb->nobar = false; | ||
603 | pb->slider = NULL; | 604 | pb->slider = NULL; |
604 | pb->invert_fill_direction = false; | 605 | pb->invert_fill_direction = false; |
605 | pb->horizontal = true; | 606 | pb->horizontal = true; |
@@ -676,6 +677,8 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
676 | pb->invert_fill_direction = true; | 677 | pb->invert_fill_direction = true; |
677 | else if (!strcmp(param->data.text, "nofill")) | 678 | else if (!strcmp(param->data.text, "nofill")) |
678 | pb->nofill = true; | 679 | pb->nofill = true; |
680 | else if (!strcmp(param->data.text, "nobar")) | ||
681 | pb->nobar = true; | ||
679 | else if (!strcmp(param->data.text, "slider")) | 682 | else if (!strcmp(param->data.text, "slider")) |
680 | { | 683 | { |
681 | if (curr_param+1 < element->params_count) | 684 | if (curr_param+1 < element->params_count) |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 7bd74b5636..16020a3590 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -109,6 +109,7 @@ struct progressbar { | |||
109 | 109 | ||
110 | bool invert_fill_direction; | 110 | bool invert_fill_direction; |
111 | bool nofill; | 111 | bool nofill; |
112 | bool nobar; | ||
112 | struct gui_img *slider; | 113 | struct gui_img *slider; |
113 | bool horizontal; | 114 | bool horizontal; |
114 | }; | 115 | }; |
diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index 92460e8b32..58d81e659d 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex | |||
@@ -650,16 +650,22 @@ Example: | |||
650 | \item[vertical] -- force the bar to be drawn vertically. | 650 | \item[vertical] -- force the bar to be drawn vertically. |
651 | \item[invert] -- invert the draw direction (i.e. right to left, or top to | 651 | \item[invert] -- invert the draw direction (i.e. right to left, or top to |
652 | bottom). | 652 | bottom). |
653 | \item[slider] -- draw an preloaded image over the top of the bar. This must be | 653 | \item[slider] -- draw an preloaded image over the top of the bar so that |
654 | the centre of the image matches current position. This must be | ||
654 | followed by the label of the desired image. | 655 | followed by the label of the desired image. |
655 | \item[nofill] -- don't draw the fill bar, only the empty image (for the | 656 | \item[nofill] -- don't draw the fill bar, only the empty image (for the |
656 | desired effect use with the ``slider'' option). | 657 | desired effect use with the ``slider'' option). |
658 | \item[nobar] -- don't draw the bar entirely including frame (for use | ||
659 | with the ``slider'' option). | ||
657 | \end{description} | 660 | \end{description} |
658 | 661 | ||
659 | Example: \config{\%pb(0,0,-,-,-,nofill, slider, slider\_image, invert)} -- draw | 662 | Example: \config{\%pb(0,0,-,-,-,nofill, slider, slider\_image, invert)} -- draw |
660 | a horizontal progressbar which doesn't fill and draws the image | 663 | a horizontal progressbar which doesn't fill and draws the image |
661 | ``slider\_image'' which moves right to left. | 664 | ``slider\_image'' which moves right to left. |
662 | 665 | ||
666 | Note: if the slider option is used, the bar will be shrank so that the slider will fit | ||
667 | inside the specified width and height. | ||
668 | |||
663 | \section{Other Tags} | 669 | \section{Other Tags} |
664 | \begin{tagmap} | 670 | \begin{tagmap} |
665 | \config{\%(} & The character `('\\ | 671 | \config{\%(} & The character `('\\ |