From 5a169bb71707dae31a886e1b932341b70eacf2df Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Mon, 23 Jun 2008 06:04:17 +0000 Subject: commit FS#9027 - conditional viewports ** BREAKS CURRENT WPS's ** * %P has been removed, merged with the new %pb * %pb is now %pb or %pb|bitmap|x|y|width|height| (any of those params can be - to use sane defaults... check wiki/task for more explaination) * New %Vl and %Vd tags which are used to setup and display conditionaly displayed viewports (%Vl||| to set up, then %Vd to enable the viewport * bumps the max allowed viewport count to 24 * you can setup 3 different progressbars in a WPS... max of one per viewport though http://www.rockbox.org/tracker/task/9027?getfile=16785 is a simple perl script to convert old %P/%pb to the new %pb syntax I'll commit changes to the cabbie wps soon which shows how to use %Vl/%Vd properly... Reminder: %m will be removed soonish also so when fixing your WPS's remember to use conditional viewports to replace %m git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17759 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/wps_parser.c | 178 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 126 insertions(+), 52 deletions(-) (limited to 'apps/gui/wps_parser.c') diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 53605e27cc..dc9abd98fb 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -80,13 +80,13 @@ static int line; #ifdef HAVE_LCD_BITMAP #if LCD_DEPTH > 1 -#define MAX_BITMAPS (MAX_IMAGES+2) /* WPS images + pbar bitmap + backdrop */ +#define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS+1) /* WPS images + pbar bitmap + backdrop */ #else -#define MAX_BITMAPS (MAX_IMAGES+1) /* WPS images + pbar bitmap */ +#define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS) /* WPS images + pbar bitmap */ #endif #define PROGRESSBAR_BMP MAX_IMAGES -#define BACKDROP_BMP (MAX_IMAGES+1) +#define BACKDROP_BMP (MAX_BITMAPS-1) /* pointers to the bitmap filenames in the WPS source */ static const char *bmp_names[MAX_BITMAPS]; @@ -129,6 +129,8 @@ static int parse_dir_level(const char *wps_bufptr, 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, @@ -317,13 +319,14 @@ static const struct wps_tag all_tags[] = { parse_image_display }, { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, - { WPS_TOKEN_IMAGE_PROGRESS_BAR, "P", 0, parse_image_special }, #ifdef HAVE_ALBUMART { WPS_NO_TOKEN, "Cl", 0, parse_albumart_load }, { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC, parse_albumart_conditional }, #endif + { WPS_VIEWPORT_ENABLE, "Vd", WPS_REFRESH_DYNAMIC, + parse_viewport_display }, { WPS_NO_TOKEN, "V", 0, parse_viewport }, #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) @@ -536,6 +539,22 @@ static int parse_image_load(const char *wps_bufptr, 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]; + + if (letter < 'a' || letter > 'z') + { + /* invalid viewport tag */ + return WPS_ERROR_INVALID_PARAM; + } + token->value.i = letter; + return 1; +} + static int parse_viewport(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data) @@ -563,17 +582,35 @@ static int parse_viewport(const char *wps_bufptr, } #endif - if (*wps_bufptr != '|') - return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */ - - ptr = wps_bufptr + 1; - /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ - if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS) return WPS_ERROR_INVALID_PARAM; - + wps_data->num_viewports++; + /* check for the optional letter to signify its a hideable viewport */ + /* %Vl|