diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2012-02-29 00:07:16 +1100 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2012-02-29 00:14:06 +1100 |
commit | 1c1e1c070cf965f83a53c5d1390ca04bcd9aa80d (patch) | |
tree | ff8a5b8f2472672d9ef15d644343631224ce7be4 /apps/gui/skin_engine/skin_parser.c | |
parent | 34031cba5bddcc29dee0f61b3ea6ee1529014181 (diff) | |
download | rockbox-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
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 35 |
1 files changed, 19 insertions, 16 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 | { |