mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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
This commit is contained in:
parent
34031cba5b
commit
1c1e1c070c
3 changed files with 27 additions and 24 deletions
|
@ -387,19 +387,30 @@ static int parse_image_load(struct skin_element *element,
|
||||||
{
|
{
|
||||||
const char* filename;
|
const char* filename;
|
||||||
const char* id;
|
const char* id;
|
||||||
int x,y;
|
int x = 0,y = 0, subimages = 1;
|
||||||
struct gui_img *img;
|
struct gui_img *img;
|
||||||
|
|
||||||
/* format: %x(n,filename.bmp,x,y)
|
/* format: %x(n,filename.bmp[,x,y])
|
||||||
or %xl(n,filename.bmp,x,y)
|
or %xl(n,filename.bmp[,x,y])
|
||||||
or %xl(n,filename.bmp,x,y,num_subimages)
|
or %xl(n,filename.bmp[,x,y,num_subimages])
|
||||||
*/
|
*/
|
||||||
|
|
||||||
id = get_param_text(element, 0);
|
id = get_param_text(element, 0);
|
||||||
filename = get_param_text(element, 1);
|
filename = get_param_text(element, 1);
|
||||||
x = get_param(element, 2)->data.number;
|
/* x,y,num_subimages handling:
|
||||||
y = get_param(element, 3)->data.number;
|
* 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 */
|
/* check the image number and load state */
|
||||||
if(skin_find_item(id, SKIN_FIND_IMAGE, wps_data))
|
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->label = PTRTOSKINOFFSET(skin_buffer, (void*)id);
|
||||||
img->x = x;
|
img->x = x;
|
||||||
img->y = y;
|
img->y = y;
|
||||||
img->num_subimages = 1;
|
img->num_subimages = subimages;
|
||||||
img->display = -1;
|
img->display = -1;
|
||||||
img->using_preloaded_icons = false;
|
img->using_preloaded_icons = false;
|
||||||
img->buflib_handle = -1;
|
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);
|
img->vp = PTRTOSKINOFFSET(skin_buffer, &curr_vp->vp);
|
||||||
|
|
||||||
if (token->type == SKIN_TOKEN_IMAGE_DISPLAY)
|
if (token->type == SKIN_TOKEN_IMAGE_DISPLAY)
|
||||||
{
|
|
||||||
token->value.data = PTRTOSKINOFFSET(skin_buffer, img);
|
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__"))
|
if (!strcmp(img->bm.data, "__list_icons__"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -176,9 +176,9 @@ static const struct tag_info legal_tags[] =
|
||||||
{ SKIN_TOKEN_DISABLE_THEME, "wd", "", 0|NOBREAK },
|
{ SKIN_TOKEN_DISABLE_THEME, "wd", "", 0|NOBREAK },
|
||||||
{ SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|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_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_LOAD_FONT, "Fl" , "IF|I", 0|NOBREAK },
|
||||||
{ SKIN_TOKEN_ALBUMART_LOAD, "Cl" , "IIII|ss", 0|NOBREAK },
|
{ SKIN_TOKEN_ALBUMART_LOAD, "Cl" , "IIII|ss", 0|NOBREAK },
|
||||||
|
|
|
@ -369,19 +369,19 @@ Examples:
|
||||||
& Load and set a backdrop image for the WPS.
|
& Load and set a backdrop image for the WPS.
|
||||||
This image must be exactly the same size as your LCD.\\
|
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
|
& Load and display an image\newline
|
||||||
\config{n}: image ID (a-z and A-Z) for later referencing in \config{\%xd}\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{filename}: file name relative to \fname{/.rockbox/} and including ``.bmp''\newline
|
||||||
\config{x}: x coordinate\newline
|
\config{x}: x coordinate (defaults to 0 if both x and y are not specified)\newline
|
||||||
\config{y}: y coordinate.\\
|
\config{y}: y coordinate. (defaults to 0 if both x and y are not specified)\\
|
||||||
\config{\%xl(n,filename,x,y,\tabnlindent[nimages])}
|
\config{\%xl(n,filename,[x,y],\tabnlindent[nimages])}
|
||||||
& Preload an image for later display (useful for when your images are displayed conditionally).\newline
|
& 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{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{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
|
If the filename is ``\_\_list\_icons\_\_'' the list icon bitmap will be used instead\newline
|
||||||
\config{x}: x coordinate\newline
|
\config{x}: x coordinate (defaults to 0 if both x and y are not specified)\newline
|
||||||
\config{y}: y coordinate\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)
|
\config{nimages}: (optional) number of sub-images (tiled vertically, of the same height)
|
||||||
contained in the bitmap. Default is 1.\\
|
contained in the bitmap. Default is 1.\\
|
||||||
\config{\%xd(n[i] [,tag] [,offset])} & Display a preloaded image.
|
\config{\%xd(n[i] [,tag] [,offset])} & Display a preloaded image.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue