From fe72cbe6accbffe394d012974d7ccae299d22d8c Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Mon, 7 Jun 2010 11:45:02 +0000 Subject: Fix FS#11370 - BEWARE when useing viewport colours. %Vf() and %Vb() need to be straight after the %V() or else the colours wont be set on the viewport (but on the line instead). This means scrolling lines dont work. To make sure the colours are used for the whole viewport dont leave any gaps between %V and %Vf/%Vb. (of course, if you want a single line to be a different colour then use the %Vf as normal. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26656 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_parser.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index ece172e1de..45500c5408 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -1026,6 +1026,8 @@ static int parse_viewportcolour(const char *wps_bufptr, { (void)wps_data; const char *ptr = wps_bufptr; + int i; + bool found_text; struct viewport_colour *colour = skin_buffer_alloc(sizeof(struct viewport_colour)); uint32_t set; if (*ptr != '(' || !colour) @@ -1040,6 +1042,31 @@ static int parse_viewportcolour(const char *wps_bufptr, token->type == WPS_TOKEN_VIEWPORT_FGCOLOUR); colour->vp = &curr_vp->vp; token->value.data = colour; + /* If there havnt been any text tags between the %V() line and here use + * the colour as the viewport colour. fixes scrolling lines not + * having the correct colour */ + i = curr_vp->lines->sublines.first_token_idx; + found_text = false; + while (!found_text && i< curr_vp->lines->sublines.last_token_idx) + { + if (wps_data->tokens[i++].type != WPS_TOKEN_CHARACTER && + wps_data->tokens[i++].type != WPS_TOKEN_VIEWPORT_FGCOLOUR && + wps_data->tokens[i++].type != WPS_TOKEN_VIEWPORT_BGCOLOUR ) + found_text = true; + } + if (!found_text) + { + if (token->type == WPS_TOKEN_VIEWPORT_FGCOLOUR) + { + curr_vp->start_fgcolour = colour->colour; + curr_vp->vp.fg_pattern = colour->colour; + } + else + { + curr_vp->start_bgcolour = colour->colour; + curr_vp->vp.bg_pattern = colour->colour; + } + } ptr++; return ptr - wps_bufptr; } -- cgit