From 91ef65306bf4e459f430d6dc44e5923d6b9f8399 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Fri, 20 Dec 2013 23:34:28 +0100 Subject: skin_engine: Adapt put_line(). This allows for code unification and removal of a workaround (STYLE_XY_PIXELS). Change-Id: Ie92d377414cad943cdb06976af10b4f315f32710 --- apps/gui/skin_engine/skin_display.c | 53 +++++++++---------------------------- apps/gui/skin_engine/skin_display.h | 2 +- apps/gui/skin_engine/skin_parser.c | 16 ++++++----- apps/gui/skin_engine/skin_render.c | 48 +++++++++++++++++++++------------ 4 files changed, 54 insertions(+), 65 deletions(-) (limited to 'apps/gui') 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 @@ #include "settings.h" #include "scrollbar.h" #include "screen_access.h" +#include "line.h" #include "playlist.h" #include "audio.h" #include "tagcache.h" @@ -393,11 +394,8 @@ int evaluate_conditional(struct gui_wps *gwps, int offset, scroll indicates whether the line is a scrolling one or not. */ void write_line(struct screen *display, struct align_pos *format_align, - int line, bool scroll, unsigned style) + int line, bool scroll, struct line_desc *linedes) { -#ifndef HAVE_LCD_BITMAP - (void)style; -#endif int left_width = 0; int center_width = 0, center_xpos; int right_width = 0, right_xpos; @@ -511,16 +509,12 @@ void write_line(struct screen *display, struct align_pos *format_align, (center_width > scroll_width) || (right_width > scroll_width))) { -#ifdef HAVE_LCD_BITMAP - display->puts_scroll_style(0, line, - (unsigned char *)format_align->left, style); -#else - display->puts_scroll(0, line, - (unsigned char *)format_align->left); -#endif + linedes->scroll = true; + display->put_line(0, line * string_height, linedes, (unsigned char *)format_align->left); } else { + linedes->scroll = false; #ifdef HAVE_LCD_BITMAP /* clear the line first */ display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); @@ -532,42 +526,19 @@ void write_line(struct screen *display, struct align_pos *format_align, which will reset the scroller for that line */ display->puts_scroll(0, line, (unsigned char *)""); #ifdef HAVE_LCD_BITMAP - style |= STYLE_XY_PIXELS; line *= string_height; + center_xpos = (viewport_width-center_width)/2; + right_xpos = viewport_width-right_width; +#endif /* print aligned strings */ if (left_width != 0) - { - display->puts_style_xyoffset(0, line, - (unsigned char *)format_align->left, style, 0, 0); + display->put_line(0, line, linedes, format_align->left); - } if (center_width != 0) - { - display->puts_style_xyoffset((viewport_width-center_width)/2, line, - (unsigned char *)format_align->center, style, 0, 0); - } - if (right_width != 0) - { - display->puts_style_xyoffset(viewport_width-right_width, line, - (unsigned char *)format_align->right, style, 0, 0); - } -#else - if (left_width != 0) - { - display->putsxy(0, line, - (unsigned char *)format_align->left); - } - if (center_width != 0) - { - display->putsxy(center_xpos, line, - (unsigned char *)format_align->center); - } + display->put_line(center_xpos, line, linedes, format_align->center); + if (right_width != 0) - { - display->putsxy(right_xpos, line, - (unsigned char *)format_align->right); - } -#endif + display->put_line(right_xpos, line, linedes, format_align->right); } } 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, scroll indicates whether the line is a scrolling one or not. */ void write_line(struct screen *display, struct align_pos *format_align, - int line, bool scroll, unsigned style); + int line, bool scroll, struct line_desc *line_desc); void draw_peakmeters(struct gui_wps *gwps, int line_number, struct viewport *viewport); #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, struct wps_data *wps_data) { (void)wps_data; - int style; char *mode = get_param_text(element, 0); + struct line_desc *line = skin_buffer_alloc(sizeof(*line)); + *line = (struct line_desc)LINE_DESC_DEFINIT; unsigned colour; if (!strcmp(mode, "invert")) { - style = STYLE_INVERT; + line->style = STYLE_INVERT; } else if (!strcmp(mode, "colour") || !strcmp(mode, "color")) { if (element->params_count < 2 || !parse_color(curr_screen, get_param_text(element, 1), &colour)) return 1; - style = STYLE_COLORED|(STYLE_COLOR_MASK&colour); + line->style = STYLE_COLORED; + line->text_color = colour; } #ifdef HAVE_LCD_COLOR else if (!strcmp(mode, "gradient")) @@ -614,16 +616,18 @@ static int parse_viewporttextstyle(struct skin_element *element, * will select the number for something which looks like a colour * making the "colour" case (above) harder to parse */ num_lines = atoi(get_param_text(element, 1)); - style = STYLE_GRADIENT|NUMLN_PACK(num_lines)|CURLN_PACK(0); + line->style = STYLE_GRADIENT; + line->nlines = num_lines; } #endif else if (!strcmp(mode, "clear")) { - style = STYLE_DEFAULT; + line->style = STYLE_DEFAULT; } else return 1; - token->value.l = style; + + token->value.data = PTRTOSKINOFFSET(skin_buffer, line); return 0; } 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 { struct skin_viewport *skin_vp; int line_number; unsigned long refresh_type; - unsigned text_style; + struct line_desc line_desc; char* cur_align_start; struct align_pos align; @@ -105,6 +105,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, #ifdef HAVE_LCD_BITMAP struct wps_data *data = gwps->data; bool do_refresh = (element->tag->flags & info->refresh_type) > 0; + struct line_desc *linedes = &info->line_desc; #endif switch (token->type) { @@ -124,16 +125,33 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, } break; case SKIN_TOKEN_VIEWPORT_TEXTSTYLE: - info->text_style = token->value.l; - break; + { + struct line_desc *data = SKINOFFSETTOPTR(skin_buffer, token->value.data); + /* gradient colors are handled with a separate tag + * (SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP, see below). since it may + * come before the text style tag color fields need to be preserved */ + if (data->style & STYLE_GRADIENT) + { + fb_data tc = linedes->text_color, + lc = linedes->line_color, + lec = linedes->line_end_color; + *linedes = *data; + linedes->text_color = tc; + linedes->line_color = lc; + linedes->line_end_color = lec; + } + else + *linedes = *data; + } + break; #endif #ifdef HAVE_LCD_COLOR case SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP: { struct gradient_config *cfg = SKINOFFSETTOPTR(skin_buffer, token->value.data); - vp->lss_pattern = cfg->start; - vp->lse_pattern = cfg->end; - vp->lst_pattern = cfg->text; + linedes->text_color = cfg->text; + linedes->line_color = cfg->start; + linedes->line_end_color = cfg->end; } break; #endif @@ -713,7 +731,7 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps, .refresh_type = refresh_type, .skin_vp = skin_viewport, .offset = 0, - .text_style = STYLE_DEFAULT + .line_desc = LINE_DESC_DEFINIT, }; struct align_pos * align = &info.align; @@ -742,14 +760,10 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps, info.line_scrolls = false; info.force_redraw = false; #ifdef HAVE_LCD_COLOR - if (info.text_style&STYLE_GRADIENT) + if (info.line_desc.style&STYLE_GRADIENT) { - int cur = CURLN_UNPACK(info.text_style); - int num = NUMLN_UNPACK(info.text_style); - if (cur+1 == num) - info.text_style = STYLE_DEFAULT; - else - info.text_style = STYLE_GRADIENT|CURLN_PACK(cur+1)|NUMLN_PACK(num); + if (++info.line_desc.line > info.line_desc.nlines) + info.line_desc.style = STYLE_DEFAULT; } #endif info.cur_align_start = info.buf; @@ -783,7 +797,7 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps, 0, info.line_number*display->getcharheight(), skin_viewport->vp.width, display->getcharheight()); write_line(display, align, info.line_number, - info.line_scrolls, info.text_style); + info.line_scrolls, &info.line_desc); } if (!info.no_line_break) info.line_number++; @@ -917,7 +931,7 @@ void skin_render_playlistviewer(struct playlistviewer* viewer, .refresh_type = refresh_type, .skin_vp = skin_viewport, .offset = viewer->start_offset, - .text_style = STYLE_DEFAULT + .line_desc = LINE_DESC_DEFINIT, }; struct align_pos * align = &info.align; @@ -975,7 +989,7 @@ void skin_render_playlistviewer(struct playlistviewer* viewer, 0, info.line_number*display->getcharheight(), vp->width, display->getcharheight()); write_line(display, align, info.line_number, - info.line_scrolls, info.text_style); + info.line_scrolls, &info.line_desc); } info.line_number++; info.offset++; -- cgit v1.2.3