summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_display.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-08-14 15:17:59 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-08-14 15:17:59 +0000
commitdc3778a685835ff6db12db9e784af01de2165656 (patch)
treefa81e777554fb3970f0a29888d02ccdde283b706 /apps/gui/skin_engine/skin_display.c
parentff8d43ddad6e26f14218c212503c551f5a7d6b26 (diff)
downloadrockbox-dc3778a685835ff6db12db9e784af01de2165656.tar.gz
rockbox-dc3778a685835ff6db12db9e784af01de2165656.zip
Rework the skin playlist viewer so it uses the same drawing code as everything else. This should mean that all text tags now work as expected. The 2nd code param is no longer needed so drop it (you can use conditionals and sublines and stuff in the one code param.
example: %Vp(1, %?it<%in -%it|%fn>) <- show the next tracks strating from the first next track and show info if it is avilable or the filename. Basic cuesheet support here, and will load upcoming track tags from the database if you have load to ram enabled. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27814 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/skin_display.c')
-rw-r--r--apps/gui/skin_engine/skin_display.c190
1 files changed, 3 insertions, 187 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index d0044b14d8..53b568ad53 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -205,191 +205,6 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
205 } 205 }
206} 206}
207 207
208void draw_playlist_viewer_list(struct gui_wps *gwps, struct playlistviewer *viewer)
209{
210 struct wps_state *state = gwps->state;
211 int lines = viewport_get_nb_lines(viewer->vp);
212 int line_height = font_get(viewer->vp->font)->height;
213 int cur_pos, max;
214 int start_item;
215 int i;
216 bool scroll = false;
217 struct wps_token *token;
218 int x, length, alignment = SKIN_TOKEN_ALIGN_LEFT;
219
220 struct mp3entry *pid3;
221 char buf[MAX_PATH*2], tempbuf[MAX_PATH], filename_buf[MAX_PATH + 1];
222 const char *filename;
223#if CONFIG_TUNER
224 if (current_screen() == GO_TO_FM)
225 {
226 cur_pos = radio_current_preset();
227 start_item = cur_pos + viewer->start_offset;
228 max = start_item+radio_preset_count();
229 }
230 else
231#endif
232 {
233 cur_pos = playlist_get_display_index();
234 max = playlist_amount()+1;
235 start_item = MAX(0, cur_pos + viewer->start_offset);
236 }
237
238 gwps->display->set_viewport(viewer->vp);
239 for(i=start_item; (i-start_item)<lines && i<max; i++)
240 {
241 int line;
242#if CONFIG_TUNER
243 if (current_screen() == GO_TO_FM)
244 {
245 pid3 = NULL;
246 line = TRACK_HAS_INFO;
247 filename = "";
248 }
249 else
250#endif
251 {
252 filename = playlist_peek(i-cur_pos, filename_buf,
253 sizeof(filename_buf));
254 if (i == cur_pos)
255 {
256 pid3 = state->id3;
257 }
258 else if (i == cur_pos+1)
259 {
260 pid3 = state->nid3;
261 }
262#if CONFIG_CODEC == SWCODEC
263 else if (i>cur_pos)
264 {
265#ifdef HAVE_TC_RAMCACHE
266 if (tagcache_fill_tags(&viewer->tempid3, filename))
267 {
268 pid3 = &viewer->tempid3;
269 }
270 else
271#endif
272 if (!audio_peek_track(&pid3, i-cur_pos))
273 pid3 = NULL;
274 }
275#endif
276 else
277 {
278 pid3 = NULL;
279 }
280 line = pid3 ? TRACK_HAS_INFO : TRACK_HAS_NO_INFO;
281 }
282 unsigned int line_len = 0;
283 if (viewer->lines[line]->children_count == 0)
284 return;
285 struct skin_element *element = viewer->lines[line]->children[0];
286 buf[0] = '\0';
287 while (element && line_len < sizeof(buf))
288 {
289 const char *out = NULL;
290 if (element->type == TEXT)
291 {
292 line_len = strlcat(buf, (char*)element->data, sizeof(buf));
293 element = element->next;
294 continue;
295 }
296 if (element->type != TAG)
297 {
298 element = element->next;
299 continue;
300 }
301 if (element->tag->type == SKIN_TOKEN_SUBLINE_SCROLL)
302 scroll = true;
303 token = (struct wps_token*)element->data;
304 out = get_id3_token(token, pid3, tempbuf, sizeof(tempbuf), -1, NULL);
305#if CONFIG_TUNER
306 if (!out)
307 out = get_radio_token(token, i-cur_pos,
308 tempbuf, sizeof(tempbuf), -1, NULL);
309#endif
310 if (out)
311 {
312 line_len = strlcat(buf, out, sizeof(buf));
313 element = element->next;
314 continue;
315 }
316
317 switch (token->type)
318 {
319 case SKIN_TOKEN_ALIGN_CENTER:
320 case SKIN_TOKEN_ALIGN_LEFT:
321 case SKIN_TOKEN_ALIGN_LEFT_RTL:
322 case SKIN_TOKEN_ALIGN_RIGHT:
323 case SKIN_TOKEN_ALIGN_RIGHT_RTL:
324 alignment = token->type;
325 tempbuf[0] = '\0';
326 break;
327 case SKIN_TOKEN_PLAYLIST_POSITION:
328 snprintf(tempbuf, sizeof(tempbuf), "%d", i);
329 break;
330 case SKIN_TOKEN_FILE_NAME:
331 get_dir(tempbuf, sizeof(tempbuf), filename, 0);
332 break;
333 case SKIN_TOKEN_FILE_PATH:
334 snprintf(tempbuf, sizeof(tempbuf), "%s", filename);
335 break;
336 default:
337 tempbuf[0] = '\0';
338 break;
339 }
340 if (tempbuf[0])
341 {
342 line_len = strlcat(buf, tempbuf, sizeof(buf));
343 }
344 element = element->next;
345 }
346
347 int vpwidth = viewer->vp->width;
348 length = gwps->display->getstringsize(buf, NULL, NULL);
349 if (scroll && length >= vpwidth)
350 {
351 gwps->display->puts_scroll(0, (i-start_item), buf );
352 }
353 else
354 {
355 if (length >= vpwidth)
356 x = 0;
357 else
358 {
359 switch (alignment)
360 {
361 case SKIN_TOKEN_ALIGN_CENTER:
362 x = (vpwidth-length)/2;
363 break;
364 case SKIN_TOKEN_ALIGN_LEFT_RTL:
365 if (lang_is_rtl() && VP_IS_RTL(viewer->vp))
366 {
367 x = vpwidth - length;
368 break;
369 }
370 case SKIN_TOKEN_ALIGN_LEFT:
371 x = 0;
372 break;
373 case SKIN_TOKEN_ALIGN_RIGHT_RTL:
374 if (lang_is_rtl() && VP_IS_RTL(viewer->vp))
375 {
376 x = 0;
377 break;
378 }
379 case SKIN_TOKEN_ALIGN_RIGHT:
380 x = vpwidth - length;
381 break;
382 default:
383 x = 0;
384 break;
385 }
386 }
387 gwps->display->putsxy(x, (i-start_item)*line_height, buf );
388 }
389 }
390}
391
392
393/* clears the area where the image was shown */ 208/* clears the area where the image was shown */
394void clear_image_pos(struct gui_wps *gwps, struct gui_img *img) 209void clear_image_pos(struct gui_wps *gwps, struct gui_img *img)
395{ 210{
@@ -618,7 +433,8 @@ void draw_player_fullbar(struct gui_wps *gwps, char* buf, int buf_size)
618/* Evaluate the conditional that is at *token_index and return whether a skip 433/* Evaluate the conditional that is at *token_index and return whether a skip
619 has ocurred. *token_index is updated with the new position. 434 has ocurred. *token_index is updated with the new position.
620*/ 435*/
621int evaluate_conditional(struct gui_wps *gwps, struct conditional *conditional, int num_options) 436int evaluate_conditional(struct gui_wps *gwps, int offset,
437 struct conditional *conditional, int num_options)
622{ 438{
623 if (!gwps) 439 if (!gwps)
624 return false; 440 return false;
@@ -633,7 +449,7 @@ int evaluate_conditional(struct gui_wps *gwps, struct conditional *conditional,
633 449
634 int intval = num_options; 450 int intval = num_options;
635 /* get_token_value needs to know the number of options in the enum */ 451 /* get_token_value needs to know the number of options in the enum */
636 value = get_token_value(gwps, conditional->token, 452 value = get_token_value(gwps, conditional->token, offset,
637 result, sizeof(result), &intval); 453 result, sizeof(result), &intval);
638 454
639 /* intval is now the number of the enum option we want to read, 455 /* intval is now the number of the enum option we want to read,