Index: apps/gui/gwps-common.c =================================================================== --- apps/gui/gwps-common.c (revision 17621) +++ apps/gui/gwps-common.c (working copy) @@ -1608,7 +1608,14 @@ *buf++ = 0; cur_align_start = buf; break; - + case WPS_VIEWPORT_ENABLE: + { + char temp = VP_DRAW_HIDEABLE; + if (data->viewports[data->tokens[i].value.i].hidden_type&VP_DRAW_WASHIDDEN) + temp |= VP_DRAW_WASHIDDEN; + data->viewports[data->tokens[i].value.i].hidden_type = temp; + } + break; default: { /* get the value of the tag and copy it to the buffer */ @@ -1932,6 +1939,7 @@ int v, line, i, subline_idx; unsigned char flags; char linebuf[MAX_PATH]; + unsigned char called_refresh_mode = refresh_mode; struct align_pos align; align.left = NULL; @@ -1981,15 +1989,22 @@ state->ff_rewind_count = ffwd_offset; + /* disable any viewports which are conditionally displayed */ for (v = 0; v < data->num_viewports; v++) { - display->set_viewport(&data->viewports[v].vp); - - if (refresh_mode == WPS_REFRESH_ALL) + if (data->viewports[v].hidden_type&VP_DRAW_HIDEABLE) { - display->clear_viewport(); + if (data->viewports[v].hidden_type&VP_DRAW_HIDDEN) + data->viewports[v].hidden_type |= VP_DRAW_WASHIDDEN; + else + data->viewports[v].hidden_type |= VP_DRAW_HIDDEN; } + } + for (v = 0; v < data->num_viewports; v++) + { + display->set_viewport(&data->viewports[v].vp); + #ifdef HAVE_LCD_BITMAP /* Set images to not to be displayed */ for (i = 0; i < MAX_IMAGES; i++) @@ -1997,7 +2012,27 @@ data->img[i].display = -1; } #endif - + /* dont redraw the viewport if its disabled */ + if ((data->viewports[v].hidden_type&VP_DRAW_HIDDEN)) + { + if (!(data->viewports[v].hidden_type&VP_DRAW_WASHIDDEN)) + display->scroll_stop(&data->viewports[v].vp); + data->viewports[v].hidden_type |= VP_DRAW_WASHIDDEN; + continue; + } + else if ((((data->viewports[v].hidden_type&VP_DRAW_HIDDEN) == 0) && + (data->viewports[v].hidden_type&(VP_DRAW_WASHIDDEN|VP_DRAW_HIDEABLE)) + == (VP_DRAW_WASHIDDEN|VP_DRAW_HIDEABLE))) + { + refresh_mode = WPS_REFRESH_ALL; + data->viewports[v].hidden_type = VP_DRAW_HIDEABLE; + } + + if (refresh_mode == WPS_REFRESH_ALL) + { + display->clear_viewport(); + } + for (line = data->viewports[v].first_line; line <= data->viewports[v].last_line; line++) { @@ -2074,6 +2109,7 @@ else write_line(display, &align, line - data->viewports[v].first_line, false); } + refresh_mode = called_refresh_mode; } Index: apps/gui/wps_debug.c =================================================================== --- apps/gui/wps_debug.c (revision 17621) +++ apps/gui/wps_debug.c (working copy) @@ -431,6 +431,10 @@ snprintf(buf, bufsize, "pitch value"); break; #endif + case WPS_VIEWPORT_ENABLE: + snprintf(buf, bufsize, "enable VP:%d", + token->value.i); + break; default: snprintf(buf, bufsize, "FIXME (code: %d)", Index: apps/gui/wps_parser.c =================================================================== --- apps/gui/wps_parser.c (revision 17621) +++ apps/gui/wps_parser.c (working copy) @@ -129,6 +129,8 @@ struct wps_token *token, struct wps_data *wps_data); #ifdef HAVE_LCD_BITMAP +static int parse_viewport_display(const char *wps_bufptr, + struct wps_token *token, struct wps_data *wps_data); static int parse_viewport(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data); static int parse_leftmargin(const char *wps_bufptr, @@ -324,6 +326,8 @@ parse_albumart_conditional }, #endif + { WPS_VIEWPORT_ENABLE, "Ve", WPS_REFRESH_STATIC, + parse_viewport_display }, { WPS_NO_TOKEN, "V", 0, parse_viewport }, #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) @@ -536,6 +540,27 @@ return skip_end_of_line(wps_bufptr); } +static int parse_viewport_display(const char *wps_bufptr, + struct wps_token *token, + struct wps_data *wps_data) +{ + (void)wps_data; + char letter = wps_bufptr[0]; + int i; + + if (letter < 'a' || letter > ('a' + WPS_MAX_VIEWPORTS)) + { + /* invalid viewport tag */ + return WPS_ERROR_INVALID_PARAM; + } + + /* for these to work, this tag needs to be before %V + so set token->value.i to the letter and change that + to the viewports index when its loaded */ + token->value.i = letter; + return 1; +} + static int parse_viewport(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data) @@ -543,6 +568,7 @@ const char *ptr = wps_bufptr; struct viewport* vp; int depth; + char letter; (void)token; /* Kill warnings */ @@ -550,7 +576,7 @@ return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */ ptr = wps_bufptr + 1; - /* format: %V|x|y|width|height|fg_pattern|bg_pattern| */ + /* format: %V|x|y|width|height|fg_pattern|bg_pattern| */ if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS) return WPS_ERROR_INVALID_PARAM; @@ -630,6 +656,24 @@ return WPS_ERROR_INVALID_PARAM; } } + /* check for the optional letter to signify its a hideable viewport */ + wps_data->viewports[wps_data->num_viewports].hidden_type = 0; + if (*(ptr + 1) >= 'a' && *(ptr + 1) < 'a' + WPS_MAX_VIEWPORTS && + *(ptr + 2 ) == '|') + { + /* try to bind this viewport to a %Ve tag */ + int i; + for (i=0; inum_tokens;i++) + { + if (wps_data->tokens[i].type == WPS_VIEWPORT_ENABLE && + wps_data->tokens[i].value.i == *(ptr + 1)) + { + wps_data->tokens[i].value.i = wps_data->num_viewports; + wps_data->viewports[wps_data->num_viewports].hidden_type = VP_DRAW_HIDEABLE; + break; + } + } + } wps_data->viewports[wps_data->num_viewports-1].last_line = wps_data->num_lines - 1; Index: apps/gui/gwps.h =================================================================== --- apps/gui/gwps.h (revision 17621) +++ apps/gui/gwps.h (working copy) @@ -271,8 +271,11 @@ #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) /* Virtual LED */ - WPS_TOKEN_VLED_HDD + WPS_TOKEN_VLED_HDD, #endif + + /* Viewport display */ + WPS_VIEWPORT_ENABLE }; struct wps_token { @@ -323,12 +326,16 @@ long subline_expire_time; }; +#define VP_DRAW_HIDEABLE 0x1 +#define VP_DRAW_HIDDEN 0x2 +#define VP_DRAW_WASHIDDEN 0x4 struct wps_viewport { struct viewport vp; /* The LCD viewport struct */ /* Indexes of the first and last lines belonging to this viewport in the lines[] array */ int first_line, last_line; + char hidden_type; }; /* wps_data