diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-08-15 14:13:36 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-08-15 14:13:36 +0000 |
commit | eda80390d5afc4346d2e64a256762df7df30bb17 (patch) | |
tree | b3f9fd726fdb1172b9f048cedb4bbb6808c03aa7 /apps | |
parent | ac2c69ccae5db7d5e22acf976910cdf3be84fe5a (diff) | |
download | rockbox-eda80390d5afc4346d2e64a256762df7df30bb17.tar.gz rockbox-eda80390d5afc4346d2e64a256762df7df30bb17.zip |
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/scrollbar.c | 21 | ||||
-rw-r--r-- | apps/gui/scrollbar.h | 9 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 77 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 37 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 5 |
5 files changed, 135 insertions, 14 deletions
diff --git a/apps/gui/scrollbar.c b/apps/gui/scrollbar.c index 317c55cdc7..8f431a4ff8 100644 --- a/apps/gui/scrollbar.c +++ b/apps/gui/scrollbar.c | |||
@@ -88,6 +88,12 @@ void gui_scrollbar_draw(struct screen * screen, int x, int y, | |||
88 | int infill; | 88 | int infill; |
89 | #endif | 89 | #endif |
90 | 90 | ||
91 | if (flags & INVERTFILL) | ||
92 | { | ||
93 | min_shown = items - max_shown; | ||
94 | max_shown = items; | ||
95 | } | ||
96 | |||
91 | inner_x = x + 1; | 97 | inner_x = x + 1; |
92 | inner_y = y + 1; | 98 | inner_y = y + 1; |
93 | inner_wd = width - 2; | 99 | inner_wd = width - 2; |
@@ -178,11 +184,18 @@ void gui_bitmap_scrollbar_draw(struct screen * screen, struct bitmap *bm, int x, | |||
178 | int start; | 184 | int start; |
179 | int size; | 185 | int size; |
180 | int inner_len; | 186 | int inner_len; |
187 | int startx = 0, starty = 0; | ||
181 | 188 | ||
182 | screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 189 | screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
183 | 190 | ||
184 | /* clear pixels in progress bar */ | 191 | /* clear pixels in progress bar */ |
185 | screen->fillrect(x, y, width, height); | 192 | screen->fillrect(x, y, width, height); |
193 | |||
194 | if (flags & INVERTFILL) | ||
195 | { | ||
196 | min_shown = items - max_shown; | ||
197 | max_shown = items; | ||
198 | } | ||
186 | 199 | ||
187 | if (flags & HORIZONTAL) | 200 | if (flags & HORIZONTAL) |
188 | inner_len = width; | 201 | inner_len = width; |
@@ -196,19 +209,23 @@ void gui_bitmap_scrollbar_draw(struct screen * screen, struct bitmap *bm, int x, | |||
196 | if (flags & HORIZONTAL) { | 209 | if (flags & HORIZONTAL) { |
197 | x += start; | 210 | x += start; |
198 | width = size; | 211 | width = size; |
212 | if (flags & INVERTFILL) | ||
213 | startx = start; | ||
199 | } else { | 214 | } else { |
200 | y += start; | 215 | y += start; |
201 | height = size; | 216 | height = size; |
217 | if (flags & INVERTFILL) | ||
218 | starty = start; | ||
202 | } | 219 | } |
203 | 220 | ||
204 | #if LCD_DEPTH > 1 | 221 | #if LCD_DEPTH > 1 |
205 | if (bm->format == FORMAT_MONO) | 222 | if (bm->format == FORMAT_MONO) |
206 | #endif | 223 | #endif |
207 | screen->mono_bitmap_part(bm->data, 0, 0, | 224 | screen->mono_bitmap_part(bm->data, startx, starty, |
208 | bm->width, x, y, width, height); | 225 | bm->width, x, y, width, height); |
209 | #if LCD_DEPTH > 1 | 226 | #if LCD_DEPTH > 1 |
210 | else | 227 | else |
211 | screen->transparent_bitmap_part((fb_data *)bm->data, 0, 0, | 228 | screen->transparent_bitmap_part((fb_data *)bm->data, startx, starty, |
212 | STRIDE(screen->screen_type, | 229 | STRIDE(screen->screen_type, |
213 | bm->width, bm->height), | 230 | bm->width, bm->height), |
214 | x, y, width, height); | 231 | x, y, width, height); |
diff --git a/apps/gui/scrollbar.h b/apps/gui/scrollbar.h index 03e1e6ec43..e5ffae79b0 100644 --- a/apps/gui/scrollbar.h +++ b/apps/gui/scrollbar.h | |||
@@ -28,12 +28,13 @@ | |||
28 | enum orientation { | 28 | enum orientation { |
29 | VERTICAL = 0x0000, /* Vertical orientation */ | 29 | VERTICAL = 0x0000, /* Vertical orientation */ |
30 | HORIZONTAL = 0x0001, /* Horizontal orientation */ | 30 | HORIZONTAL = 0x0001, /* Horizontal orientation */ |
31 | INVERTFILL = 0x0002, /* Invert the fill direction */ | ||
31 | #ifdef HAVE_LCD_COLOR | 32 | #ifdef HAVE_LCD_COLOR |
32 | FOREGROUND = 0x0002, /* Do not clear background pixels */ | 33 | FOREGROUND = 0x0020, /* Do not clear background pixels */ |
33 | INNER_FILL = 0x0004, /* Fill inner part even if FOREGROUND */ | 34 | INNER_FILL = 0x0040, /* Fill inner part even if FOREGROUND */ |
34 | INNER_BGFILL = 0x0008, /* Fill inner part with background | 35 | INNER_BGFILL = 0x0080, /* Fill inner part with background |
35 | color even if FOREGROUND */ | 36 | color even if FOREGROUND */ |
36 | INNER_FILL_MASK = 0x000c, | 37 | INNER_FILL_MASK = 0x00c0, |
37 | #endif | 38 | #endif |
38 | }; | 39 | }; |
39 | 40 | ||
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 53b568ad53..8e08343d82 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -129,7 +129,10 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
129 | struct wps_state *state = gwps->state; | 129 | struct wps_state *state = gwps->state; |
130 | struct mp3entry *id3 = state->id3; | 130 | struct mp3entry *id3 = state->id3; |
131 | int y = pb->y, height = pb->height; | 131 | int y = pb->y, height = pb->height; |
132 | unsigned long length, elapsed; | 132 | unsigned long length, end; |
133 | int flags = HORIZONTAL; | ||
134 | |||
135 | int drawn_length, drawn_end; | ||
133 | 136 | ||
134 | if (height < 0) | 137 | if (height < 0) |
135 | height = font_get(vp->font)->height; | 138 | height = font_get(vp->font)->height; |
@@ -148,39 +151,62 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
148 | int minvol = sound_min(SOUND_VOLUME); | 151 | int minvol = sound_min(SOUND_VOLUME); |
149 | int maxvol = sound_max(SOUND_VOLUME); | 152 | int maxvol = sound_max(SOUND_VOLUME); |
150 | length = maxvol-minvol; | 153 | length = maxvol-minvol; |
151 | elapsed = global_settings.volume-minvol; | 154 | end = global_settings.volume-minvol; |
152 | } | 155 | } |
153 | else if (pb->type == SKIN_TOKEN_BATTERY_PERCENTBAR) | 156 | else if (pb->type == SKIN_TOKEN_BATTERY_PERCENTBAR) |
154 | { | 157 | { |
155 | length = 100; | 158 | length = 100; |
156 | elapsed = battery_level(); | 159 | end = battery_level(); |
157 | } | 160 | } |
158 | #if CONFIG_TUNER | 161 | #if CONFIG_TUNER |
159 | else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) | 162 | else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) |
160 | { | 163 | { |
161 | int min = fm_region_data[global_settings.fm_region].freq_min; | 164 | int min = fm_region_data[global_settings.fm_region].freq_min; |
162 | elapsed = radio_current_frequency() - min; | 165 | end = radio_current_frequency() - min; |
163 | length = fm_region_data[global_settings.fm_region].freq_max - min; | 166 | length = fm_region_data[global_settings.fm_region].freq_max - min; |
164 | } | 167 | } |
165 | #endif | 168 | #endif |
166 | else if (id3 && id3->length) | 169 | else if (id3 && id3->length) |
167 | { | 170 | { |
168 | length = id3->length; | 171 | length = id3->length; |
169 | elapsed = id3->elapsed + state->ff_rewind_count; | 172 | end = id3->elapsed + state->ff_rewind_count; |
170 | } | 173 | } |
171 | else | 174 | else |
172 | { | 175 | { |
173 | length = 1; | 176 | length = 1; |
174 | elapsed = 0; | 177 | end = 0; |
178 | } | ||
179 | |||
180 | if (pb->nofill) | ||
181 | { | ||
182 | drawn_length = 1; | ||
183 | drawn_end = 0; | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | drawn_length = length; | ||
188 | drawn_end = end; | ||
189 | } | ||
190 | |||
191 | if (!pb->horizontal) | ||
192 | { | ||
193 | /* we want to fill upwards which is technically inverted. */ | ||
194 | flags = VERTICAL|INVERTFILL; | ||
195 | } | ||
196 | |||
197 | if (pb->invert_fill_direction) | ||
198 | { | ||
199 | flags ^= INVERTFILL; | ||
175 | } | 200 | } |
176 | 201 | ||
202 | |||
177 | if (pb->have_bitmap_pb) | 203 | if (pb->have_bitmap_pb) |
178 | gui_bitmap_scrollbar_draw(display, &pb->bm, | 204 | gui_bitmap_scrollbar_draw(display, &pb->bm, |
179 | pb->x, y, pb->width, pb->bm.height, | 205 | pb->x, y, pb->width, pb->bm.height, |
180 | length, 0, elapsed, HORIZONTAL); | 206 | drawn_length, 0, drawn_end, flags); |
181 | else | 207 | else |
182 | gui_scrollbar_draw(display, pb->x, y, pb->width, height, | 208 | gui_scrollbar_draw(display, pb->x, y, pb->width, height, |
183 | length, 0, elapsed, HORIZONTAL); | 209 | drawn_length, 0, drawn_end, flags); |
184 | 210 | ||
185 | if (pb->type == SKIN_TOKEN_PROGRESSBAR) | 211 | if (pb->type == SKIN_TOKEN_PROGRESSBAR) |
186 | { | 212 | { |
@@ -203,6 +229,41 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
203 | } | 229 | } |
204 | #endif | 230 | #endif |
205 | } | 231 | } |
232 | |||
233 | if (pb->slider) | ||
234 | { | ||
235 | int x = pb->x, y = pb->y; | ||
236 | int width = pb->width; | ||
237 | int height = pb->height; | ||
238 | struct gui_img *img = pb->slider; | ||
239 | |||
240 | if (flags&VERTICAL) | ||
241 | { | ||
242 | y += pb->height*end/length; | ||
243 | height = img->bm.height; | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | x += pb->width*end/length; | ||
248 | width = img->bm.width; | ||
249 | } | ||
250 | #if LCD_DEPTH > 1 | ||
251 | if(img->bm.format == FORMAT_MONO) { | ||
252 | #endif | ||
253 | display->mono_bitmap_part(img->bm.data, | ||
254 | 0, 0, | ||
255 | img->bm.width, x, | ||
256 | y, width, height); | ||
257 | #if LCD_DEPTH > 1 | ||
258 | } else { | ||
259 | display->transparent_bitmap_part((fb_data *)img->bm.data, | ||
260 | 0, 0, | ||
261 | STRIDE(display->screen_type, | ||
262 | img->bm.width, img->bm.height), | ||
263 | x, y, width, height); | ||
264 | } | ||
265 | #endif | ||
266 | } | ||
206 | } | 267 | } |
207 | 268 | ||
208 | /* clears the area where the image was shown */ | 269 | /* clears the area where the image was shown */ |
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 68cb01470c..341056ff87 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -540,6 +540,7 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
540 | struct skin_token_list *item; | 540 | struct skin_token_list *item; |
541 | struct viewport *vp = &curr_vp->vp; | 541 | struct viewport *vp = &curr_vp->vp; |
542 | struct skin_tag_parameter *param = element->params; | 542 | struct skin_tag_parameter *param = element->params; |
543 | int curr_param = 0; | ||
543 | 544 | ||
544 | if (element->params_count == 0 && | 545 | if (element->params_count == 0 && |
545 | element->tag->type != SKIN_TOKEN_PROGRESSBAR) | 546 | element->tag->type != SKIN_TOKEN_PROGRESSBAR) |
@@ -554,6 +555,7 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
554 | pb->have_bitmap_pb = false; | 555 | pb->have_bitmap_pb = false; |
555 | pb->bm.data = NULL; /* no bitmap specified */ | 556 | pb->bm.data = NULL; /* no bitmap specified */ |
556 | pb->follow_lang_direction = follow_lang_direction > 0; | 557 | pb->follow_lang_direction = follow_lang_direction > 0; |
558 | pb->invert_fill_direction = false; | ||
557 | 559 | ||
558 | if (element->params_count == 0) | 560 | if (element->params_count == 0) |
559 | { | 561 | { |
@@ -614,6 +616,41 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
614 | if (!isdefault(param)) | 616 | if (!isdefault(param)) |
615 | pb->bm.data = param->data.text; | 617 | pb->bm.data = param->data.text; |
616 | 618 | ||
619 | curr_param = 5; | ||
620 | pb->invert_fill_direction = false; | ||
621 | pb->nofill = false; | ||
622 | pb->slider = NULL; | ||
623 | pb->horizontal = pb->width > pb->height; | ||
624 | while (curr_param < element->params_count) | ||
625 | { | ||
626 | param++; | ||
627 | if (!strcmp(param->data.text, "invert")) | ||
628 | pb->invert_fill_direction = true; | ||
629 | else if (!strcmp(param->data.text, "nofill")) | ||
630 | pb->nofill = true; | ||
631 | else if (!strcmp(param->data.text, "slider")) | ||
632 | { | ||
633 | if (curr_param+1 < element->params_count) | ||
634 | { | ||
635 | curr_param++; | ||
636 | param++; | ||
637 | pb->slider = find_image(param->data.text, wps_data); | ||
638 | if (!pb->slider) | ||
639 | return -1; | ||
640 | } | ||
641 | } | ||
642 | else if (!strcmp(param->data.text, "vertical")) | ||
643 | { | ||
644 | pb->horizontal = false; | ||
645 | if (isdefault(&element->params[3])) | ||
646 | pb->height = vp->height - pb->x; | ||
647 | } | ||
648 | else if (!strcmp(param->data.text, "horizontal")) | ||
649 | pb->horizontal = true; | ||
650 | |||
651 | curr_param++; | ||
652 | } | ||
653 | |||
617 | 654 | ||
618 | if (token->type == SKIN_TOKEN_VOLUME) | 655 | if (token->type == SKIN_TOKEN_VOLUME) |
619 | token->type = SKIN_TOKEN_VOLUMEBAR; | 656 | token->type = SKIN_TOKEN_VOLUMEBAR; |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index ccae11b91a..c886a7584f 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -106,6 +106,11 @@ struct progressbar { | |||
106 | /*progressbar image*/ | 106 | /*progressbar image*/ |
107 | struct bitmap bm; | 107 | struct bitmap bm; |
108 | bool have_bitmap_pb; | 108 | bool have_bitmap_pb; |
109 | |||
110 | bool invert_fill_direction; | ||
111 | bool nofill; | ||
112 | struct gui_img *slider; | ||
113 | bool horizontal; | ||
109 | }; | 114 | }; |
110 | #endif | 115 | #endif |
111 | 116 | ||