summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-03-23 20:31:00 +0000
committerDave Chapman <dave@dchapman.com>2008-03-23 20:31:00 +0000
commit15ddd7a7ec2aa92767234e37907904309943a27b (patch)
tree5dff9b41fe0b8948c85c3eda66c62ffe780cb4a7
parentb8b03370e4a3e1ec20324e9055065c77873e30f7 (diff)
downloadrockbox-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
-rw-r--r--apps/gui/gwps-common.c43
-rw-r--r--apps/gui/gwps.h4
-rw-r--r--apps/gui/wps_parser.c40
3 files changed, 63 insertions, 24 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 744f86e42a..37b2b7c5d1 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -516,11 +516,11 @@ static void clear_image_pos(struct gui_wps *gwps, int n)
516 struct wps_data *data = gwps->data; 516 struct wps_data *data = gwps->data;
517 gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 517 gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
518 gwps->display->fillrect(data->img[n].x, data->img[n].y, 518 gwps->display->fillrect(data->img[n].x, data->img[n].y,
519 data->img[n].bm.width, data->img[n].bm.height); 519 data->img[n].bm.width, data->img[n].subimage_height);
520 gwps->display->set_drawmode(DRMODE_SOLID); 520 gwps->display->set_drawmode(DRMODE_SOLID);
521} 521}
522 522
523static void wps_draw_image(struct gui_wps *gwps, int n) 523static void wps_draw_image(struct gui_wps *gwps, int n, int subimage)
524{ 524{
525 struct screen *display = gwps->display; 525 struct screen *display = gwps->display;
526 struct wps_data *data = gwps->data; 526 struct wps_data *data = gwps->data;
@@ -532,15 +532,18 @@ static void wps_draw_image(struct gui_wps *gwps, int n)
532#if LCD_DEPTH > 1 532#if LCD_DEPTH > 1
533 if(data->img[n].bm.format == FORMAT_MONO) { 533 if(data->img[n].bm.format == FORMAT_MONO) {
534#endif 534#endif
535 display->mono_bitmap(data->img[n].bm.data, data->img[n].x, 535 display->mono_bitmap_part(data->img[n].bm.data,
536 data->img[n].y, data->img[n].bm.width, 536 0, data->img[n].subimage_height * subimage,
537 data->img[n].bm.height); 537 data->img[n].bm.width, data->img[n].x,
538 data->img[n].y, data->img[n].bm.width,
539 data->img[n].subimage_height);
538#if LCD_DEPTH > 1 540#if LCD_DEPTH > 1
539 } else { 541 } else {
540 display->transparent_bitmap((fb_data *)data->img[n].bm.data, 542 display->transparent_bitmap_part((fb_data *)data->img[n].bm.data,
541 data->img[n].x, 543 0, data->img[n].subimage_height * subimage,
542 data->img[n].y, data->img[n].bm.width, 544 data->img[n].bm.width, data->img[n].x,
543 data->img[n].bm.height); 545 data->img[n].y, data->img[n].bm.width,
546 data->img[n].subimage_height);
544 } 547 }
545#endif 548#endif
546} 549}
@@ -556,11 +559,15 @@ static void wps_display_images(struct gui_wps *gwps, struct viewport* vp)
556 559
557 for (n = 0; n < MAX_IMAGES; n++) 560 for (n = 0; n < MAX_IMAGES; n++)
558 { 561 {
559 if (data->img[n].loaded && 562 if (data->img[n].loaded)
560 (data->img[n].display ||
561 (data->img[n].always_display && data->img[n].vp == vp)))
562 { 563 {
563 wps_draw_image(gwps, n); 564 if (data->img[n].display >= 0)
565 {
566 wps_draw_image(gwps, n, data->img[n].display);
567 } else if (data->img[n].always_display && data->img[n].vp == vp)
568 {
569 wps_draw_image(gwps, n, 0);
570 }
564 } 571 }
565 } 572 }
566 display->set_drawmode(DRMODE_SOLID); 573 display->set_drawmode(DRMODE_SOLID);
@@ -1449,7 +1456,7 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index)
1449#ifdef HAVE_LCD_BITMAP 1456#ifdef HAVE_LCD_BITMAP
1450 /* clear all pictures in the conditional and nested ones */ 1457 /* clear all pictures in the conditional and nested ones */
1451 if (data->tokens[i].type == WPS_TOKEN_IMAGE_PRELOAD_DISPLAY) 1458 if (data->tokens[i].type == WPS_TOKEN_IMAGE_PRELOAD_DISPLAY)
1452 clear_image_pos(gwps, data->tokens[i].value.i); 1459 clear_image_pos(gwps, data->tokens[i].value.i & 0xFF);
1453#endif 1460#endif
1454#ifdef HAVE_ALBUMART 1461#ifdef HAVE_ALBUMART
1455 if (data->tokens[i].type == WPS_TOKEN_ALBUMART_DISPLAY) 1462 if (data->tokens[i].type == WPS_TOKEN_ALBUMART_DISPLAY)
@@ -1515,9 +1522,11 @@ static bool get_line(struct gui_wps *gwps,
1515 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY: 1522 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
1516 { 1523 {
1517 struct gui_img *img = data->img; 1524 struct gui_img *img = data->img;
1518 int n = data->tokens[i].value.i; 1525 int n = data->tokens[i].value.i & 0xFF;
1526 int subimage = data->tokens[i].value.i >> 8;
1527
1519 if (n >= 0 && n < MAX_IMAGES && img[n].loaded) 1528 if (n >= 0 && n < MAX_IMAGES && img[n].loaded)
1520 img[n].display = true; 1529 img[n].display = subimage;
1521 break; 1530 break;
1522 } 1531 }
1523#endif 1532#endif
@@ -1944,7 +1953,7 @@ bool gui_wps_refresh(struct gui_wps *gwps,
1944 /* Set images to not to be displayed */ 1953 /* Set images to not to be displayed */
1945 for (i = 0; i < MAX_IMAGES; i++) 1954 for (i = 0; i < MAX_IMAGES; i++)
1946 { 1955 {
1947 data->img[i].display = false; 1956 data->img[i].display = -1;
1948 } 1957 }
1949#endif 1958#endif
1950 1959
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index e72b41308b..b24c243cd7 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -64,8 +64,10 @@ struct gui_img{
64 struct viewport* vp; /* The viewport to display this image in */ 64 struct viewport* vp; /* The viewport to display this image in */
65 int x; /* x-pos */ 65 int x; /* x-pos */
66 int y; /* y-pos */ 66 int y; /* y-pos */
67 int num_subimages; /* number of sub-images */
68 int subimage_height; /* height of each sub-image */
69 int display; /* -1 for no display, 0..n to display a subimage */
67 bool loaded; /* load state */ 70 bool loaded; /* load state */
68 bool display; /* is to be displayed */
69 bool always_display; /* not using the preload/display mechanism */ 71 bool always_display; /* not using the preload/display mechanism */
70}; 72};
71 73
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
448static int parse_image_load(const char *wps_bufptr, 455static 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 }