diff options
author | Dave Chapman <dave@dchapman.com> | 2008-03-23 20:31:00 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2008-03-23 20:31:00 +0000 |
commit | 15ddd7a7ec2aa92767234e37907904309943a27b (patch) | |
tree | 5dff9b41fe0b8948c85c3eda66c62ffe780cb4a7 /apps/gui/wps_parser.c | |
parent | b8b03370e4a3e1ec20324e9055065c77873e30f7 (diff) | |
download | rockbox-15ddd7a7ec2aa92767234e37907904309943a27b.tar.gz rockbox-15ddd7a7ec2aa92767234e37907904309943a27b.zip |
Add the ability to use bitmap strips (a single .bmp file containing many images of the same dimensions, tiled vertically - similar to icon strips) in the WPS. The %xl tag now has an optional "number of subimages" parameter, and the %xd tag has an optional "subimage to display" parameter (a-z,A-Z - allowing up to 52 sub-images). So for example, a bitmap with 10 subimages is loaded with %xl|M|volume.bmp|134|153|10| and then this can be used in a conditional as %?pv<%xdMa|%xdMb|%xdMc|%xdMd|%xdMe|%xdMf|%xdMg|%xdMh|%xdMi|%xdMj>.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16764 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/wps_parser.c')
-rw-r--r-- | apps/gui/wps_parser.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index eb4b1087e3..d5e29f3a4f 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -432,7 +432,8 @@ static int parse_image_display(const char *wps_bufptr, | |||
432 | struct wps_data *wps_data) | 432 | struct wps_data *wps_data) |
433 | { | 433 | { |
434 | (void)wps_data; | 434 | (void)wps_data; |
435 | int n = get_image_id(*wps_bufptr); | 435 | int n = get_image_id(wps_bufptr[0]); |
436 | int subimage; | ||
436 | 437 | ||
437 | if (n == -1) | 438 | if (n == -1) |
438 | { | 439 | { |
@@ -440,9 +441,15 @@ static int parse_image_display(const char *wps_bufptr, | |||
440 | return WPS_ERROR_INVALID_PARAM; | 441 | return WPS_ERROR_INVALID_PARAM; |
441 | } | 442 | } |
442 | 443 | ||
443 | token->value.i = n; | 444 | if ((subimage = get_image_id(wps_bufptr[1])) != -1) |
444 | 445 | { | |
445 | return 1; | 446 | /* Store sub-image number to display in high bits */ |
447 | token->value.i = n | (subimage << 8); | ||
448 | return 2; /* We have consumed 2 bytes */ | ||
449 | } else { | ||
450 | token->value.i = n; | ||
451 | return 1; /* We have consumed 1 byte */ | ||
452 | } | ||
446 | } | 453 | } |
447 | 454 | ||
448 | static int parse_image_load(const char *wps_bufptr, | 455 | static int parse_image_load(const char *wps_bufptr, |
@@ -451,12 +458,16 @@ static int parse_image_load(const char *wps_bufptr, | |||
451 | { | 458 | { |
452 | int n; | 459 | int n; |
453 | const char *ptr = wps_bufptr; | 460 | const char *ptr = wps_bufptr; |
461 | const char *pos; | ||
454 | const char* filename; | 462 | const char* filename; |
455 | const char* id; | 463 | const char* id; |
464 | const char *newline; | ||
456 | int x,y; | 465 | int x,y; |
457 | 466 | ||
458 | /* format: %x|n|filename.bmp|x|y| | 467 | /* format: %x|n|filename.bmp|x|y| |
459 | or %xl|n|filename.bmp|x|y| */ | 468 | or %xl|n|filename.bmp|x|y| |
469 | or %xl|n|filename.bmp|x|y|num_subimages| | ||
470 | */ | ||
460 | 471 | ||
461 | if (*ptr != '|') | 472 | if (*ptr != '|') |
462 | return WPS_ERROR_INVALID_PARAM; | 473 | return WPS_ERROR_INVALID_PARAM; |
@@ -490,7 +501,18 @@ static int parse_image_load(const char *wps_bufptr, | |||
490 | wps_data->img[n].vp = &wps_data->viewports[wps_data->num_viewports].vp; | 501 | wps_data->img[n].vp = &wps_data->viewports[wps_data->num_viewports].vp; |
491 | 502 | ||
492 | if (token->type == WPS_TOKEN_IMAGE_DISPLAY) | 503 | if (token->type == WPS_TOKEN_IMAGE_DISPLAY) |
504 | { | ||
493 | wps_data->img[n].always_display = true; | 505 | wps_data->img[n].always_display = true; |
506 | } | ||
507 | else | ||
508 | { | ||
509 | /* Parse the (optional) number of sub-images */ | ||
510 | ptr++; | ||
511 | newline = strchr(ptr, '\n'); | ||
512 | pos = strchr(ptr, '|'); | ||
513 | if (pos && pos < newline) | ||
514 | wps_data->img[n].num_subimages = atoi(ptr); | ||
515 | } | ||
494 | 516 | ||
495 | /* Skip the rest of the line */ | 517 | /* Skip the rest of the line */ |
496 | return skip_end_of_line(wps_bufptr); | 518 | return skip_end_of_line(wps_bufptr); |
@@ -1283,8 +1305,9 @@ static void wps_images_clear(struct wps_data *data) | |||
1283 | for (i = 0; i < MAX_IMAGES; i++) | 1305 | for (i = 0; i < MAX_IMAGES; i++) |
1284 | { | 1306 | { |
1285 | data->img[i].loaded = false; | 1307 | data->img[i].loaded = false; |
1286 | data->img[i].display = false; | 1308 | data->img[i].display = -1; |
1287 | data->img[i].always_display = false; | 1309 | data->img[i].always_display = false; |
1310 | data->img[i].num_subimages = 1; | ||
1288 | } | 1311 | } |
1289 | data->progressbar.have_bitmap_pb = false; | 1312 | data->progressbar.have_bitmap_pb = false; |
1290 | } | 1313 | } |
@@ -1357,6 +1380,11 @@ static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) | |||
1357 | if (load_bitmap(wps_data, img_path, bitmap)) | 1380 | if (load_bitmap(wps_data, img_path, bitmap)) |
1358 | { | 1381 | { |
1359 | *loaded = true; | 1382 | *loaded = true; |
1383 | |||
1384 | /* Calculate and store height if this image has sub-images */ | ||
1385 | if (n < MAX_IMAGES) | ||
1386 | wps_data->img[n].subimage_height = wps_data->img[n].bm.height / | ||
1387 | wps_data->img[n].num_subimages; | ||
1360 | } | 1388 | } |
1361 | } | 1389 | } |
1362 | } | 1390 | } |