summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_render.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_render.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_render.c')
-rw-r--r--apps/gui/skin_engine/skin_render.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
index 895746370e..e254c62cf9 100644
--- a/apps/gui/skin_engine/skin_render.c
+++ b/apps/gui/skin_engine/skin_render.c
@@ -144,11 +144,36 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
144#ifdef HAVE_LCD_BITMAP 144#ifdef HAVE_LCD_BITMAP
145 case SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY: 145 case SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY:
146 { 146 {
147 char n = token->value.i & 0xFF; 147 struct image_display *id = token->value.data;
148 int subimage = token->value.i >> 8; 148 char n = id->label;
149 struct gui_img *img = find_image(n, data); 149 struct gui_img *img = find_image(n, data);
150 if (img && img->loaded) 150 if (img && img->loaded)
151 img->display = subimage; 151 {
152 if (id->token == NULL)
153 {
154 img->display = id->subimage;
155 }
156 else
157 {
158 char buf[16];
159 const char *out;
160 int a = TOKEN_VALUE_ONLY;
161 out = get_token_value(gwps, id->token, buf, sizeof(buf), &a);
162 /* NOTE: get_token_value() returns values starting at 1! */
163 if (a == -1)
164 a = (out && *out) ? 1 : 2;
165 a--;
166 a += id->offset;
167 /* If the token returned a value which is higher than
168 * the amount of subimages clear the image. */
169 if (a<0 || a >= img->num_subimages)
170 {
171 clear_image_pos(gwps, img);
172 }
173 else
174 img->display = a;
175 }
176 }
152 break; 177 break;
153 } 178 }
154#ifdef HAVE_ALBUMART 179#ifdef HAVE_ALBUMART
@@ -230,7 +255,8 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch,
230 /* clear all pictures in the conditional and nested ones */ 255 /* clear all pictures in the conditional and nested ones */
231 if (token->type == SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY) 256 if (token->type == SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY)
232 { 257 {
233 struct gui_img *img = find_image(token->value.i&0xFF, data); 258 struct image_display *id = token->value.data;
259 struct gui_img *img = find_image(id->label, data);
234 clear_image_pos(gwps, img); 260 clear_image_pos(gwps, img);
235 } 261 }
236 else if (token->type == SKIN_TOKEN_PEAKMETER) 262 else if (token->type == SKIN_TOKEN_PEAKMETER)