summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2012-02-29 00:07:16 +1100
committerJonathan Gordon <rockbox@jdgordon.info>2012-02-29 00:14:06 +1100
commit1c1e1c070cf965f83a53c5d1390ca04bcd9aa80d (patch)
treeff8a5b8f2472672d9ef15d644343631224ce7be4
parent34031cba5bddcc29dee0f61b3ea6ee1529014181 (diff)
downloadrockbox-1c1e1c070cf965f83a53c5d1390ca04bcd9aa80d.tar.gz
rockbox-1c1e1c070cf965f83a53c5d1390ca04bcd9aa80d.zip
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
-rw-r--r--apps/gui/skin_engine/skin_parser.c35
-rw-r--r--lib/skin_parser/tag_table.c4
-rw-r--r--manual/appendix/wps_tags.tex12
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,
387{ 387{
388 const char* filename; 388 const char* filename;
389 const char* id; 389 const char* id;
390 int x,y; 390 int x = 0,y = 0, subimages = 1;
391 struct gui_img *img; 391 struct gui_img *img;
392 392
393 /* format: %x(n,filename.bmp,x,y) 393 /* format: %x(n,filename.bmp[,x,y])
394 or %xl(n,filename.bmp,x,y) 394 or %xl(n,filename.bmp[,x,y])
395 or %xl(n,filename.bmp,x,y,num_subimages) 395 or %xl(n,filename.bmp[,x,y,num_subimages])
396 */ 396 */
397 397
398 id = get_param_text(element, 0); 398 id = get_param_text(element, 0);
399 filename = get_param_text(element, 1); 399 filename = get_param_text(element, 1);
400 x = get_param(element, 2)->data.number; 400 /* x,y,num_subimages handling:
401 y = get_param(element, 3)->data.number; 401 * If all 3 are left out use sane defaults.
402 402 * If there are 2 params it must be x,y
403 * if there is only 1 param it must be the num_subimages
404 */
405 if (element->params_count == 3)
406 subimages = get_param(element, 2)->data.number;
407 else if (element->params_count > 3)
408 {
409 x = get_param(element, 2)->data.number;
410 y = get_param(element, 3)->data.number;
411 if (element->params_count == 5)
412 subimages = get_param(element, 4)->data.number;
413 }
403 /* check the image number and load state */ 414 /* check the image number and load state */
404 if(skin_find_item(id, SKIN_FIND_IMAGE, wps_data)) 415 if(skin_find_item(id, SKIN_FIND_IMAGE, wps_data))
405 { 416 {
@@ -414,7 +425,7 @@ static int parse_image_load(struct skin_element *element,
414 img->label = PTRTOSKINOFFSET(skin_buffer, (void*)id); 425 img->label = PTRTOSKINOFFSET(skin_buffer, (void*)id);
415 img->x = x; 426 img->x = x;
416 img->y = y; 427 img->y = y;
417 img->num_subimages = 1; 428 img->num_subimages = subimages;
418 img->display = -1; 429 img->display = -1;
419 img->using_preloaded_icons = false; 430 img->using_preloaded_icons = false;
420 img->buflib_handle = -1; 431 img->buflib_handle = -1;
@@ -423,15 +434,7 @@ static int parse_image_load(struct skin_element *element,
423 img->vp = PTRTOSKINOFFSET(skin_buffer, &curr_vp->vp); 434 img->vp = PTRTOSKINOFFSET(skin_buffer, &curr_vp->vp);
424 435
425 if (token->type == SKIN_TOKEN_IMAGE_DISPLAY) 436 if (token->type == SKIN_TOKEN_IMAGE_DISPLAY)
426 {
427 token->value.data = PTRTOSKINOFFSET(skin_buffer, img); 437 token->value.data = PTRTOSKINOFFSET(skin_buffer, img);
428 }
429 else if (element->params_count == 5)
430 {
431 img->num_subimages = get_param(element, 4)->data.number;
432 if (img->num_subimages <= 0)
433 return WPS_ERROR_INVALID_PARAM;
434 }
435 438
436 if (!strcmp(img->bm.data, "__list_icons__")) 439 if (!strcmp(img->bm.data, "__list_icons__"))
437 { 440 {
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[] =
176 { SKIN_TOKEN_DISABLE_THEME, "wd", "", 0|NOBREAK }, 176 { SKIN_TOKEN_DISABLE_THEME, "wd", "", 0|NOBREAK },
177 { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|NOBREAK }, 177 { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|NOBREAK },
178 178
179 { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SFII|I", 0|NOBREAK }, 179 { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SF|III", 0|NOBREAK },
180 { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S|[IT]I", 0 }, 180 { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S|[IT]I", 0 },
181 { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SFII", SKIN_REFRESH_STATIC|NOBREAK }, 181 { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SF|II", SKIN_REFRESH_STATIC|NOBREAK },
182 182
183 { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF|I", 0|NOBREAK }, 183 { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF|I", 0|NOBREAK },
184 { SKIN_TOKEN_ALBUMART_LOAD, "Cl" , "IIII|ss", 0|NOBREAK }, 184 { 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:
369 & Load and set a backdrop image for the WPS. 369 & Load and set a backdrop image for the WPS.
370 This image must be exactly the same size as your LCD.\\ 370 This image must be exactly the same size as your LCD.\\
371 }% 371 }%
372 \config{\%x(n,filename,x,y)} 372 \config{\%x(n,filename[,x,y])}
373 & Load and display an image\newline 373 & Load and display an image\newline
374 \config{n}: image ID (a-z and A-Z) for later referencing in \config{\%xd}\newline 374 \config{n}: image ID (a-z and A-Z) for later referencing in \config{\%xd}\newline
375 \config{filename}: file name relative to \fname{/.rockbox/} and including ``.bmp''\newline 375 \config{filename}: file name relative to \fname{/.rockbox/} and including ``.bmp''\newline
376 \config{x}: x coordinate\newline 376 \config{x}: x coordinate (defaults to 0 if both x and y are not specified)\newline
377 \config{y}: y coordinate.\\ 377 \config{y}: y coordinate. (defaults to 0 if both x and y are not specified)\\
378 \config{\%xl(n,filename,x,y,\tabnlindent[nimages])} 378 \config{\%xl(n,filename,[x,y],\tabnlindent[nimages])}
379 & Preload an image for later display (useful for when your images are displayed conditionally).\newline 379 & Preload an image for later display (useful for when your images are displayed conditionally).\newline
380 \config{n}: image ID (a-z and A-Z) for later referencing in \config{\%xd}\newline 380 \config{n}: image ID (a-z and A-Z) for later referencing in \config{\%xd}\newline
381 \config{filename}: file name relative to \fname{/.rockbox/} and including ``.bmp''\newline 381 \config{filename}: file name relative to \fname{/.rockbox/} and including ``.bmp''\newline
382 If the filename is ``\_\_list\_icons\_\_'' the list icon bitmap will be used instead\newline 382 If the filename is ``\_\_list\_icons\_\_'' the list icon bitmap will be used instead\newline
383 \config{x}: x coordinate\newline 383 \config{x}: x coordinate (defaults to 0 if both x and y are not specified)\newline
384 \config{y}: y coordinate\newline 384 \config{y}: y coordinate. (defaults to 0 if both x and y are not specified)\\
385 \config{nimages}: (optional) number of sub-images (tiled vertically, of the same height) 385 \config{nimages}: (optional) number of sub-images (tiled vertically, of the same height)
386 contained in the bitmap. Default is 1.\\ 386 contained in the bitmap. Default is 1.\\
387 \config{\%xd(n[i] [,tag] [,offset])} & Display a preloaded image. 387 \config{\%xd(n[i] [,tag] [,offset])} & Display a preloaded image.