summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/gui/skin_engine/skin_parser.c116
-rw-r--r--lib/skin_parser/tag_table.c13
2 files changed, 106 insertions, 23 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 0e7150c553..63f3f81140 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -398,8 +398,15 @@ static int parse_image_load(struct skin_element *element,
398 subimages = get_param(element, 2)->data.number; 398 subimages = get_param(element, 2)->data.number;
399 else if (element->params_count > 3) 399 else if (element->params_count > 3)
400 { 400 {
401 x = get_param(element, 2)->data.number; 401 if (get_param(element, 2)->type == PERCENT)
402 y = get_param(element, 3)->data.number; 402 x = get_param(element, 2)->data.number * curr_vp->vp.width / 1000;
403 else
404 x = get_param(element, 2)->data.number;
405 if (get_param(element, 3)->type == PERCENT)
406 y = get_param(element, 3)->data.number * curr_vp->vp.height / 1000;
407 else
408 y = get_param(element, 3)->data.number;
409
403 if (element->params_count == 5) 410 if (element->params_count == 5)
404 subimages = get_param(element, 4)->data.number; 411 subimages = get_param(element, 4)->data.number;
405 } 412 }
@@ -642,16 +649,27 @@ static int parse_drawrectangle( struct skin_element *element,
642 if (!rect) 649 if (!rect)
643 return -1; 650 return -1;
644 651
645 rect->x = get_param(element, 0)->data.number; 652 if (get_param(element, 0)->type == PERCENT)
646 rect->y = get_param(element, 1)->data.number; 653 rect->x = get_param(element, 0)->data.number * curr_vp->vp.width / 1000;
654 else
655 rect->x = get_param(element, 0)->data.number;
656
657 if (get_param(element, 1)->type == PERCENT)
658 rect->y = get_param(element, 1)->data.number * curr_vp->vp.height / 1000;
659 else
660 rect->y = get_param(element, 1)->data.number;
647 661
648 if (isdefault(get_param(element, 2))) 662 if (isdefault(get_param(element, 2)))
649 rect->width = curr_vp->vp.width - rect->x; 663 rect->width = curr_vp->vp.width - rect->x;
664 else if (get_param(element, 2)->type == PERCENT)
665 rect->width = get_param(element, 2)->data.number * curr_vp->vp.width / 1000;
650 else 666 else
651 rect->width = get_param(element, 2)->data.number; 667 rect->width = get_param(element, 2)->data.number;
652 668
653 if (isdefault(get_param(element, 3))) 669 if (isdefault(get_param(element, 3)))
654 rect->height = curr_vp->vp.height - rect->y; 670 rect->height = curr_vp->vp.height - rect->y;
671 else if (get_param(element, 3)->type == PERCENT)
672 rect->height = get_param(element, 3)->data.number * curr_vp->vp.height / 1000;
655 else 673 else
656 rect->height = get_param(element, 3)->data.number; 674 rect->height = get_param(element, 3)->data.number;
657 675
@@ -924,7 +942,12 @@ static int parse_progressbar_tag(struct skin_element* element,
924 /* (x, y, width, height, ...) */ 942 /* (x, y, width, height, ...) */
925 if (!isdefault(param)) 943 if (!isdefault(param))
926 { 944 {
927 pb->x = param->data.number; 945 if (param->type == PERCENT)
946 {
947 pb->x = param->data.number * vp->width / 1000;
948 }
949 else
950 pb->x = param->data.number;
928 if (pb->x < 0 || pb->x >= vp->width) 951 if (pb->x < 0 || pb->x >= vp->width)
929 return WPS_ERROR_INVALID_PARAM; 952 return WPS_ERROR_INVALID_PARAM;
930 } 953 }
@@ -934,7 +957,12 @@ static int parse_progressbar_tag(struct skin_element* element,
934 957
935 if (!isdefault(param)) 958 if (!isdefault(param))
936 { 959 {
937 pb->y = param->data.number; 960 if (param->type == PERCENT)
961 {
962 pb->y = param->data.number * vp->height / 1000;
963 }
964 else
965 pb->y = param->data.number;
938 if (pb->y < 0 || pb->y >= vp->height) 966 if (pb->y < 0 || pb->y >= vp->height)
939 return WPS_ERROR_INVALID_PARAM; 967 return WPS_ERROR_INVALID_PARAM;
940 } 968 }
@@ -944,7 +972,12 @@ static int parse_progressbar_tag(struct skin_element* element,
944 972
945 if (!isdefault(param)) 973 if (!isdefault(param))
946 { 974 {
947 pb->width = param->data.number; 975 if (param->type == PERCENT)
976 {
977 pb->width = param->data.number * vp->width / 1000;
978 }
979 else
980 pb->width = param->data.number;
948 if (pb->width <= 0 || (pb->x + pb->width) > vp->width) 981 if (pb->width <= 0 || (pb->x + pb->width) > vp->width)
949 return WPS_ERROR_INVALID_PARAM; 982 return WPS_ERROR_INVALID_PARAM;
950 } 983 }
@@ -955,7 +988,12 @@ static int parse_progressbar_tag(struct skin_element* element,
955 if (!isdefault(param)) 988 if (!isdefault(param))
956 { 989 {
957 int max; 990 int max;
958 pb->height = param->data.number; 991 if (param->type == PERCENT)
992 {
993 pb->height = param->data.number * vp->height / 1000;
994 }
995 else
996 pb->height = param->data.number;
959 /* include y in check only if it was non-default */ 997 /* include y in check only if it was non-default */
960 max = (pb->y > 0) ? pb->y + pb->height : pb->height; 998 max = (pb->y > 0) ? pb->y + pb->height : pb->height;
961 if (pb->height <= 0 || max > vp->height) 999 if (pb->height <= 0 || max > vp->height)
@@ -1213,6 +1251,18 @@ static int parse_albumart_load(struct skin_element* element,
1213 aa->width = get_param(element, 2)->data.number; 1251 aa->width = get_param(element, 2)->data.number;
1214 aa->height = get_param(element, 3)->data.number; 1252 aa->height = get_param(element, 3)->data.number;
1215 1253
1254 if (!isdefault(get_param(element, 0)) && get_param(element, 0)->type == PERCENT)
1255 aa->x = get_param(element, 0)->data.number * curr_vp->vp.width / 1000;
1256
1257 if (!isdefault(get_param(element, 1)) && get_param(element, 1)->type == PERCENT)
1258 aa->y = get_param(element, 1)->data.number * curr_vp->vp.height / 1000;
1259
1260 if (!isdefault(get_param(element, 2)) && get_param(element, 2)->type == PERCENT)
1261 aa->width = get_param(element, 2)->data.number * curr_vp->vp.width / 1000;
1262
1263 if (!isdefault(get_param(element, 3)) && get_param(element, 3)->type == PERCENT)
1264 aa->height = get_param(element, 3)->data.number * curr_vp->vp.height / 1000;
1265
1216 aa->vp = PTRTOSKINOFFSET(skin_buffer, &curr_vp->vp); 1266 aa->vp = PTRTOSKINOFFSET(skin_buffer, &curr_vp->vp);
1217 aa->draw_handle = -1; 1267 aa->draw_handle = -1;
1218 1268
@@ -1521,10 +1571,7 @@ static int parse_touchregion(struct skin_element *element,
1521 { 1571 {
1522 region->label = PTRTOSKINOFFSET(skin_buffer, get_param_text(element, 0)); 1572 region->label = PTRTOSKINOFFSET(skin_buffer, get_param_text(element, 0));
1523 p = 1; 1573 p = 1;
1524 /* "[SI]III[SI]|SS" is the param list. There MUST be 4 numbers 1574 if (element->params_count < 6)
1525 * followed by at least one string. Verify that here */
1526 if (element->params_count < 6 ||
1527 get_param(element, 4)->type != INTEGER)
1528 return WPS_ERROR_INVALID_PARAM; 1575 return WPS_ERROR_INVALID_PARAM;
1529 } 1576 }
1530 else 1577 else
@@ -1532,11 +1579,48 @@ static int parse_touchregion(struct skin_element *element,
1532 region->label = PTRTOSKINOFFSET(skin_buffer, NULL); 1579 region->label = PTRTOSKINOFFSET(skin_buffer, NULL);
1533 p = 0; 1580 p = 0;
1534 } 1581 }
1582/*x*/
1583 struct skin_tag_parameter *param = get_param(element, p);
1584 region->x = 0;
1585 if (!isdefault(param))
1586 {
1587 if (param->type == INTEGER)
1588 region->x = param->data.number;
1589 else if (param->type == PERCENT)
1590 region->x = param->data.number * curr_vp->vp.width / 1000;
1591 }
1592/*y*/
1593 param = get_param(element, ++p);
1594 region->y = 0;
1595 if (!isdefault(param))
1596 {
1597 if (param->type == INTEGER)
1598 region->y = param->data.number;
1599 else if (param->type == PERCENT)
1600 region->y =param->data.number * curr_vp->vp.width / 1000;
1601 }
1602/*width*/
1603 param = get_param(element, ++p);
1604 region->width = curr_vp->vp.width;
1605 if (!isdefault(param))
1606 {
1607 if (param->type == INTEGER)
1608 region->width =param->data.number;
1609 else if (param->type == PERCENT)
1610 region->width = curr_vp->vp.width * param->data.number / 1000;
1611 }
1612/*height*/
1613 param = get_param(element, ++p);
1614 region->height = curr_vp->vp.height;
1615 if (!isdefault(param))
1616 {
1617 if (param->type == INTEGER)
1618 region->height =param->data.number;
1619 else if (param->type == PERCENT)
1620 region->height = curr_vp->vp.height * param->data.number / 1000;
1621 }
1622 p++;
1535 1623
1536 region->x = get_param(element, p++)->data.number;
1537 region->y = get_param(element, p++)->data.number;
1538 region->width = get_param(element, p++)->data.number;
1539 region->height = get_param(element, p++)->data.number;
1540 region->wvp = PTRTOSKINOFFSET(skin_buffer, curr_vp); 1624 region->wvp = PTRTOSKINOFFSET(skin_buffer, curr_vp);
1541 region->armed = false; 1625 region->armed = false;
1542 region->reverse_bar = false; 1626 region->reverse_bar = false;
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index 24dcf181d4..2cea048548 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -22,7 +22,7 @@
22#include "tag_table.h" 22#include "tag_table.h"
23 23
24#include <string.h> 24#include <string.h>
25#define BAR_PARAMS "?iiii|s*" 25#define BAR_PARAMS "?[iP][iP][iP][iP]|s*"
26/* The tag definition table */ 26/* The tag definition table */
27static const struct tag_info legal_tags[] = 27static const struct tag_info legal_tags[] =
28{ 28{
@@ -176,13 +176,13 @@ static const struct tag_info legal_tags[] =
176 { SKIN_TOKEN_DISABLE_THEME, "wd", "", 0|NOBREAK }, 176 { SKIN_TOKEN_DISABLE_THEME, "wd", "", 0|NOBREAK },
177 { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|NOBREAK }, 177 { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|NOBREAK },
178 178
179 { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SF|III", 0|NOBREAK }, 179 { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SF|[IP][IP]I", 0|NOBREAK },
180 { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S|[IT]I", 0 }, 180 { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S|[IT]I", 0 },
181 { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SF|II", SKIN_REFRESH_STATIC|NOBREAK }, 181 { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SF|II", SKIN_REFRESH_STATIC|NOBREAK },
182 { SKIN_TOKEN_IMAGE_DISPLAY_9SEGMENT, "x9", "S", 0 }, 182 { SKIN_TOKEN_IMAGE_DISPLAY_9SEGMENT, "x9", "S", 0 },
183 183
184 { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF|I", 0|NOBREAK }, 184 { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF|I", 0|NOBREAK },
185 { SKIN_TOKEN_ALBUMART_LOAD, "Cl" , "IIII|ss", 0|NOBREAK }, 185 { SKIN_TOKEN_ALBUMART_LOAD, "Cl" , "[iP][iP][iP][iP]|ss", 0|NOBREAK },
186 { SKIN_TOKEN_ALBUMART_DISPLAY, "Cd" , "", SKIN_REFRESH_STATIC }, 186 { SKIN_TOKEN_ALBUMART_DISPLAY, "Cd" , "", SKIN_REFRESH_STATIC },
187 { SKIN_TOKEN_ALBUMART_FOUND, "C" , "", SKIN_REFRESH_STATIC }, 187 { SKIN_TOKEN_ALBUMART_FOUND, "C" , "", SKIN_REFRESH_STATIC },
188 188
@@ -214,7 +214,7 @@ static const struct tag_info legal_tags[] =
214 { SKIN_TOKEN_IMAGE_BACKDROP, "X" , "f", SKIN_REFRESH_STATIC|NOBREAK }, 214 { SKIN_TOKEN_IMAGE_BACKDROP, "X" , "f", SKIN_REFRESH_STATIC|NOBREAK },
215 /* This uses the bar tag params also but the first item can be a string 215 /* This uses the bar tag params also but the first item can be a string
216 * and we don't allow no params. */ 216 * and we don't allow no params. */
217 { SKIN_TOKEN_SETTING, "St" , "[Si]|iiis*", SKIN_REFRESH_DYNAMIC }, 217 { SKIN_TOKEN_SETTING, "St" , "[Sip]|[ip][ip][ip]s*", SKIN_REFRESH_DYNAMIC },
218 { SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S", SKIN_REFRESH_STATIC }, 218 { SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S", SKIN_REFRESH_STATIC },
219 { SKIN_TOKEN_LANG_IS_RTL, "Sr" , "", SKIN_REFRESH_STATIC }, 219 { SKIN_TOKEN_LANG_IS_RTL, "Sr" , "", SKIN_REFRESH_STATIC },
220 220
@@ -224,8 +224,7 @@ static const struct tag_info legal_tags[] =
224 * [SI]III[SI]|SN <- SIIIIS|S or IIIIS|S 224 * [SI]III[SI]|SN <- SIIIIS|S or IIIIS|S
225 * keep in sync with parse_touchregion() and parse_lasttouch() */ 225 * keep in sync with parse_touchregion() and parse_lasttouch() */
226 { SKIN_TOKEN_LASTTOUCH, "Tl" , "|[SD]D", SKIN_REFRESH_DYNAMIC }, 226 { SKIN_TOKEN_LASTTOUCH, "Tl" , "|[SD]D", SKIN_REFRESH_DYNAMIC },
227 { SKIN_TOKEN_TOUCHREGION, "T" , "[SI]III[SI]|S*", 0|NOBREAK }, 227 { SKIN_TOKEN_TOUCHREGION, "T" , "[Sip][ip][ip][ip][Sip]|S*", 0|NOBREAK },
228
229 { SKIN_TOKEN_HAVE_TOUCH, "Tp", "", FEATURE_TAG }, 228 { SKIN_TOKEN_HAVE_TOUCH, "Tp", "", FEATURE_TAG },
230 229
231 { SKIN_TOKEN_CURRENT_SCREEN, "cs", "", SKIN_REFRESH_DYNAMIC }, 230 { SKIN_TOKEN_CURRENT_SCREEN, "cs", "", SKIN_REFRESH_DYNAMIC },
@@ -246,7 +245,7 @@ static const struct tag_info legal_tags[] =
246 { SKIN_TOKEN_VAR_TIMEOUT, "vl", "S|D", SKIN_REFRESH_DYNAMIC }, 245 { SKIN_TOKEN_VAR_TIMEOUT, "vl", "S|D", SKIN_REFRESH_DYNAMIC },
247 246
248 { SKIN_TOKEN_SUBSTRING, "ss", "IiT|s", SKIN_REFRESH_DYNAMIC }, 247 { SKIN_TOKEN_SUBSTRING, "ss", "IiT|s", SKIN_REFRESH_DYNAMIC },
249 { SKIN_TOKEN_DRAWRECTANGLE, "dr", "IIii|ss", SKIN_REFRESH_STATIC }, 248 { SKIN_TOKEN_DRAWRECTANGLE, "dr", "[IP][IP][ip][ip]|ss", SKIN_REFRESH_STATIC },
250 { SKIN_TOKEN_UNKNOWN, "" , "", 0 } 249 { SKIN_TOKEN_UNKNOWN, "" , "", 0 }
251 /* Keep this here to mark the end of the table */ 250 /* Keep this here to mark the end of the table */
252}; 251};