diff options
Diffstat (limited to 'apps/gui/skin_engine/skin_render.c')
-rw-r--r-- | apps/gui/skin_engine/skin_render.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index 00981f5b67..ed2f783e7a 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c | |||
@@ -60,17 +60,17 @@ struct skin_draw_info { | |||
60 | int line_number; | 60 | int line_number; |
61 | unsigned long refresh_type; | 61 | unsigned long refresh_type; |
62 | struct line_desc line_desc; | 62 | struct line_desc line_desc; |
63 | 63 | ||
64 | char* cur_align_start; | 64 | char* cur_align_start; |
65 | struct align_pos align; | 65 | struct align_pos align; |
66 | bool no_line_break; | 66 | bool no_line_break; |
67 | bool line_scrolls; | 67 | bool line_scrolls; |
68 | bool force_redraw; | 68 | bool force_redraw; |
69 | bool viewport_change; | 69 | bool viewport_change; |
70 | 70 | ||
71 | char *buf; | 71 | char *buf; |
72 | size_t buf_size; | 72 | size_t buf_size; |
73 | 73 | ||
74 | int offset; /* used by the playlist viewer */ | 74 | int offset; /* used by the playlist viewer */ |
75 | }; | 75 | }; |
76 | 76 | ||
@@ -102,7 +102,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, | |||
102 | bool do_refresh = (element->tag->flags & info->refresh_type) > 0; | 102 | bool do_refresh = (element->tag->flags & info->refresh_type) > 0; |
103 | 103 | ||
104 | switch (token->type) | 104 | switch (token->type) |
105 | { | 105 | { |
106 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) | 106 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) |
107 | case SKIN_TOKEN_VIEWPORT_FGCOLOUR: | 107 | case SKIN_TOKEN_VIEWPORT_FGCOLOUR: |
108 | { | 108 | { |
@@ -161,7 +161,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, | |||
161 | while (viewport) | 161 | while (viewport) |
162 | { | 162 | { |
163 | struct skin_viewport *skinvp = SKINOFFSETTOPTR(skin_buffer, viewport->data); | 163 | struct skin_viewport *skinvp = SKINOFFSETTOPTR(skin_buffer, viewport->data); |
164 | 164 | ||
165 | char *vplabel = SKINOFFSETTOPTR(skin_buffer, skinvp->label); | 165 | char *vplabel = SKINOFFSETTOPTR(skin_buffer, skinvp->label); |
166 | if (skinvp->label == VP_DEFAULT_LABEL) | 166 | if (skinvp->label == VP_DEFAULT_LABEL) |
167 | vplabel = VP_DEFAULT_LABEL_STRING; | 167 | vplabel = VP_DEFAULT_LABEL_STRING; |
@@ -171,7 +171,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, | |||
171 | if (skinvp->hidden_flags&VP_DRAW_HIDDEN) | 171 | if (skinvp->hidden_flags&VP_DRAW_HIDDEN) |
172 | { | 172 | { |
173 | temp |= VP_DRAW_WASHIDDEN; | 173 | temp |= VP_DRAW_WASHIDDEN; |
174 | } | 174 | } |
175 | skinvp->hidden_flags = temp; | 175 | skinvp->hidden_flags = temp; |
176 | } | 176 | } |
177 | viewport = SKINOFFSETTOPTR(skin_buffer, viewport->next); | 177 | viewport = SKINOFFSETTOPTR(skin_buffer, viewport->next); |
@@ -351,7 +351,7 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch, | |||
351 | struct wps_data *data = gwps->data; | 351 | struct wps_data *data = gwps->data; |
352 | struct viewport *last_vp; | 352 | struct viewport *last_vp; |
353 | 353 | ||
354 | /* Tags here are ones which need to be "turned off" or cleared | 354 | /* Tags here are ones which need to be "turned off" or cleared |
355 | * if they are in a conditional branch which isnt being used */ | 355 | * if they are in a conditional branch which isnt being used */ |
356 | if (branch->type == LINE_ALTERNATOR) | 356 | if (branch->type == LINE_ALTERNATOR) |
357 | { | 357 | { |
@@ -387,7 +387,7 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch, | |||
387 | if (token->type == SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY) | 387 | if (token->type == SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY) |
388 | { | 388 | { |
389 | struct image_display *id = SKINOFFSETTOPTR(skin_buffer, token->value.data); | 389 | struct image_display *id = SKINOFFSETTOPTR(skin_buffer, token->value.data); |
390 | struct gui_img *img = skin_find_item(SKINOFFSETTOPTR(skin_buffer, id->label), | 390 | struct gui_img *img = skin_find_item(SKINOFFSETTOPTR(skin_buffer, id->label), |
391 | SKIN_FIND_IMAGE, data); | 391 | SKIN_FIND_IMAGE, data); |
392 | clear_image_pos(gwps, img); | 392 | clear_image_pos(gwps, img); |
393 | } | 393 | } |
@@ -455,7 +455,7 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch, | |||
455 | } | 455 | } |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | static void fix_line_alignment(struct skin_draw_info *info, struct skin_element *element) | 459 | static void fix_line_alignment(struct skin_draw_info *info, struct skin_element *element) |
460 | { | 460 | { |
461 | struct align_pos *align = &info->align; | 461 | struct align_pos *align = &info->align; |
@@ -497,16 +497,16 @@ static void fix_line_alignment(struct skin_draw_info *info, struct skin_element | |||
497 | break; | 497 | break; |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | /* Draw a LINE element onto the display */ | 501 | /* Draw a LINE element onto the display */ |
502 | static bool skin_render_line(struct skin_element* line, struct skin_draw_info *info) | 502 | static bool skin_render_line(struct skin_element* line, struct skin_draw_info *info) |
503 | { | 503 | { |
504 | bool needs_update = false; | 504 | bool needs_update = false; |
505 | int last_value, value; | 505 | int last_value, value; |
506 | 506 | ||
507 | if (line->children_count == 0) | 507 | if (line->children_count == 0) |
508 | return false; /* empty line, do nothing */ | 508 | return false; /* empty line, do nothing */ |
509 | 509 | ||
510 | struct skin_element *child = get_child(line->children, 0); | 510 | struct skin_element *child = get_child(line->children, 0); |
511 | struct conditional *conditional; | 511 | struct conditional *conditional; |
512 | skin_render_func func = skin_render_line; | 512 | skin_render_func func = skin_render_line; |
@@ -518,14 +518,14 @@ static bool skin_render_line(struct skin_element* line, struct skin_draw_info *i | |||
518 | case CONDITIONAL: | 518 | case CONDITIONAL: |
519 | conditional = SKINOFFSETTOPTR(skin_buffer, child->data); | 519 | conditional = SKINOFFSETTOPTR(skin_buffer, child->data); |
520 | last_value = conditional->last_value; | 520 | last_value = conditional->last_value; |
521 | value = evaluate_conditional(info->gwps, info->offset, | 521 | value = evaluate_conditional(info->gwps, info->offset, |
522 | conditional, child->children_count); | 522 | conditional, child->children_count); |
523 | conditional->last_value = value; | 523 | conditional->last_value = value; |
524 | if (child->children_count == 1) | 524 | if (child->children_count == 1) |
525 | { | 525 | { |
526 | /* special handling so | 526 | /* special handling so |
527 | * %?aa<true> and %?<true|false> need special handlng here */ | 527 | * %?aa<true> and %?<true|false> need special handlng here */ |
528 | 528 | ||
529 | if (value == -1) /* tag is false */ | 529 | if (value == -1) /* tag is false */ |
530 | { | 530 | { |
531 | /* we are in a false branch of a %?aa<true> conditional */ | 531 | /* we are in a false branch of a %?aa<true> conditional */ |
@@ -545,18 +545,18 @@ static bool skin_render_line(struct skin_element* line, struct skin_draw_info *i | |||
545 | } | 545 | } |
546 | else if (get_child(child->children, value)->type == LINE) | 546 | else if (get_child(child->children, value)->type == LINE) |
547 | func = skin_render_line; | 547 | func = skin_render_line; |
548 | 548 | ||
549 | if (value != last_value) | 549 | if (value != last_value) |
550 | { | 550 | { |
551 | info->refresh_type = SKIN_REFRESH_ALL; | 551 | info->refresh_type = SKIN_REFRESH_ALL; |
552 | info->force_redraw = true; | 552 | info->force_redraw = true; |
553 | } | 553 | } |
554 | 554 | ||
555 | if (func(get_child(child->children, value), info)) | 555 | if (func(get_child(child->children, value), info)) |
556 | needs_update = true; | 556 | needs_update = true; |
557 | else | 557 | else |
558 | needs_update = needs_update || (last_value != value); | 558 | needs_update = needs_update || (last_value != value); |
559 | 559 | ||
560 | info->refresh_type = old_refresh_mode; | 560 | info->refresh_type = old_refresh_mode; |
561 | break; | 561 | break; |
562 | case TAG: | 562 | case TAG: |
@@ -564,9 +564,9 @@ static bool skin_render_line(struct skin_element* line, struct skin_draw_info *i | |||
564 | info->no_line_break = true; | 564 | info->no_line_break = true; |
565 | if (child->tag->type == SKIN_TOKEN_SUBLINE_SCROLL) | 565 | if (child->tag->type == SKIN_TOKEN_SUBLINE_SCROLL) |
566 | info->line_scrolls = true; | 566 | info->line_scrolls = true; |
567 | 567 | ||
568 | fix_line_alignment(info, child); | 568 | fix_line_alignment(info, child); |
569 | 569 | ||
570 | if (!SKINOFFSETTOPTR(skin_buffer, child->data)) | 570 | if (!SKINOFFSETTOPTR(skin_buffer, child->data)) |
571 | { | 571 | { |
572 | break; | 572 | break; |
@@ -583,17 +583,17 @@ static bool skin_render_line(struct skin_element* line, struct skin_draw_info *i | |||
583 | if (child->tag->flags&SKIN_RTC_REFRESH) | 583 | if (child->tag->flags&SKIN_RTC_REFRESH) |
584 | needs_update = needs_update || info->refresh_type&SKIN_REFRESH_DYNAMIC; | 584 | needs_update = needs_update || info->refresh_type&SKIN_REFRESH_DYNAMIC; |
585 | #endif | 585 | #endif |
586 | needs_update = needs_update || | 586 | needs_update = needs_update || |
587 | ((child->tag->flags&info->refresh_type)!=0); | 587 | ((child->tag->flags&info->refresh_type)!=0); |
588 | strlcat(info->cur_align_start, valuestr, | 588 | strlcat(info->cur_align_start, valuestr, |
589 | info->buf_size - (info->cur_align_start-info->buf)); | 589 | info->buf_size - (info->cur_align_start-info->buf)); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | break; | 592 | break; |
593 | case TEXT: | 593 | case TEXT: |
594 | strlcat(info->cur_align_start, SKINOFFSETTOPTR(skin_buffer, child->data), | 594 | strlcat(info->cur_align_start, SKINOFFSETTOPTR(skin_buffer, child->data), |
595 | info->buf_size - (info->cur_align_start-info->buf)); | 595 | info->buf_size - (info->cur_align_start-info->buf)); |
596 | needs_update = needs_update || | 596 | needs_update = needs_update || |
597 | (info->refresh_type&SKIN_REFRESH_STATIC) != 0; | 597 | (info->refresh_type&SKIN_REFRESH_STATIC) != 0; |
598 | break; | 598 | break; |
599 | case COMMENT: | 599 | case COMMENT: |
@@ -664,7 +664,7 @@ bool skin_render_alternator(struct skin_element* element, struct skin_draw_info | |||
664 | int try_line = start; | 664 | int try_line = start; |
665 | bool suitable = false; | 665 | bool suitable = false; |
666 | int rettimeout = DEFAULT_SUBLINE_TIME_MULTIPLIER*TIMEOUT_UNIT; | 666 | int rettimeout = DEFAULT_SUBLINE_TIME_MULTIPLIER*TIMEOUT_UNIT; |
667 | 667 | ||
668 | /* find a subline which has at least one token in it, | 668 | /* find a subline which has at least one token in it, |
669 | * and that line doesnt have a timeout set to 0 through conditionals */ | 669 | * and that line doesnt have a timeout set to 0 through conditionals */ |
670 | do { | 670 | do { |
@@ -674,7 +674,7 @@ bool skin_render_alternator(struct skin_element* element, struct skin_draw_info | |||
674 | if (get_child(element->children, try_line)->children_count != 0) | 674 | if (get_child(element->children, try_line)->children_count != 0) |
675 | { | 675 | { |
676 | current_line = get_child(element->children, try_line); | 676 | current_line = get_child(element->children, try_line); |
677 | rettimeout = get_subline_timeout(info->gwps, | 677 | rettimeout = get_subline_timeout(info->gwps, |
678 | get_child(current_line->children, 0)); | 678 | get_child(current_line->children, 0)); |
679 | if (rettimeout > 0) | 679 | if (rettimeout > 0) |
680 | { | 680 | { |
@@ -683,7 +683,7 @@ bool skin_render_alternator(struct skin_element* element, struct skin_draw_info | |||
683 | } | 683 | } |
684 | } | 684 | } |
685 | while (try_line != start && !suitable); | 685 | while (try_line != start && !suitable); |
686 | 686 | ||
687 | if (suitable) | 687 | if (suitable) |
688 | { | 688 | { |
689 | alternator->current_line = try_line; | 689 | alternator->current_line = try_line; |
@@ -749,14 +749,14 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps, | |||
749 | if (++info.line_desc.line > info.line_desc.nlines) | 749 | if (++info.line_desc.line > info.line_desc.nlines) |
750 | info.line_desc.style = STYLE_DEFAULT; | 750 | info.line_desc.style = STYLE_DEFAULT; |
751 | } | 751 | } |
752 | #endif | 752 | #endif |
753 | #endif | 753 | #endif |
754 | info.cur_align_start = info.buf; | 754 | info.cur_align_start = info.buf; |
755 | align->left = info.buf; | 755 | align->left = info.buf; |
756 | align->center = NULL; | 756 | align->center = NULL; |
757 | align->right = NULL; | 757 | align->right = NULL; |
758 | 758 | ||
759 | 759 | ||
760 | if (line->type == LINE_ALTERNATOR) | 760 | if (line->type == LINE_ALTERNATOR) |
761 | func = skin_render_alternator; | 761 | func = skin_render_alternator; |
762 | else if (line->type == LINE) | 762 | else if (line->type == LINE) |
@@ -798,11 +798,11 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode) | |||
798 | const int vp_is_appearing = (VP_DRAW_WASHIDDEN|VP_DRAW_HIDEABLE); | 798 | const int vp_is_appearing = (VP_DRAW_WASHIDDEN|VP_DRAW_HIDEABLE); |
799 | struct wps_data *data = gwps->data; | 799 | struct wps_data *data = gwps->data; |
800 | struct screen *display = gwps->display; | 800 | struct screen *display = gwps->display; |
801 | 801 | ||
802 | struct skin_element* viewport; | 802 | struct skin_element* viewport; |
803 | struct skin_viewport* skin_viewport; | 803 | struct skin_viewport* skin_viewport; |
804 | char *label; | 804 | char *label; |
805 | 805 | ||
806 | int old_refresh_mode = refresh_mode; | 806 | int old_refresh_mode = refresh_mode; |
807 | skin_buffer = get_skin_buffer(gwps->data); | 807 | skin_buffer = get_skin_buffer(gwps->data); |
808 | 808 | ||
@@ -828,7 +828,7 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode) | |||
828 | if (label && SKINOFFSETTOPTR(skin_buffer, viewport->next) && | 828 | if (label && SKINOFFSETTOPTR(skin_buffer, viewport->next) && |
829 | !strcmp(label,VP_DEFAULT_LABEL_STRING)) | 829 | !strcmp(label,VP_DEFAULT_LABEL_STRING)) |
830 | refresh_mode = 0; | 830 | refresh_mode = 0; |
831 | 831 | ||
832 | for (viewport = SKINOFFSETTOPTR(skin_buffer, data->tree); | 832 | for (viewport = SKINOFFSETTOPTR(skin_buffer, data->tree); |
833 | viewport; | 833 | viewport; |
834 | viewport = SKINOFFSETTOPTR(skin_buffer, viewport->next)) | 834 | viewport = SKINOFFSETTOPTR(skin_buffer, viewport->next)) |
@@ -848,7 +848,7 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode) | |||
848 | skin_backdrop_show(data->backdrop_id); | 848 | skin_backdrop_show(data->backdrop_id); |
849 | } | 849 | } |
850 | #endif | 850 | #endif |
851 | 851 | ||
852 | /* dont redraw the viewport if its disabled */ | 852 | /* dont redraw the viewport if its disabled */ |
853 | if (skin_viewport->hidden_flags&VP_NEVER_VISIBLE) | 853 | if (skin_viewport->hidden_flags&VP_NEVER_VISIBLE) |
854 | { /* don't draw anything into this one */ | 854 | { /* don't draw anything into this one */ |
@@ -864,7 +864,7 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode) | |||
864 | vp_refresh_mode = SKIN_REFRESH_ALL; | 864 | vp_refresh_mode = SKIN_REFRESH_ALL; |
865 | skin_viewport->hidden_flags = VP_DRAW_HIDEABLE; | 865 | skin_viewport->hidden_flags = VP_DRAW_HIDEABLE; |
866 | } | 866 | } |
867 | 867 | ||
868 | display->set_viewport_ex(&skin_viewport->vp, VP_FLAG_VP_SET_CLEAN); | 868 | display->set_viewport_ex(&skin_viewport->vp, VP_FLAG_VP_SET_CLEAN); |
869 | 869 | ||
870 | if ((vp_refresh_mode&SKIN_REFRESH_ALL) == SKIN_REFRESH_ALL) | 870 | if ((vp_refresh_mode&SKIN_REFRESH_ALL) == SKIN_REFRESH_ALL) |
@@ -929,17 +929,17 @@ void skin_render_playlistviewer(struct playlistviewer* viewer, | |||
929 | else | 929 | else |
930 | #endif | 930 | #endif |
931 | { | 931 | { |
932 | struct cuesheet *cue = skin_get_global_state()->id3 ? | 932 | struct cuesheet *cue = skin_get_global_state()->id3 ? |
933 | skin_get_global_state()->id3->cuesheet : NULL; | 933 | skin_get_global_state()->id3->cuesheet : NULL; |
934 | cur_pos = playlist_get_display_index(); | 934 | cur_pos = playlist_get_display_index(); |
935 | max = playlist_amount()+1; | 935 | max = playlist_amount()+1; |
936 | if (cue) | 936 | if (cue) |
937 | max += cue->track_count; | 937 | max += cue->track_count; |
938 | start_item = MAX(0, cur_pos + viewer->start_offset); | 938 | start_item = MAX(0, cur_pos + viewer->start_offset); |
939 | } | 939 | } |
940 | if (max-start_item > nb_lines) | 940 | if (max-start_item > nb_lines) |
941 | max = start_item + nb_lines; | 941 | max = start_item + nb_lines; |
942 | 942 | ||
943 | line = SKINOFFSETTOPTR(skin_buffer, viewer->line); | 943 | line = SKINOFFSETTOPTR(skin_buffer, viewer->line); |
944 | while (start_item < max) | 944 | while (start_item < max) |
945 | { | 945 | { |
@@ -947,20 +947,20 @@ void skin_render_playlistviewer(struct playlistviewer* viewer, | |||
947 | info.no_line_break = false; | 947 | info.no_line_break = false; |
948 | info.line_scrolls = false; | 948 | info.line_scrolls = false; |
949 | info.force_redraw = false; | 949 | info.force_redraw = false; |
950 | 950 | ||
951 | info.cur_align_start = info.buf; | 951 | info.cur_align_start = info.buf; |
952 | align->left = info.buf; | 952 | align->left = info.buf; |
953 | align->center = NULL; | 953 | align->center = NULL; |
954 | align->right = NULL; | 954 | align->right = NULL; |
955 | 955 | ||
956 | 956 | ||
957 | if (line->type == LINE_ALTERNATOR) | 957 | if (line->type == LINE_ALTERNATOR) |
958 | func = skin_render_alternator; | 958 | func = skin_render_alternator; |
959 | else if (line->type == LINE) | 959 | else if (line->type == LINE) |
960 | func = skin_render_line; | 960 | func = skin_render_line; |
961 | 961 | ||
962 | needs_update = func(line, &info); | 962 | needs_update = func(line, &info); |
963 | 963 | ||
964 | /* only update if the line needs to be, and there is something to write */ | 964 | /* only update if the line needs to be, and there is something to write */ |
965 | if (refresh_type && needs_update) | 965 | if (refresh_type && needs_update) |
966 | { | 966 | { |