From 3be3a4013829a5d088904803bdd26e339eea61f0 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Thu, 9 Jan 2014 17:42:47 +0100 Subject: put_line: Be more careful with changing fg and bg colors. put_line() needs to change fore- and background colors if required by the line style. This should really only be done if required, and be undone as to not compromise subsequent lines. This fixes %Vf and %Vb skin tags. Change-Id: I85e5a0d1d64aa9eb76a891d9ce1de1320274a69a --- apps/gui/line.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'apps/gui/line.c') diff --git a/apps/gui/line.c b/apps/gui/line.c index c06fc50f26..5a376c652c 100644 --- a/apps/gui/line.c +++ b/apps/gui/line.c @@ -306,7 +306,8 @@ static void style_line(struct screen *display, break; } #if (LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1)) - /* fg color and bg color are left as-is for text drawing */ + /* prepare fg and bg colors for text drawing, be careful to not + * override any previously set colors unless mandated by the style */ if (display->depth > 1) { if (style & STYLE_COLORED) @@ -318,8 +319,6 @@ static void style_line(struct screen *display, } else if (style & (STYLE_GRADIENT|STYLE_COLORBAR)) display->set_foreground(line->text_color); - else - display->set_foreground(get_viewport_default_colour(display->screen_type, true)); } #endif } @@ -329,11 +328,23 @@ void vput_line(struct screen *display, int x, int y, struct line_desc *line, const char *fmt, va_list ap) { +#if (LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1)) + /* push and pop fg and bg colors as to not compromise unrelated lines */ + unsigned fg = 0, bg = 0; /* shut up gcc */ + if (display->depth > 1 && line->style > STYLE_INVERT) + { + fg = display->get_foreground(); + bg = display->get_background(); + } +#endif style_line(display, x, y, line); print_line(display, x, y, line, fmt, ap); #if (LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1)) - if (display->depth > 1) - display->set_foreground(get_viewport_default_colour(display->screen_type, true)); + if (display->depth > 1 && line->style > STYLE_INVERT) + { + display->set_foreground(fg); + display->set_background(bg); + } #endif display->set_drawmode(DRMODE_SOLID); } -- cgit v1.2.3