diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-10-16 19:14:37 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-10-16 19:14:37 +0000 |
commit | a72ffe7bb533302dbf4e6c7c4f1e4bd4078d3ed6 (patch) | |
tree | f15618b2c0e00cbb25d4e3ab900db3c799768bc6 /apps/gui/skin_engine/skin_display.c | |
parent | 9072a4558cb1db2b82ca3b001f6b95b5afda16c8 (diff) | |
download | rockbox-a72ffe7bb533302dbf4e6c7c4f1e4bd4078d3ed6.tar.gz rockbox-a72ffe7bb533302dbf4e6c7c4f1e4bd4078d3ed6.zip |
Make the skin engine behave sane if the skin's id3 pointer is NULL (the one in struct wps_state), so that skins don't need audio to be played before being displayed (needed for upcoming custom statusbar).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23208 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/skin_display.c')
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 83 |
1 files changed, 54 insertions, 29 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 7d75b48506..67984cd2bb 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -145,6 +145,7 @@ static void draw_progressbar(struct gui_wps *gwps, | |||
145 | struct screen *display = gwps->display; | 145 | struct screen *display = gwps->display; |
146 | struct wps_state *state = gwps->state; | 146 | struct wps_state *state = gwps->state; |
147 | struct progressbar *pb = wps_vp->pb; | 147 | struct progressbar *pb = wps_vp->pb; |
148 | struct mp3entry *id3 = state->id3; | ||
148 | int y = pb->y; | 149 | int y = pb->y; |
149 | 150 | ||
150 | if (y < 0) | 151 | if (y < 0) |
@@ -156,27 +157,37 @@ static void draw_progressbar(struct gui_wps *gwps, | |||
156 | y = (-y -1)*line_height + (0 > center ? 0 : center); | 157 | y = (-y -1)*line_height + (0 > center ? 0 : center); |
157 | } | 158 | } |
158 | 159 | ||
160 | int elapsed, length; | ||
161 | if (id3) | ||
162 | { | ||
163 | elapsed = id3->elapsed; | ||
164 | length = id3->length; | ||
165 | } | ||
166 | else | ||
167 | { | ||
168 | elapsed = 0; | ||
169 | length = 0; | ||
170 | } | ||
171 | |||
159 | if (pb->have_bitmap_pb) | 172 | if (pb->have_bitmap_pb) |
160 | gui_bitmap_scrollbar_draw(display, pb->bm, | 173 | gui_bitmap_scrollbar_draw(display, pb->bm, |
161 | pb->x, y, pb->width, pb->bm.height, | 174 | pb->x, y, pb->width, pb->bm.height, |
162 | state->id3->length ? state->id3->length : 1, 0, | 175 | length ? length : 1, 0, |
163 | state->id3->length ? state->id3->elapsed | 176 | length ? elapsed + state->ff_rewind_count : 0, |
164 | + state->ff_rewind_count : 0, | 177 | HORIZONTAL); |
165 | HORIZONTAL); | ||
166 | else | 178 | else |
167 | gui_scrollbar_draw(display, pb->x, y, pb->width, pb->height, | 179 | gui_scrollbar_draw(display, pb->x, y, pb->width, pb->height, |
168 | state->id3->length ? state->id3->length : 1, 0, | 180 | length ? length : 1, 0, |
169 | state->id3->length ? state->id3->elapsed | 181 | length ? elapsed + state->ff_rewind_count : 0, |
170 | + state->ff_rewind_count : 0, | 182 | HORIZONTAL); |
171 | HORIZONTAL); | ||
172 | #ifdef AB_REPEAT_ENABLE | 183 | #ifdef AB_REPEAT_ENABLE |
173 | if ( ab_repeat_mode_enabled() && state->id3->length != 0 ) | 184 | if ( ab_repeat_mode_enabled() && length != 0 ) |
174 | ab_draw_markers(display, state->id3->length, | 185 | ab_draw_markers(display, length, |
175 | pb->x, pb->x + pb->width, y, pb->height); | 186 | pb->x, pb->x + pb->width, y, pb->height); |
176 | #endif | 187 | #endif |
177 | 188 | ||
178 | if (state->id3->cuesheet) | 189 | if (id3 && id3->cuesheet) |
179 | cue_draw_markers(display, state->id3->cuesheet, state->id3->length, | 190 | cue_draw_markers(display, state->id3->cuesheet, length, |
180 | pb->x, pb->x + pb->width, y+1, pb->height-2); | 191 | pb->x, pb->x + pb->width, y+1, pb->height-2); |
181 | } | 192 | } |
182 | 193 | ||
@@ -266,12 +277,20 @@ static bool draw_player_progress(struct gui_wps *gwps) | |||
266 | int pos = 0; | 277 | int pos = 0; |
267 | int i; | 278 | int i; |
268 | 279 | ||
269 | if (!state->id3) | 280 | int elapsed, length; |
270 | return false; | 281 | if (LIKELY(state->id3)) |
282 | { | ||
283 | elapsed = state->id3->elapsed; | ||
284 | length = state->id3->length; | ||
285 | } | ||
286 | else | ||
287 | { | ||
288 | elapsed = 0; | ||
289 | length = 0; | ||
290 | } | ||
271 | 291 | ||
272 | if (state->id3->length) | 292 | if (length) |
273 | pos = 36 * (state->id3->elapsed + state->ff_rewind_count) | 293 | pos = 36 * (elapsed + state->ff_rewind_count) / length; |
274 | / state->id3->length; | ||
275 | 294 | ||
276 | for (i = 0; i < 7; i++, pos -= 5) | 295 | for (i = 0; i < 7; i++, pos -= 5) |
277 | { | 296 | { |
@@ -314,12 +333,24 @@ static void draw_player_fullbar(struct gui_wps *gwps, char* buf, int buf_size) | |||
314 | int digit, i, j; | 333 | int digit, i, j; |
315 | bool softchar; | 334 | bool softchar; |
316 | 335 | ||
317 | if (!state->id3 || buf_size < 34) /* worst case: 11x UTF-8 char + \0 */ | 336 | int elapsed, length; |
337 | if (LIKELY(state->id3)) | ||
338 | { | ||
339 | elapsed = id3->elapsed; | ||
340 | length = id3->length; | ||
341 | } | ||
342 | else | ||
343 | { | ||
344 | elapsed = 0; | ||
345 | length = 0; | ||
346 | } | ||
347 | |||
348 | if (buf_size < 34) /* worst case: 11x UTF-8 char + \0 */ | ||
318 | return; | 349 | return; |
319 | 350 | ||
320 | time = state->id3->elapsed + state->ff_rewind_count; | 351 | time = elapsed + state->ff_rewind_count; |
321 | if (state->id3->length) | 352 | if (length) |
322 | pos = 55 * time / state->id3->length; | 353 | pos = 55 * time / length; |
323 | 354 | ||
324 | memset(timestr, 0, sizeof(timestr)); | 355 | memset(timestr, 0, sizeof(timestr)); |
325 | format_time(timestr, sizeof(timestr)-2, time); | 356 | format_time(timestr, sizeof(timestr)-2, time); |
@@ -879,14 +910,8 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) | |||
879 | { | 910 | { |
880 | struct wps_data *data = gwps->data; | 911 | struct wps_data *data = gwps->data; |
881 | struct screen *display = gwps->display; | 912 | struct screen *display = gwps->display; |
882 | struct wps_state *state = gwps->state; | ||
883 | |||
884 | if (!data || !state || !display) | ||
885 | return false; | ||
886 | |||
887 | struct mp3entry *id3 = state->id3; | ||
888 | 913 | ||
889 | if (!id3) | 914 | if (!data || !display || !gwps->state) |
890 | return false; | 915 | return false; |
891 | 916 | ||
892 | unsigned flags; | 917 | unsigned flags; |