summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_parser.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-08-05 11:28:48 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-08-05 11:28:48 +0000
commit3f8e7fc26fdecde65fb78de84e4df31df8c0e750 (patch)
tree7f2c2d93d72d4f7a3dade4ccdd9a81433f5abe05 /apps/gui/skin_engine/skin_parser.c
parent145571d9b5c2b6b1028fbb95388f933a3675ebfa (diff)
downloadrockbox-3f8e7fc26fdecde65fb78de84e4df31df8c0e750.tar.gz
rockbox-3f8e7fc26fdecde65fb78de84e4df31df8c0e750.zip
New feature for the %xd() (display a preloaded image) skin tag.
It can now automatically load the correct subimage from a strip (assuming the strip is in the correct order) by giving a tag for the 2nd param. example: %xd(F, %mp) which is equivilant to %?mp<%xd(Fa)|%xd(Fb)|%xd(Fc)|%xd(Fd)|%xd(Fe)> You can also set the subimage offset.. i.e %xd(E, %mm, -1) which means "show nothing for the first value of %mm and use the bitmap strip for the remaining values" if a tag+offset is <0 or greater than the number of subimages in a strip he image is cleared (I'm open to changing this if someone has a better idea) cabbiev2.176x220x16.wps is an example of how to use this git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27717 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r--apps/gui/skin_engine/skin_parser.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index a3cb68915b..c5acd1fd75 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -232,27 +232,39 @@ static int parse_image_display(struct skin_element *element,
232 char sublabel = text[1]; 232 char sublabel = text[1];
233 int subimage; 233 int subimage;
234 struct gui_img *img; 234 struct gui_img *img;
235 struct image_display *id = skin_buffer_alloc(sizeof(struct image_display));
235 236
236 /* sanity check */ 237 /* sanity check */
237 img = find_image(label, wps_data); 238 img = find_image(label, wps_data);
238 if (!img) 239 if (!img || !id)
239 { 240 {
240 token->value.i = label; /* so debug works */ 241 token->value.i = label; /* so debug works */
241 return WPS_ERROR_INVALID_PARAM; 242 return WPS_ERROR_INVALID_PARAM;
242 } 243 }
243 244 id->label = label;
244 if ((subimage = get_image_id(sublabel)) != -1) 245 id->offset = 0;
246
247 if (element->params_count > 1)
245 { 248 {
246 if (subimage >= img->num_subimages) 249 id->token = element->params[1].data.code->data;
247 return WPS_ERROR_INVALID_PARAM; 250 if (element->params_count > 2)
248 251 id->offset = element->params[2].data.number;
249 /* Store sub-image number to display in high bits */
250 token->value.i = label | (subimage << 8);
251 return 4; /* We have consumed 2 bytes */
252 } else {
253 token->value.i = label;
254 return 3; /* We have consumed 1 byte */
255 } 252 }
253 else
254 {
255 id->token = NULL;
256 if ((subimage = get_image_id(sublabel)) != -1)
257 {
258 if (subimage >= img->num_subimages)
259 return WPS_ERROR_INVALID_PARAM;
260 id->subimage = subimage;
261 token->value.i = label | (subimage << 8);
262 } else {
263 id->subimage = 0;
264 }
265 }
266 token->value.data = id;
267 return 0;
256} 268}
257 269
258static int parse_image_load(struct skin_element *element, 270static int parse_image_load(struct skin_element *element,