diff options
author | Thomas Martitz <kugel@rockbox.org> | 2013-12-20 23:34:28 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2014-01-07 14:13:40 +0100 |
commit | 91ef65306bf4e459f430d6dc44e5923d6b9f8399 (patch) | |
tree | fefdfa516c8b061371f7a79ed22647aaec1a1922 | |
parent | eec89a90ffdd077d687914fe18a9e48028f07fb4 (diff) | |
download | rockbox-91ef65306bf4e459f430d6dc44e5923d6b9f8399.tar.gz rockbox-91ef65306bf4e459f430d6dc44e5923d6b9f8399.zip |
skin_engine: Adapt put_line().
This allows for code unification and removal of a workaround (STYLE_XY_PIXELS).
Change-Id: Ie92d377414cad943cdb06976af10b4f315f32710
-rwxr-xr-x | apps/gui/skin_engine/skin_display.c | 53 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_display.h | 2 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 16 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_render.c | 48 |
4 files changed, 54 insertions, 65 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index c33e38392d..c2ede75e16 100755 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include "settings.h" | 40 | #include "settings.h" |
41 | #include "scrollbar.h" | 41 | #include "scrollbar.h" |
42 | #include "screen_access.h" | 42 | #include "screen_access.h" |
43 | #include "line.h" | ||
43 | #include "playlist.h" | 44 | #include "playlist.h" |
44 | #include "audio.h" | 45 | #include "audio.h" |
45 | #include "tagcache.h" | 46 | #include "tagcache.h" |
@@ -393,11 +394,8 @@ int evaluate_conditional(struct gui_wps *gwps, int offset, | |||
393 | scroll indicates whether the line is a scrolling one or not. | 394 | scroll indicates whether the line is a scrolling one or not. |
394 | */ | 395 | */ |
395 | void write_line(struct screen *display, struct align_pos *format_align, | 396 | void write_line(struct screen *display, struct align_pos *format_align, |
396 | int line, bool scroll, unsigned style) | 397 | int line, bool scroll, struct line_desc *linedes) |
397 | { | 398 | { |
398 | #ifndef HAVE_LCD_BITMAP | ||
399 | (void)style; | ||
400 | #endif | ||
401 | int left_width = 0; | 399 | int left_width = 0; |
402 | int center_width = 0, center_xpos; | 400 | int center_width = 0, center_xpos; |
403 | int right_width = 0, right_xpos; | 401 | int right_width = 0, right_xpos; |
@@ -511,16 +509,12 @@ void write_line(struct screen *display, struct align_pos *format_align, | |||
511 | (center_width > scroll_width) || | 509 | (center_width > scroll_width) || |
512 | (right_width > scroll_width))) | 510 | (right_width > scroll_width))) |
513 | { | 511 | { |
514 | #ifdef HAVE_LCD_BITMAP | 512 | linedes->scroll = true; |
515 | display->puts_scroll_style(0, line, | 513 | display->put_line(0, line * string_height, linedes, (unsigned char *)format_align->left); |
516 | (unsigned char *)format_align->left, style); | ||
517 | #else | ||
518 | display->puts_scroll(0, line, | ||
519 | (unsigned char *)format_align->left); | ||
520 | #endif | ||
521 | } | 514 | } |
522 | else | 515 | else |
523 | { | 516 | { |
517 | linedes->scroll = false; | ||
524 | #ifdef HAVE_LCD_BITMAP | 518 | #ifdef HAVE_LCD_BITMAP |
525 | /* clear the line first */ | 519 | /* clear the line first */ |
526 | display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 520 | display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
@@ -532,42 +526,19 @@ void write_line(struct screen *display, struct align_pos *format_align, | |||
532 | which will reset the scroller for that line */ | 526 | which will reset the scroller for that line */ |
533 | display->puts_scroll(0, line, (unsigned char *)""); | 527 | display->puts_scroll(0, line, (unsigned char *)""); |
534 | #ifdef HAVE_LCD_BITMAP | 528 | #ifdef HAVE_LCD_BITMAP |
535 | style |= STYLE_XY_PIXELS; | ||
536 | line *= string_height; | 529 | line *= string_height; |
530 | center_xpos = (viewport_width-center_width)/2; | ||
531 | right_xpos = viewport_width-right_width; | ||
532 | #endif | ||
537 | /* print aligned strings */ | 533 | /* print aligned strings */ |
538 | if (left_width != 0) | 534 | if (left_width != 0) |
539 | { | 535 | display->put_line(0, line, linedes, format_align->left); |
540 | display->puts_style_xyoffset(0, line, | ||
541 | (unsigned char *)format_align->left, style, 0, 0); | ||
542 | 536 | ||
543 | } | ||
544 | if (center_width != 0) | 537 | if (center_width != 0) |
545 | { | 538 | display->put_line(center_xpos, line, linedes, format_align->center); |
546 | display->puts_style_xyoffset((viewport_width-center_width)/2, line, | 539 | |
547 | (unsigned char *)format_align->center, style, 0, 0); | ||
548 | } | ||
549 | if (right_width != 0) | ||
550 | { | ||
551 | display->puts_style_xyoffset(viewport_width-right_width, line, | ||
552 | (unsigned char *)format_align->right, style, 0, 0); | ||
553 | } | ||
554 | #else | ||
555 | if (left_width != 0) | ||
556 | { | ||
557 | display->putsxy(0, line, | ||
558 | (unsigned char *)format_align->left); | ||
559 | } | ||
560 | if (center_width != 0) | ||
561 | { | ||
562 | display->putsxy(center_xpos, line, | ||
563 | (unsigned char *)format_align->center); | ||
564 | } | ||
565 | if (right_width != 0) | 540 | if (right_width != 0) |
566 | { | 541 | display->put_line(right_xpos, line, linedes, format_align->right); |
567 | display->putsxy(right_xpos, line, | ||
568 | (unsigned char *)format_align->right); | ||
569 | } | ||
570 | #endif | ||
571 | } | 542 | } |
572 | } | 543 | } |
573 | 544 | ||
diff --git a/apps/gui/skin_engine/skin_display.h b/apps/gui/skin_engine/skin_display.h index b3422b0360..01a2169952 100644 --- a/apps/gui/skin_engine/skin_display.h +++ b/apps/gui/skin_engine/skin_display.h | |||
@@ -53,7 +53,7 @@ int evaluate_conditional(struct gui_wps *gwps, int offset, | |||
53 | scroll indicates whether the line is a scrolling one or not. | 53 | scroll indicates whether the line is a scrolling one or not. |
54 | */ | 54 | */ |
55 | void write_line(struct screen *display, struct align_pos *format_align, | 55 | void write_line(struct screen *display, struct align_pos *format_align, |
56 | int line, bool scroll, unsigned style); | 56 | int line, bool scroll, struct line_desc *line_desc); |
57 | void draw_peakmeters(struct gui_wps *gwps, int line_number, | 57 | void draw_peakmeters(struct gui_wps *gwps, int line_number, |
58 | struct viewport *viewport); | 58 | struct viewport *viewport); |
59 | #endif | 59 | #endif |
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 3238c48c63..1945bfbc57 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -589,20 +589,22 @@ static int parse_viewporttextstyle(struct skin_element *element, | |||
589 | struct wps_data *wps_data) | 589 | struct wps_data *wps_data) |
590 | { | 590 | { |
591 | (void)wps_data; | 591 | (void)wps_data; |
592 | int style; | ||
593 | char *mode = get_param_text(element, 0); | 592 | char *mode = get_param_text(element, 0); |
593 | struct line_desc *line = skin_buffer_alloc(sizeof(*line)); | ||
594 | *line = (struct line_desc)LINE_DESC_DEFINIT; | ||
594 | unsigned colour; | 595 | unsigned colour; |
595 | 596 | ||
596 | if (!strcmp(mode, "invert")) | 597 | if (!strcmp(mode, "invert")) |
597 | { | 598 | { |
598 | style = STYLE_INVERT; | 599 | line->style = STYLE_INVERT; |
599 | } | 600 | } |
600 | else if (!strcmp(mode, "colour") || !strcmp(mode, "color")) | 601 | else if (!strcmp(mode, "colour") || !strcmp(mode, "color")) |
601 | { | 602 | { |
602 | if (element->params_count < 2 || | 603 | if (element->params_count < 2 || |
603 | !parse_color(curr_screen, get_param_text(element, 1), &colour)) | 604 | !parse_color(curr_screen, get_param_text(element, 1), &colour)) |
604 | return 1; | 605 | return 1; |
605 | style = STYLE_COLORED|(STYLE_COLOR_MASK&colour); | 606 | line->style = STYLE_COLORED; |
607 | line->text_color = colour; | ||
606 | } | 608 | } |
607 | #ifdef HAVE_LCD_COLOR | 609 | #ifdef HAVE_LCD_COLOR |
608 | else if (!strcmp(mode, "gradient")) | 610 | else if (!strcmp(mode, "gradient")) |
@@ -614,16 +616,18 @@ static int parse_viewporttextstyle(struct skin_element *element, | |||
614 | * will select the number for something which looks like a colour | 616 | * will select the number for something which looks like a colour |
615 | * making the "colour" case (above) harder to parse */ | 617 | * making the "colour" case (above) harder to parse */ |
616 | num_lines = atoi(get_param_text(element, 1)); | 618 | num_lines = atoi(get_param_text(element, 1)); |
617 | style = STYLE_GRADIENT|NUMLN_PACK(num_lines)|CURLN_PACK(0); | 619 | line->style = STYLE_GRADIENT; |
620 | line->nlines = num_lines; | ||
618 | } | 621 | } |
619 | #endif | 622 | #endif |
620 | else if (!strcmp(mode, "clear")) | 623 | else if (!strcmp(mode, "clear")) |
621 | { | 624 | { |
622 | style = STYLE_DEFAULT; | 625 | line->style = STYLE_DEFAULT; |
623 | } | 626 | } |
624 | else | 627 | else |
625 | return 1; | 628 | return 1; |
626 | token->value.l = style; | 629 | |
630 | token->value.data = PTRTOSKINOFFSET(skin_buffer, line); | ||
627 | return 0; | 631 | return 0; |
628 | } | 632 | } |
629 | 633 | ||
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index d95b769fa3..f40c3b90e0 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c | |||
@@ -59,7 +59,7 @@ struct skin_draw_info { | |||
59 | struct skin_viewport *skin_vp; | 59 | struct skin_viewport *skin_vp; |
60 | int line_number; | 60 | int line_number; |
61 | unsigned long refresh_type; | 61 | unsigned long refresh_type; |
62 | unsigned text_style; | 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; |
@@ -105,6 +105,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, | |||
105 | #ifdef HAVE_LCD_BITMAP | 105 | #ifdef HAVE_LCD_BITMAP |
106 | struct wps_data *data = gwps->data; | 106 | struct wps_data *data = gwps->data; |
107 | bool do_refresh = (element->tag->flags & info->refresh_type) > 0; | 107 | bool do_refresh = (element->tag->flags & info->refresh_type) > 0; |
108 | struct line_desc *linedes = &info->line_desc; | ||
108 | #endif | 109 | #endif |
109 | switch (token->type) | 110 | switch (token->type) |
110 | { | 111 | { |
@@ -124,16 +125,33 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, | |||
124 | } | 125 | } |
125 | break; | 126 | break; |
126 | case SKIN_TOKEN_VIEWPORT_TEXTSTYLE: | 127 | case SKIN_TOKEN_VIEWPORT_TEXTSTYLE: |
127 | info->text_style = token->value.l; | 128 | { |
128 | break; | 129 | struct line_desc *data = SKINOFFSETTOPTR(skin_buffer, token->value.data); |
130 | /* gradient colors are handled with a separate tag | ||
131 | * (SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP, see below). since it may | ||
132 | * come before the text style tag color fields need to be preserved */ | ||
133 | if (data->style & STYLE_GRADIENT) | ||
134 | { | ||
135 | fb_data tc = linedes->text_color, | ||
136 | lc = linedes->line_color, | ||
137 | lec = linedes->line_end_color; | ||
138 | *linedes = *data; | ||
139 | linedes->text_color = tc; | ||
140 | linedes->line_color = lc; | ||
141 | linedes->line_end_color = lec; | ||
142 | } | ||
143 | else | ||
144 | *linedes = *data; | ||
145 | } | ||
146 | break; | ||
129 | #endif | 147 | #endif |
130 | #ifdef HAVE_LCD_COLOR | 148 | #ifdef HAVE_LCD_COLOR |
131 | case SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP: | 149 | case SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP: |
132 | { | 150 | { |
133 | struct gradient_config *cfg = SKINOFFSETTOPTR(skin_buffer, token->value.data); | 151 | struct gradient_config *cfg = SKINOFFSETTOPTR(skin_buffer, token->value.data); |
134 | vp->lss_pattern = cfg->start; | 152 | linedes->text_color = cfg->text; |
135 | vp->lse_pattern = cfg->end; | 153 | linedes->line_color = cfg->start; |
136 | vp->lst_pattern = cfg->text; | 154 | linedes->line_end_color = cfg->end; |
137 | } | 155 | } |
138 | break; | 156 | break; |
139 | #endif | 157 | #endif |
@@ -713,7 +731,7 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps, | |||
713 | .refresh_type = refresh_type, | 731 | .refresh_type = refresh_type, |
714 | .skin_vp = skin_viewport, | 732 | .skin_vp = skin_viewport, |
715 | .offset = 0, | 733 | .offset = 0, |
716 | .text_style = STYLE_DEFAULT | 734 | .line_desc = LINE_DESC_DEFINIT, |
717 | }; | 735 | }; |
718 | 736 | ||
719 | struct align_pos * align = &info.align; | 737 | struct align_pos * align = &info.align; |
@@ -742,14 +760,10 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps, | |||
742 | info.line_scrolls = false; | 760 | info.line_scrolls = false; |
743 | info.force_redraw = false; | 761 | info.force_redraw = false; |
744 | #ifdef HAVE_LCD_COLOR | 762 | #ifdef HAVE_LCD_COLOR |
745 | if (info.text_style&STYLE_GRADIENT) | 763 | if (info.line_desc.style&STYLE_GRADIENT) |
746 | { | 764 | { |
747 | int cur = CURLN_UNPACK(info.text_style); | 765 | if (++info.line_desc.line > info.line_desc.nlines) |
748 | int num = NUMLN_UNPACK(info.text_style); | 766 | info.line_desc.style = STYLE_DEFAULT; |
749 | if (cur+1 == num) | ||
750 | info.text_style = STYLE_DEFAULT; | ||
751 | else | ||
752 | info.text_style = STYLE_GRADIENT|CURLN_PACK(cur+1)|NUMLN_PACK(num); | ||
753 | } | 767 | } |
754 | #endif | 768 | #endif |
755 | info.cur_align_start = info.buf; | 769 | info.cur_align_start = info.buf; |
@@ -783,7 +797,7 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps, | |||
783 | 0, info.line_number*display->getcharheight(), | 797 | 0, info.line_number*display->getcharheight(), |
784 | skin_viewport->vp.width, display->getcharheight()); | 798 | skin_viewport->vp.width, display->getcharheight()); |
785 | write_line(display, align, info.line_number, | 799 | write_line(display, align, info.line_number, |
786 | info.line_scrolls, info.text_style); | 800 | info.line_scrolls, &info.line_desc); |
787 | } | 801 | } |
788 | if (!info.no_line_break) | 802 | if (!info.no_line_break) |
789 | info.line_number++; | 803 | info.line_number++; |
@@ -917,7 +931,7 @@ void skin_render_playlistviewer(struct playlistviewer* viewer, | |||
917 | .refresh_type = refresh_type, | 931 | .refresh_type = refresh_type, |
918 | .skin_vp = skin_viewport, | 932 | .skin_vp = skin_viewport, |
919 | .offset = viewer->start_offset, | 933 | .offset = viewer->start_offset, |
920 | .text_style = STYLE_DEFAULT | 934 | .line_desc = LINE_DESC_DEFINIT, |
921 | }; | 935 | }; |
922 | 936 | ||
923 | struct align_pos * align = &info.align; | 937 | struct align_pos * align = &info.align; |
@@ -975,7 +989,7 @@ void skin_render_playlistviewer(struct playlistviewer* viewer, | |||
975 | 0, info.line_number*display->getcharheight(), | 989 | 0, info.line_number*display->getcharheight(), |
976 | vp->width, display->getcharheight()); | 990 | vp->width, display->getcharheight()); |
977 | write_line(display, align, info.line_number, | 991 | write_line(display, align, info.line_number, |
978 | info.line_scrolls, info.text_style); | 992 | info.line_scrolls, &info.line_desc); |
979 | } | 993 | } |
980 | info.line_number++; | 994 | info.line_number++; |
981 | info.offset++; | 995 | info.offset++; |