skin_engine: Adapt put_line().

This allows for code unification and removal of a workaround (STYLE_XY_PIXELS).

Change-Id: Ie92d377414cad943cdb06976af10b4f315f32710
This commit is contained in:
Thomas Martitz 2013-12-20 23:34:28 +01:00
parent eec89a90ff
commit 91ef65306b
4 changed files with 54 additions and 65 deletions

View file

@ -40,6 +40,7 @@
#include "settings.h" #include "settings.h"
#include "scrollbar.h" #include "scrollbar.h"
#include "screen_access.h" #include "screen_access.h"
#include "line.h"
#include "playlist.h" #include "playlist.h"
#include "audio.h" #include "audio.h"
#include "tagcache.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. scroll indicates whether the line is a scrolling one or not.
*/ */
void write_line(struct screen *display, struct align_pos *format_align, 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 left_width = 0;
int center_width = 0, center_xpos; int center_width = 0, center_xpos;
int right_width = 0, right_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) || (center_width > scroll_width) ||
(right_width > scroll_width))) (right_width > scroll_width)))
{ {
#ifdef HAVE_LCD_BITMAP linedes->scroll = true;
display->puts_scroll_style(0, line, display->put_line(0, line * string_height, linedes, (unsigned char *)format_align->left);
(unsigned char *)format_align->left, style);
#else
display->puts_scroll(0, line,
(unsigned char *)format_align->left);
#endif
} }
else else
{ {
linedes->scroll = false;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* clear the line first */ /* clear the line first */
display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 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 */ which will reset the scroller for that line */
display->puts_scroll(0, line, (unsigned char *)""); display->puts_scroll(0, line, (unsigned char *)"");
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
style |= STYLE_XY_PIXELS;
line *= string_height; line *= string_height;
center_xpos = (viewport_width-center_width)/2;
right_xpos = viewport_width-right_width;
#endif
/* print aligned strings */ /* print aligned strings */
if (left_width != 0) if (left_width != 0)
{ display->put_line(0, line, linedes, format_align->left);
display->puts_style_xyoffset(0, line,
(unsigned char *)format_align->left, style, 0, 0);
}
if (center_width != 0) if (center_width != 0)
{ display->put_line(center_xpos, line, linedes, format_align->center);
display->puts_style_xyoffset((viewport_width-center_width)/2, line,
(unsigned char *)format_align->center, style, 0, 0);
}
if (right_width != 0) if (right_width != 0)
{ display->put_line(right_xpos, line, linedes, format_align->right);
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);
}
if (right_width != 0)
{
display->putsxy(right_xpos, line,
(unsigned char *)format_align->right);
}
#endif
} }
} }

View file

@ -53,7 +53,7 @@ int evaluate_conditional(struct gui_wps *gwps, int offset,
scroll indicates whether the line is a scrolling one or not. scroll indicates whether the line is a scrolling one or not.
*/ */
void write_line(struct screen *display, struct align_pos *format_align, 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, void draw_peakmeters(struct gui_wps *gwps, int line_number,
struct viewport *viewport); struct viewport *viewport);
#endif #endif

View file

@ -589,20 +589,22 @@ static int parse_viewporttextstyle(struct skin_element *element,
struct wps_data *wps_data) struct wps_data *wps_data)
{ {
(void)wps_data; (void)wps_data;
int style;
char *mode = get_param_text(element, 0); 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; unsigned colour;
if (!strcmp(mode, "invert")) if (!strcmp(mode, "invert"))
{ {
style = STYLE_INVERT; line->style = STYLE_INVERT;
} }
else if (!strcmp(mode, "colour") || !strcmp(mode, "color")) else if (!strcmp(mode, "colour") || !strcmp(mode, "color"))
{ {
if (element->params_count < 2 || if (element->params_count < 2 ||
!parse_color(curr_screen, get_param_text(element, 1), &colour)) !parse_color(curr_screen, get_param_text(element, 1), &colour))
return 1; return 1;
style = STYLE_COLORED|(STYLE_COLOR_MASK&colour); line->style = STYLE_COLORED;
line->text_color = colour;
} }
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
else if (!strcmp(mode, "gradient")) 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 * will select the number for something which looks like a colour
* making the "colour" case (above) harder to parse */ * making the "colour" case (above) harder to parse */
num_lines = atoi(get_param_text(element, 1)); 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 #endif
else if (!strcmp(mode, "clear")) else if (!strcmp(mode, "clear"))
{ {
style = STYLE_DEFAULT; line->style = STYLE_DEFAULT;
} }
else else
return 1; return 1;
token->value.l = style;
token->value.data = PTRTOSKINOFFSET(skin_buffer, line);
return 0; return 0;
} }

View file

@ -59,7 +59,7 @@ struct skin_draw_info {
struct skin_viewport *skin_vp; struct skin_viewport *skin_vp;
int line_number; int line_number;
unsigned long refresh_type; unsigned long refresh_type;
unsigned text_style; struct line_desc line_desc;
char* cur_align_start; char* cur_align_start;
struct align_pos align; 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 #ifdef HAVE_LCD_BITMAP
struct wps_data *data = gwps->data; struct wps_data *data = gwps->data;
bool do_refresh = (element->tag->flags & info->refresh_type) > 0; bool do_refresh = (element->tag->flags & info->refresh_type) > 0;
struct line_desc *linedes = &info->line_desc;
#endif #endif
switch (token->type) switch (token->type)
{ {
@ -124,16 +125,33 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
} }
break; break;
case SKIN_TOKEN_VIEWPORT_TEXTSTYLE: 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 #endif
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
case SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP: case SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP:
{ {
struct gradient_config *cfg = SKINOFFSETTOPTR(skin_buffer, token->value.data); struct gradient_config *cfg = SKINOFFSETTOPTR(skin_buffer, token->value.data);
vp->lss_pattern = cfg->start; linedes->text_color = cfg->text;
vp->lse_pattern = cfg->end; linedes->line_color = cfg->start;
vp->lst_pattern = cfg->text; linedes->line_end_color = cfg->end;
} }
break; break;
#endif #endif
@ -713,7 +731,7 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps,
.refresh_type = refresh_type, .refresh_type = refresh_type,
.skin_vp = skin_viewport, .skin_vp = skin_viewport,
.offset = 0, .offset = 0,
.text_style = STYLE_DEFAULT .line_desc = LINE_DESC_DEFINIT,
}; };
struct align_pos * align = &info.align; 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.line_scrolls = false;
info.force_redraw = false; info.force_redraw = false;
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
if (info.text_style&STYLE_GRADIENT) if (info.line_desc.style&STYLE_GRADIENT)
{ {
int cur = CURLN_UNPACK(info.text_style); if (++info.line_desc.line > info.line_desc.nlines)
int num = NUMLN_UNPACK(info.text_style); info.line_desc.style = STYLE_DEFAULT;
if (cur+1 == num)
info.text_style = STYLE_DEFAULT;
else
info.text_style = STYLE_GRADIENT|CURLN_PACK(cur+1)|NUMLN_PACK(num);
} }
#endif #endif
info.cur_align_start = info.buf; 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(), 0, info.line_number*display->getcharheight(),
skin_viewport->vp.width, display->getcharheight()); skin_viewport->vp.width, display->getcharheight());
write_line(display, align, info.line_number, write_line(display, align, info.line_number,
info.line_scrolls, info.text_style); info.line_scrolls, &info.line_desc);
} }
if (!info.no_line_break) if (!info.no_line_break)
info.line_number++; info.line_number++;
@ -917,7 +931,7 @@ void skin_render_playlistviewer(struct playlistviewer* viewer,
.refresh_type = refresh_type, .refresh_type = refresh_type,
.skin_vp = skin_viewport, .skin_vp = skin_viewport,
.offset = viewer->start_offset, .offset = viewer->start_offset,
.text_style = STYLE_DEFAULT .line_desc = LINE_DESC_DEFINIT,
}; };
struct align_pos * align = &info.align; struct align_pos * align = &info.align;
@ -975,7 +989,7 @@ void skin_render_playlistviewer(struct playlistviewer* viewer,
0, info.line_number*display->getcharheight(), 0, info.line_number*display->getcharheight(),
vp->width, display->getcharheight()); vp->width, display->getcharheight());
write_line(display, align, info.line_number, write_line(display, align, info.line_number,
info.line_scrolls, info.text_style); info.line_scrolls, &info.line_desc);
} }
info.line_number++; info.line_number++;
info.offset++; info.offset++;