summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/gui/skin_engine/skin_parser.c36
-rw-r--r--apps/gui/skin_engine/skin_render.c34
-rw-r--r--apps/gui/skin_engine/wps_internals.h9
-rw-r--r--lib/skin_parser/tag_table.c2
-rw-r--r--manual/appendix/wps_tags.tex11
-rw-r--r--wps/cabbiev2.176x220x16.wps6
6 files changed, 75 insertions, 23 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,
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)
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 709dbc6ff7..e42fc5a53b 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -49,6 +49,9 @@
49#define WPS_ALIGN_CENTER 64 49#define WPS_ALIGN_CENTER 64
50#define WPS_ALIGN_LEFT 128 50#define WPS_ALIGN_LEFT 128
51 51
52
53#define TOKEN_VALUE_ONLY 0xDEADD0D0
54
52#ifdef HAVE_ALBUMART 55#ifdef HAVE_ALBUMART
53 56
54/* albumart definitions */ 57/* albumart definitions */
@@ -80,6 +83,12 @@ struct gui_img {
80 int display; 83 int display;
81}; 84};
82 85
86struct image_display {
87 char label;
88 int subimage;
89 struct wps_token *token; /* the token to get the subimage number from */
90 int offset; /* offset into the bitmap strip to start */
91};
83 92
84struct progressbar { 93struct progressbar {
85 enum skin_token_type type; 94 enum skin_token_type type;
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index 26c049b3dd..dccb9f8259 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -167,7 +167,7 @@ static const struct tag_info legal_tags[] =
167 { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|NOBREAK }, 167 { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|NOBREAK },
168 168
169 { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SFII|I", 0|NOBREAK }, 169 { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SFII|I", 0|NOBREAK },
170 { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S", 0 }, 170 { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S|TI", 0 },
171 { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SFII", 0|NOBREAK }, 171 { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SFII", 0|NOBREAK },
172 172
173 { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF", 0|NOBREAK }, 173 { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF", 0|NOBREAK },
diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex
index 070d191646..2992b18a1c 100644
--- a/manual/appendix/wps_tags.tex
+++ b/manual/appendix/wps_tags.tex
@@ -320,10 +320,15 @@ Examples:
320 \config{y}: y coordinate\newline 320 \config{y}: y coordinate\newline
321 \config{nimages}: (optional) number of sub-images (tiled vertically, of the same height) 321 \config{nimages}: (optional) number of sub-images (tiled vertically, of the same height)
322 contained in the bitmap. Default is 1.\\ 322 contained in the bitmap. Default is 1.\\
323 \config{\%xd(n[i])} & Display a preloaded image. 323 \config{\%xd(n[i] [,tag] [,offset])} & Display a preloaded image.
324 \config{n}: image ID (a-z and A-Z) as it was specified in \config{\%x} or \config{\%xl}\newline 324 \config{n}: image ID (a-z and A-Z) as it was specified in \config{\%x} or \config{\%xl}\newline
325 \config{i}: (optional) number of the sub-image to display (a-z for 1-26 and A-Z for 27-52). 325 \config{i}: (optional) number of the sub-image to display (a-z for 1-26 and A-Z for 27-52).
326 By default the first (i.e. top most) sub-image will be used.\\ 326 (ignored when \config{tag} is used)
327 By default the first (i.e. top most) sub-image will be used.\newline
328 \config{tag}: (optional) Another tag to calculate the subimage from e.g \config{\%xd(A, \%mh)} would
329 use the first subimage when \config{\%mh} is on and the second when it is off\newline
330 \config{offset}}: (optional) Add this number to the value from the \config{tag} when
331 chosing the subimage (may be negative)\\
327 \end{tagmap} 332 \end{tagmap}
328 333
329Examples: 334Examples:
diff --git a/wps/cabbiev2.176x220x16.wps b/wps/cabbiev2.176x220x16.wps
index c0c7cfc827..7b20adf7cf 100644
--- a/wps/cabbiev2.176x220x16.wps
+++ b/wps/cabbiev2.176x220x16.wps
@@ -27,10 +27,10 @@
27%?C<%s%ac%?id<%id|%?d(1)<%d(1)|%(root%)>>|> 27%?C<%s%ac%?id<%id|%?d(1)<%d(1)|%(root%)>>|>
28 28
29%al %pc%ac%?Sr<%pe %Sx(of) %pp|%pp %Sx(of) %pe>%ar%pr 29%al %pc%ac%?Sr<%pe %Sx(of) %pp|%pp %Sx(of) %pe>%ar%pr
30%?mh<%xd(Aa)|%xd(Ab)> 30%xd(A, %mh)
31%?bp<%?bc<%xd(Ba)|%xd(Bb)>|%?bl<|%xd(Bc)|%xd(Bd)|%xd(Be)|%xd(Bf)|%xd(Bg)|%xd(Bh)|%xd(Bi)|%xd(Bj)>> 31%?bp<%?bc<%xd(Ba)|%xd(Bb)>|%?bl<|%xd(Bc)|%xd(Bd)|%xd(Be)|%xd(Bf)|%xd(Bg)|%xd(Bh)|%xd(Bi)|%xd(Bj)>>
32%?pv<%xd(Ca)|%xd(Cb)|%xd(Cc)|%xd(Cd)|%xd(Ce)|%xd(Cf)|%xd(Cg)|%xd(Ch)|%xd(Ci)|%xd(Cj)> 32%?pv<%xd(Ca)|%xd(Cb)|%xd(Cc)|%xd(Cd)|%xd(Ce)|%xd(Cf)|%xd(Cg)|%xd(Ch)|%xd(Ci)|%xd(Cj)>
33%?ps<%xd(D)> 33%?ps<%xd(D)>
34%?mm<|%xd(Ea)|%xd(Eb)|%xd(Ec)|%xd(Ed)> 34%xd(E, %mm, -1)
35%?mp<%xd(Fa)|%xd(Fb)|%xd(Fc)|%xd(Fd)|%xd(Fe)> 35%xd(F, %mp)
36%?C<%Cd> 36%?C<%Cd>