summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-08-18 07:17:51 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-08-18 07:17:51 +0000
commitdab7e161767f951a55d6fbc0988fae5f3d9df474 (patch)
tree7fe7a5dcbc9fa3bd2ff270fee738f36e05c9dd90
parent36ca4967e0ced08ab8d262ba046189e6dfbe71da (diff)
downloadrockbox-dab7e161767f951a55d6fbc0988fae5f3d9df474.tar.gz
rockbox-dab7e161767f951a55d6fbc0988fae5f3d9df474.zip
store the image label instead of a number so debug output is actually useful when %xd is used witout a coresponding %xl
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22404 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/skin_engine/skin_display.c6
-rw-r--r--apps/gui/skin_engine/skin_parser.c24
-rw-r--r--apps/gui/skin_engine/wps_debug.c4
-rw-r--r--apps/gui/skin_engine/wps_internals.h4
4 files changed, 16 insertions, 22 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 1e88863307..6b86a8bc0e 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -478,13 +478,13 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index)
478 return true; 478 return true;
479} 479}
480#ifdef HAVE_LCD_BITMAP 480#ifdef HAVE_LCD_BITMAP
481struct gui_img* find_image(int n, struct wps_data *data) 481struct gui_img* find_image(char label, struct wps_data *data)
482{ 482{
483 struct skin_token_list *list = data->images; 483 struct skin_token_list *list = data->images;
484 while (list) 484 while (list)
485 { 485 {
486 struct gui_img *img = (struct gui_img *)list->token->value.data; 486 struct gui_img *img = (struct gui_img *)list->token->value.data;
487 if (img->id == n) 487 if (img->label == label)
488 return img; 488 return img;
489 list = list->next; 489 list = list->next;
490 } 490 }
@@ -555,7 +555,7 @@ static bool get_line(struct gui_wps *gwps,
555#ifdef HAVE_LCD_BITMAP 555#ifdef HAVE_LCD_BITMAP
556 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY: 556 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
557 { 557 {
558 int n = data->tokens[i].value.i & 0xFF; 558 char n = data->tokens[i].value.i & 0xFF;
559 int subimage = data->tokens[i].value.i >> 8; 559 int subimage = data->tokens[i].value.i >> 8;
560 struct gui_img *img = find_image(n, data); 560 struct gui_img *img = find_image(n, data);
561 561
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 82083e8922..b7f2ec3091 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -482,19 +482,17 @@ static int parse_image_display(const char *wps_bufptr,
482 struct wps_token *token, 482 struct wps_token *token,
483 struct wps_data *wps_data) 483 struct wps_data *wps_data)
484{ 484{
485 int n = get_image_id(wps_bufptr[0]); 485 char label = wps_bufptr[0];
486 int subimage; 486 int subimage;
487 struct gui_img *img;; 487 struct gui_img *img;;
488 488
489 if (n == -1)
490 {
491 /* invalid picture display tag */
492 return WPS_ERROR_INVALID_PARAM;
493 }
494 /* sanity check */ 489 /* sanity check */
495 img = find_image(n, wps_data); 490 img = find_image(label, wps_data);
496 if (!img) 491 if (!img)
492 {
493 token->value.i = label; /* do debug works */
497 return WPS_ERROR_INVALID_PARAM; 494 return WPS_ERROR_INVALID_PARAM;
495 }
498 496
499 if ((subimage = get_image_id(wps_bufptr[1])) != -1) 497 if ((subimage = get_image_id(wps_bufptr[1])) != -1)
500 { 498 {
@@ -502,10 +500,10 @@ static int parse_image_display(const char *wps_bufptr,
502 return WPS_ERROR_INVALID_PARAM; 500 return WPS_ERROR_INVALID_PARAM;
503 501
504 /* Store sub-image number to display in high bits */ 502 /* Store sub-image number to display in high bits */
505 token->value.i = n | (subimage << 8); 503 token->value.i = label | (subimage << 8);
506 return 2; /* We have consumed 2 bytes */ 504 return 2; /* We have consumed 2 bytes */
507 } else { 505 } else {
508 token->value.i = n; 506 token->value.i = label;
509 return 1; /* We have consumed 1 byte */ 507 return 1; /* We have consumed 1 byte */
510 } 508 }
511} 509}
@@ -514,7 +512,6 @@ static int parse_image_load(const char *wps_bufptr,
514 struct wps_token *token, 512 struct wps_token *token,
515 struct wps_data *wps_data) 513 struct wps_data *wps_data)
516{ 514{
517 int n;
518 const char *ptr = wps_bufptr; 515 const char *ptr = wps_bufptr;
519 const char *pos; 516 const char *pos;
520 const char* filename; 517 const char* filename;
@@ -540,11 +537,8 @@ static int parse_image_load(const char *wps_bufptr,
540 if (*ptr != '|') 537 if (*ptr != '|')
541 return WPS_ERROR_INVALID_PARAM; 538 return WPS_ERROR_INVALID_PARAM;
542 539
543 /* get the image ID */
544 n = get_image_id(*id);
545
546 /* check the image number and load state */ 540 /* check the image number and load state */
547 if(n < 0 || find_image(n, wps_data)) 541 if(find_image(*id, wps_data))
548 { 542 {
549 /* Invalid image ID */ 543 /* Invalid image ID */
550 return WPS_ERROR_INVALID_PARAM; 544 return WPS_ERROR_INVALID_PARAM;
@@ -554,7 +548,7 @@ static int parse_image_load(const char *wps_bufptr,
554 return WPS_ERROR_INVALID_PARAM; 548 return WPS_ERROR_INVALID_PARAM;
555 /* save a pointer to the filename */ 549 /* save a pointer to the filename */
556 img->bm.data = (char*)filename; 550 img->bm.data = (char*)filename;
557 img->id = n; 551 img->label = *id;
558 img->x = x; 552 img->x = x;
559 img->y = y; 553 img->y = y;
560 img->num_subimages = 1; 554 img->num_subimages = 1;
diff --git a/apps/gui/skin_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c
index e3e6e960e6..60f53b83f4 100644
--- a/apps/gui/skin_engine/wps_debug.c
+++ b/apps/gui/skin_engine/wps_debug.c
@@ -113,8 +113,8 @@ static char *get_token_desc(struct wps_token *token, struct wps_data *data,
113 break; 113 break;
114 114
115 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY: 115 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
116 snprintf(buf, bufsize, "display preloaded image %d", 116 snprintf(buf, bufsize, "display preloaded image '%c'",
117 token->value.i); 117 token->value.i&0xFF);
118 break; 118 break;
119 119
120 case WPS_TOKEN_IMAGE_DISPLAY: 120 case WPS_TOKEN_IMAGE_DISPLAY:
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 4136347a7b..0adae04c42 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -77,7 +77,7 @@
77 77
78#ifdef HAVE_LCD_BITMAP 78#ifdef HAVE_LCD_BITMAP
79struct gui_img { 79struct gui_img {
80 short int id; 80 char label;
81 struct bitmap bm; 81 struct bitmap bm;
82 struct viewport* vp; /* The viewport to display this image in */ 82 struct viewport* vp; /* The viewport to display this image in */
83 short int x; /* x-pos */ 83 short int x; /* x-pos */
@@ -346,7 +346,7 @@ const char *get_token_value(struct gui_wps *gwps,
346 346
347 347
348 348
349struct gui_img* find_image(int n, struct wps_data *data); 349struct gui_img* find_image(char label, struct wps_data *data);
350struct skin_viewport* find_viewport(char label, struct wps_data *data); 350struct skin_viewport* find_viewport(char label, struct wps_data *data);
351 351
352#endif 352#endif