diff options
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 161 |
1 files changed, 100 insertions, 61 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index b3840f689f..7da772fab4 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -343,11 +343,12 @@ static int parse_image_display(struct skin_element *element, | |||
343 | 343 | ||
344 | if (element->params_count > 1) | 344 | if (element->params_count > 1) |
345 | { | 345 | { |
346 | if (get_param(element, 1)->type == CODE) | 346 | struct skin_tag_parameter *param1 = get_param(element, 1); |
347 | if (param1->type == CODE) | ||
347 | id->token = get_param_code(element, 1)->data; | 348 | id->token = get_param_code(element, 1)->data; |
348 | /* specify a number. 1 being the first subimage (i.e top) NOT 0 */ | 349 | /* specify a number. 1 being the first subimage (i.e top) NOT 0 */ |
349 | else if (get_param(element, 1)->type == INTEGER) | 350 | else if (param1->type == INTEGER) |
350 | id->subimage = get_param(element, 1)->data.number - 1; | 351 | id->subimage = param1->data.number - 1; |
351 | if (element->params_count > 2) | 352 | if (element->params_count > 2) |
352 | id->offset = get_param(element, 2)->data.number; | 353 | id->offset = get_param(element, 2)->data.number; |
353 | } | 354 | } |
@@ -391,14 +392,16 @@ static int parse_image_load(struct skin_element *element, | |||
391 | subimages = get_param(element, 2)->data.number; | 392 | subimages = get_param(element, 2)->data.number; |
392 | else if (element->params_count > 3) | 393 | else if (element->params_count > 3) |
393 | { | 394 | { |
394 | if (get_param(element, 2)->type == PERCENT) | 395 | struct skin_tag_parameter *param2 = get_param(element, 2); |
395 | x = get_param(element, 2)->data.number * curr_vp->vp.width / 1000; | 396 | struct skin_tag_parameter *param3 = get_param(element, 3); |
397 | if (param2->type == PERCENT) | ||
398 | x = param2->data.number * curr_vp->vp.width / 1000; | ||
396 | else | 399 | else |
397 | x = get_param(element, 2)->data.number; | 400 | x = param2->data.number; |
398 | if (get_param(element, 3)->type == PERCENT) | 401 | if (param3->type == PERCENT) |
399 | y = get_param(element, 3)->data.number * curr_vp->vp.height / 1000; | 402 | y = param3->data.number * curr_vp->vp.height / 1000; |
400 | else | 403 | else |
401 | y = get_param(element, 3)->data.number; | 404 | y = param3->data.number; |
402 | 405 | ||
403 | if (element->params_count == 5) | 406 | if (element->params_count == 5) |
404 | subimages = get_param(element, 4)->data.number; | 407 | subimages = get_param(element, 4)->data.number; |
@@ -561,6 +564,7 @@ static int parse_listitemviewport(struct skin_element *element, | |||
561 | struct wps_data *wps_data) | 564 | struct wps_data *wps_data) |
562 | { | 565 | { |
563 | #ifndef __PCTOOL__ | 566 | #ifndef __PCTOOL__ |
567 | struct skin_tag_parameter *param; | ||
564 | struct listitem_viewport_cfg *cfg = skin_buffer_alloc(sizeof(*cfg)); | 568 | struct listitem_viewport_cfg *cfg = skin_buffer_alloc(sizeof(*cfg)); |
565 | if (!cfg) | 569 | if (!cfg) |
566 | return -1; | 570 | return -1; |
@@ -569,10 +573,15 @@ static int parse_listitemviewport(struct skin_element *element, | |||
569 | cfg->label = PTRTOSKINOFFSET(skin_buffer, get_param_text(element, 0)); | 573 | cfg->label = PTRTOSKINOFFSET(skin_buffer, get_param_text(element, 0)); |
570 | cfg->width = -1; | 574 | cfg->width = -1; |
571 | cfg->height = -1; | 575 | cfg->height = -1; |
572 | if (!isdefault(get_param(element, 1))) | 576 | |
573 | cfg->width = get_param(element, 1)->data.number; | 577 | param = get_param(element, 1); |
574 | if (!isdefault(get_param(element, 2))) | 578 | if (!isdefault(param)) |
575 | cfg->height = get_param(element, 2)->data.number; | 579 | cfg->width = param->data.number; |
580 | |||
581 | param = get_param(element, 2); | ||
582 | if (!isdefault(param)) | ||
583 | cfg->height = param->data.number; | ||
584 | |||
576 | if (element->params_count > 3 && | 585 | if (element->params_count > 3 && |
577 | !strcmp(get_param_text(element, 3), "tile")) | 586 | !strcmp(get_param_text(element, 3), "tile")) |
578 | cfg->tile = true; | 587 | cfg->tile = true; |
@@ -634,34 +643,39 @@ static int parse_drawrectangle( struct skin_element *element, | |||
634 | struct wps_data *wps_data) | 643 | struct wps_data *wps_data) |
635 | { | 644 | { |
636 | (void)wps_data; | 645 | (void)wps_data; |
646 | struct skin_tag_parameter *param; | ||
637 | struct draw_rectangle *rect = skin_buffer_alloc(sizeof(*rect)); | 647 | struct draw_rectangle *rect = skin_buffer_alloc(sizeof(*rect)); |
638 | 648 | ||
639 | if (!rect) | 649 | if (!rect) |
640 | return -1; | 650 | return -1; |
641 | 651 | ||
642 | if (get_param(element, 0)->type == PERCENT) | 652 | param = get_param(element, 0); |
643 | rect->x = get_param(element, 0)->data.number * curr_vp->vp.width / 1000; | 653 | if (param->type == PERCENT) |
654 | rect->x = param->data.number * curr_vp->vp.width / 1000; | ||
644 | else | 655 | else |
645 | rect->x = get_param(element, 0)->data.number; | 656 | rect->x = param->data.number; |
646 | 657 | ||
647 | if (get_param(element, 1)->type == PERCENT) | 658 | param = get_param(element, 1); |
648 | rect->y = get_param(element, 1)->data.number * curr_vp->vp.height / 1000; | 659 | if (param->type == PERCENT) |
660 | rect->y = param->data.number * curr_vp->vp.height / 1000; | ||
649 | else | 661 | else |
650 | rect->y = get_param(element, 1)->data.number; | 662 | rect->y = param->data.number; |
651 | 663 | ||
652 | if (isdefault(get_param(element, 2))) | 664 | param = get_param(element, 2); |
665 | if (isdefault(param)) | ||
653 | rect->width = curr_vp->vp.width - rect->x; | 666 | rect->width = curr_vp->vp.width - rect->x; |
654 | else if (get_param(element, 2)->type == PERCENT) | 667 | else if (param->type == PERCENT) |
655 | rect->width = get_param(element, 2)->data.number * curr_vp->vp.width / 1000; | 668 | rect->width = param->data.number * curr_vp->vp.width / 1000; |
656 | else | 669 | else |
657 | rect->width = get_param(element, 2)->data.number; | 670 | rect->width = param->data.number; |
658 | 671 | ||
659 | if (isdefault(get_param(element, 3))) | 672 | param = get_param(element, 3); |
673 | if (isdefault(param)) | ||
660 | rect->height = curr_vp->vp.height - rect->y; | 674 | rect->height = curr_vp->vp.height - rect->y; |
661 | else if (get_param(element, 3)->type == PERCENT) | 675 | else if (param->type == PERCENT) |
662 | rect->height = get_param(element, 3)->data.number * curr_vp->vp.height / 1000; | 676 | rect->height = param->data.number * curr_vp->vp.height / 1000; |
663 | else | 677 | else |
664 | rect->height = get_param(element, 3)->data.number; | 678 | rect->height = param->data.number; |
665 | 679 | ||
666 | rect->start_colour = curr_vp->vp.fg_pattern; | 680 | rect->start_colour = curr_vp->vp.fg_pattern; |
667 | rect->end_colour = curr_vp->vp.fg_pattern; | 681 | rect->end_colour = curr_vp->vp.fg_pattern; |
@@ -811,19 +825,38 @@ static int parse_logical_if(struct skin_element *element, | |||
811 | token->value.data = PTRTOSKINOFFSET(skin_buffer, lif); | 825 | token->value.data = PTRTOSKINOFFSET(skin_buffer, lif); |
812 | lif->token = get_param_code(element, 0)->data; | 826 | lif->token = get_param_code(element, 0)->data; |
813 | 827 | ||
814 | if (!strncmp(op, "=", 1)) | 828 | /* one or two operator conditionals */ |
815 | lif->op = IF_EQUALS; | 829 | #define OPS2VAL(op1, op2) ((int)op1 << 8 | (int)op2) |
816 | else if (!strncmp(op, "!=", 2)) | 830 | #define CLAUSE(op1, op2, symbol) {OPS2VAL(op1, op2), symbol } |
817 | lif->op = IF_NOTEQUALS; | 831 | |
818 | else if (!strncmp(op, ">=", 2)) | 832 | struct clause_symbol {int value;int symbol;}; |
819 | lif->op = IF_GREATERTHAN_EQ; | 833 | static const struct clause_symbol get_clause_match[] = |
820 | else if (!strncmp(op, "<=", 2)) | 834 | { |
821 | lif->op = IF_LESSTHAN_EQ; | 835 | CLAUSE('=', '=', IF_EQUALS), |
822 | else if (!strncmp(op, ">", 2)) | 836 | CLAUSE('!', '=', IF_NOTEQUALS), |
823 | lif->op = IF_GREATERTHAN; | 837 | CLAUSE('>', '=', IF_GREATERTHAN_EQ), |
824 | else if (!strncmp(op, "<", 1)) | 838 | CLAUSE('<', '=', IF_LESSTHAN_EQ), |
825 | lif->op = IF_LESSTHAN; | 839 | /*All Single value items @ end */ |
826 | 840 | CLAUSE('>', 0, IF_GREATERTHAN), | |
841 | CLAUSE('<', 0, IF_LESSTHAN), | ||
842 | CLAUSE('=', 0, IF_EQUALS), | ||
843 | }; | ||
844 | |||
845 | int val1 = OPS2VAL(op[0], 0); | ||
846 | int val2; | ||
847 | if (val1 != 0) /* Empty string ?*/ | ||
848 | { | ||
849 | val2 = OPS2VAL(op[0], op[1]); | ||
850 | for (unsigned int i = 0; i < ARRAYLEN(get_clause_match); i++) | ||
851 | { | ||
852 | const struct clause_symbol *sym = &get_clause_match[i]; | ||
853 | if(sym->value == val1 || sym->value == val2) | ||
854 | { | ||
855 | lif->op = sym->symbol; | ||
856 | break; | ||
857 | } | ||
858 | } | ||
859 | } | ||
827 | memcpy(&lif->operand, get_param(element, 2), sizeof(lif->operand)); | 860 | memcpy(&lif->operand, get_param(element, 2), sizeof(lif->operand)); |
828 | if (element->params_count > 3) | 861 | if (element->params_count > 3) |
829 | lif->num_options = get_param(element, 3)->data.number; | 862 | lif->num_options = get_param(element, 3)->data.number; |
@@ -1219,22 +1252,27 @@ static int parse_albumart_load(struct skin_element* element, | |||
1219 | aa->xalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ | 1252 | aa->xalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ |
1220 | aa->yalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ | 1253 | aa->yalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ |
1221 | 1254 | ||
1222 | aa->x = get_param(element, 0)->data.number; | 1255 | struct skin_tag_parameter *param0 = get_param(element, 0); |
1223 | aa->y = get_param(element, 1)->data.number; | 1256 | struct skin_tag_parameter *param1 = get_param(element, 1); |
1224 | aa->width = get_param(element, 2)->data.number; | 1257 | struct skin_tag_parameter *param2 = get_param(element, 2); |
1225 | aa->height = get_param(element, 3)->data.number; | 1258 | struct skin_tag_parameter *param3 = get_param(element, 3); |
1259 | |||
1260 | aa->x = param0->data.number; | ||
1261 | aa->y = param1->data.number; | ||
1262 | aa->width = param2->data.number; | ||
1263 | aa->height = param3->data.number; | ||
1226 | 1264 | ||
1227 | if (!isdefault(get_param(element, 0)) && get_param(element, 0)->type == PERCENT) | 1265 | if (!isdefault(param0) && param0->type == PERCENT) |
1228 | aa->x = get_param(element, 0)->data.number * curr_vp->vp.width / 1000; | 1266 | aa->x = param0->data.number * curr_vp->vp.width / 1000; |
1229 | 1267 | ||
1230 | if (!isdefault(get_param(element, 1)) && get_param(element, 1)->type == PERCENT) | 1268 | if (!isdefault(param1) && param1->type == PERCENT) |
1231 | aa->y = get_param(element, 1)->data.number * curr_vp->vp.height / 1000; | 1269 | aa->y = param1->data.number * curr_vp->vp.height / 1000; |
1232 | 1270 | ||
1233 | if (!isdefault(get_param(element, 2)) && get_param(element, 2)->type == PERCENT) | 1271 | if (!isdefault(param2) && param2->type == PERCENT) |
1234 | aa->width = get_param(element, 2)->data.number * curr_vp->vp.width / 1000; | 1272 | aa->width = param2->data.number * curr_vp->vp.width / 1000; |
1235 | 1273 | ||
1236 | if (!isdefault(get_param(element, 3)) && get_param(element, 3)->type == PERCENT) | 1274 | if (!isdefault(param3) && param3->type == PERCENT) |
1237 | aa->height = get_param(element, 3)->data.number * curr_vp->vp.height / 1000; | 1275 | aa->height = param3->data.number * curr_vp->vp.height / 1000; |
1238 | 1276 | ||
1239 | aa->vp = PTRTOSKINOFFSET(skin_buffer, &curr_vp->vp); | 1277 | aa->vp = PTRTOSKINOFFSET(skin_buffer, &curr_vp->vp); |
1240 | aa->draw_handle = -1; | 1278 | aa->draw_handle = -1; |
@@ -1345,23 +1383,24 @@ static int parse_skinvar( struct skin_element *element, | |||
1345 | if (!data) | 1383 | if (!data) |
1346 | return WPS_ERROR_INVALID_PARAM; | 1384 | return WPS_ERROR_INVALID_PARAM; |
1347 | data->var = PTRTOSKINOFFSET(skin_buffer, var); | 1385 | data->var = PTRTOSKINOFFSET(skin_buffer, var); |
1386 | char *text_param1 = get_param_text(element, 1); | ||
1348 | if (!isdefault(get_param(element, 2))) | 1387 | if (!isdefault(get_param(element, 2))) |
1349 | data->newval = get_param(element, 2)->data.number; | 1388 | data->newval = get_param(element, 2)->data.number; |
1350 | else if (strcmp(get_param_text(element, 1), "touch")) | 1389 | else if (strcmp(text_param1, "touch")) |
1351 | return WPS_ERROR_INVALID_PARAM; | 1390 | return WPS_ERROR_INVALID_PARAM; |
1352 | data->max = 0; | 1391 | data->max = 0; |
1353 | if (!strcmp(get_param_text(element, 1), "set")) | 1392 | if (!strcmp(text_param1, "set")) |
1354 | data->direct = true; | 1393 | data->direct = true; |
1355 | else if (!strcmp(get_param_text(element, 1), "inc")) | 1394 | else if (!strcmp(text_param1, "inc")) |
1356 | { | 1395 | { |
1357 | data->direct = false; | 1396 | data->direct = false; |
1358 | } | 1397 | } |
1359 | else if (!strcmp(get_param_text(element, 1), "dec")) | 1398 | else if (!strcmp(text_param1, "dec")) |
1360 | { | 1399 | { |
1361 | data->direct = false; | 1400 | data->direct = false; |
1362 | data->newval *= -1; | 1401 | data->newval *= -1; |
1363 | } | 1402 | } |
1364 | else if (!strcmp(get_param_text(element, 1), "touch")) | 1403 | else if (!strcmp(text_param1, "touch")) |
1365 | { | 1404 | { |
1366 | data->direct = false; | 1405 | data->direct = false; |
1367 | data->newval = 0; | 1406 | data->newval = 0; |
@@ -1403,12 +1442,12 @@ static int parse_lasttouch(struct skin_element *element, | |||
1403 | 1442 | ||
1404 | for (i=0; i<element->params_count; i++) | 1443 | for (i=0; i<element->params_count; i++) |
1405 | { | 1444 | { |
1406 | if (get_param(element, i)->type == STRING) | 1445 | struct skin_tag_parameter *param = get_param(element, i); |
1446 | if (param->type == STRING) | ||
1407 | region = skin_find_item(get_param_text(element, i), | 1447 | region = skin_find_item(get_param_text(element, i), |
1408 | SKIN_FIND_TOUCHREGION, wps_data); | 1448 | SKIN_FIND_TOUCHREGION, wps_data); |
1409 | else if (get_param(element, i)->type == INTEGER || | 1449 | else if (param->type == INTEGER || param->type == DECIMAL) |
1410 | get_param(element, i)->type == DECIMAL) | 1450 | data->timeout = param->data.number; |
1411 | data->timeout = get_param(element, i)->data.number; | ||
1412 | } | 1451 | } |
1413 | 1452 | ||
1414 | data->region = PTRTOSKINOFFSET(skin_buffer, region); | 1453 | data->region = PTRTOSKINOFFSET(skin_buffer, region); |