From 1c1e1c070cf965f83a53c5d1390ca04bcd9aa80d Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Wed, 29 Feb 2012 00:07:16 +1100 Subject: skin_engine: ease the restrictions on %x/%xl %x and %xl only require the id and filename now. If you leave off the x,y it will default to 0,0. If you want to use the default x,y you can still put in the num_subimages param on the end (e.g %xl(a, file, 3) ) Change-Id: I8eff793dfdd037e302ace8deec9dc16dcea264a7 --- apps/gui/skin_engine/skin_parser.c | 35 +++++++++++++++++++---------------- lib/skin_parser/tag_table.c | 4 ++-- manual/appendix/wps_tags.tex | 12 ++++++------ 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 3b83d9e199..4e4b9d14d2 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -387,19 +387,30 @@ static int parse_image_load(struct skin_element *element, { const char* filename; const char* id; - int x,y; + int x = 0,y = 0, subimages = 1; struct gui_img *img; - /* format: %x(n,filename.bmp,x,y) - or %xl(n,filename.bmp,x,y) - or %xl(n,filename.bmp,x,y,num_subimages) + /* format: %x(n,filename.bmp[,x,y]) + or %xl(n,filename.bmp[,x,y]) + or %xl(n,filename.bmp[,x,y,num_subimages]) */ id = get_param_text(element, 0); filename = get_param_text(element, 1); - x = get_param(element, 2)->data.number; - y = get_param(element, 3)->data.number; - + /* x,y,num_subimages handling: + * If all 3 are left out use sane defaults. + * If there are 2 params it must be x,y + * if there is only 1 param it must be the num_subimages + */ + if (element->params_count == 3) + subimages = get_param(element, 2)->data.number; + else if (element->params_count > 3) + { + x = get_param(element, 2)->data.number; + y = get_param(element, 3)->data.number; + if (element->params_count == 5) + subimages = get_param(element, 4)->data.number; + } /* check the image number and load state */ if(skin_find_item(id, SKIN_FIND_IMAGE, wps_data)) { @@ -414,7 +425,7 @@ static int parse_image_load(struct skin_element *element, img->label = PTRTOSKINOFFSET(skin_buffer, (void*)id); img->x = x; img->y = y; - img->num_subimages = 1; + img->num_subimages = subimages; img->display = -1; img->using_preloaded_icons = false; img->buflib_handle = -1; @@ -423,15 +434,7 @@ static int parse_image_load(struct skin_element *element, img->vp = PTRTOSKINOFFSET(skin_buffer, &curr_vp->vp); if (token->type == SKIN_TOKEN_IMAGE_DISPLAY) - { token->value.data = PTRTOSKINOFFSET(skin_buffer, img); - } - else if (element->params_count == 5) - { - img->num_subimages = get_param(element, 4)->data.number; - if (img->num_subimages <= 0) - return WPS_ERROR_INVALID_PARAM; - } if (!strcmp(img->bm.data, "__list_icons__")) { diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c index e4b8bb1bf9..47a0abb046 100644 --- a/lib/skin_parser/tag_table.c +++ b/lib/skin_parser/tag_table.c @@ -176,9 +176,9 @@ static const struct tag_info legal_tags[] = { SKIN_TOKEN_DISABLE_THEME, "wd", "", 0|NOBREAK }, { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|NOBREAK }, - { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SFII|I", 0|NOBREAK }, + { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SF|III", 0|NOBREAK }, { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S|[IT]I", 0 }, - { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SFII", SKIN_REFRESH_STATIC|NOBREAK }, + { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SF|II", SKIN_REFRESH_STATIC|NOBREAK }, { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF|I", 0|NOBREAK }, { SKIN_TOKEN_ALBUMART_LOAD, "Cl" , "IIII|ss", 0|NOBREAK }, diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index 5890e20e93..baea29a516 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex @@ -369,19 +369,19 @@ Examples: & Load and set a backdrop image for the WPS. This image must be exactly the same size as your LCD.\\ }% - \config{\%x(n,filename,x,y)} + \config{\%x(n,filename[,x,y])} & Load and display an image\newline \config{n}: image ID (a-z and A-Z) for later referencing in \config{\%xd}\newline \config{filename}: file name relative to \fname{/.rockbox/} and including ``.bmp''\newline - \config{x}: x coordinate\newline - \config{y}: y coordinate.\\ - \config{\%xl(n,filename,x,y,\tabnlindent[nimages])} + \config{x}: x coordinate (defaults to 0 if both x and y are not specified)\newline + \config{y}: y coordinate. (defaults to 0 if both x and y are not specified)\\ + \config{\%xl(n,filename,[x,y],\tabnlindent[nimages])} & Preload an image for later display (useful for when your images are displayed conditionally).\newline \config{n}: image ID (a-z and A-Z) for later referencing in \config{\%xd}\newline \config{filename}: file name relative to \fname{/.rockbox/} and including ``.bmp''\newline If the filename is ``\_\_list\_icons\_\_'' the list icon bitmap will be used instead\newline - \config{x}: x coordinate\newline - \config{y}: y coordinate\newline + \config{x}: x coordinate (defaults to 0 if both x and y are not specified)\newline + \config{y}: y coordinate. (defaults to 0 if both x and y are not specified)\\ \config{nimages}: (optional) number of sub-images (tiled vertically, of the same height) contained in the bitmap. Default is 1.\\ \config{\%xd(n[i] [,tag] [,offset])} & Display a preloaded image. -- cgit v1.2.3