diff options
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 80 |
1 files changed, 71 insertions, 9 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 31dd89d0bb..261a900cd1 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -547,6 +547,7 @@ static int parse_logical_if(struct skin_element *element, | |||
547 | return 0; | 547 | return 0; |
548 | 548 | ||
549 | } | 549 | } |
550 | |||
550 | static int parse_timeout_tag(struct skin_element *element, | 551 | static int parse_timeout_tag(struct skin_element *element, |
551 | struct wps_token *token, | 552 | struct wps_token *token, |
552 | struct wps_data *wps_data) | 553 | struct wps_data *wps_data) |
@@ -562,7 +563,6 @@ static int parse_timeout_tag(struct skin_element *element, | |||
562 | case SKIN_TOKEN_BUTTON_VOLUME: | 563 | case SKIN_TOKEN_BUTTON_VOLUME: |
563 | case SKIN_TOKEN_TRACK_STARTING: | 564 | case SKIN_TOKEN_TRACK_STARTING: |
564 | case SKIN_TOKEN_TRACK_ENDING: | 565 | case SKIN_TOKEN_TRACK_ENDING: |
565 | case SKIN_TOKEN_LASTTOUCH: | ||
566 | val = 10; | 566 | val = 10; |
567 | break; | 567 | break; |
568 | default: | 568 | default: |
@@ -878,6 +878,47 @@ static int parse_albumart_load(struct skin_element* element, | |||
878 | #endif /* HAVE_ALBUMART */ | 878 | #endif /* HAVE_ALBUMART */ |
879 | 879 | ||
880 | #ifdef HAVE_TOUCHSCREEN | 880 | #ifdef HAVE_TOUCHSCREEN |
881 | struct touchregion* find_touchregion(const char *label, | ||
882 | struct wps_data *data) | ||
883 | { | ||
884 | struct skin_token_list *list = data->touchregions; | ||
885 | while (list) | ||
886 | { | ||
887 | struct touchregion *tr = | ||
888 | (struct touchregion *)list->token->value.data; | ||
889 | if (tr->label && !strcmp(tr->label, label)) | ||
890 | return tr; | ||
891 | list = list->next; | ||
892 | } | ||
893 | return NULL; | ||
894 | } | ||
895 | |||
896 | static int parse_lasttouch(struct skin_element *element, | ||
897 | struct wps_token *token, | ||
898 | struct wps_data *wps_data) | ||
899 | { | ||
900 | struct touchregion_lastpress *data = | ||
901 | (struct touchregion_lastpress*)skin_buffer_alloc( | ||
902 | sizeof(struct touchregion_lastpress)); | ||
903 | int i; | ||
904 | if (!data) | ||
905 | return WPS_ERROR_INVALID_PARAM; | ||
906 | data->region = NULL; | ||
907 | data->timeout = 10; | ||
908 | |||
909 | for (i=0; i<element->params_count; i++) | ||
910 | { | ||
911 | if (element->params[i].type == STRING) | ||
912 | data->region = find_touchregion( | ||
913 | element->params[i].data.text, wps_data); | ||
914 | else if (element->params[i].type == INTEGER) | ||
915 | data->timeout = element->params[i].data.number; | ||
916 | } | ||
917 | |||
918 | data->timeout *= TIMEOUT_UNIT; | ||
919 | token->value.data = data; | ||
920 | return 0; | ||
921 | } | ||
881 | 922 | ||
882 | struct touchaction {const char* s; int action;}; | 923 | struct touchaction {const char* s; int action;}; |
883 | static const struct touchaction touchactions[] = { | 924 | static const struct touchaction touchactions[] = { |
@@ -917,6 +958,7 @@ static int parse_touchregion(struct skin_element *element, | |||
917 | { | 958 | { |
918 | (void)token; | 959 | (void)token; |
919 | unsigned i, imax; | 960 | unsigned i, imax; |
961 | int p; | ||
920 | struct touchregion *region = NULL; | 962 | struct touchregion *region = NULL; |
921 | const char *action; | 963 | const char *action; |
922 | const char pb_string[] = "progressbar"; | 964 | const char pb_string[] = "progressbar"; |
@@ -951,15 +993,33 @@ static int parse_touchregion(struct skin_element *element, | |||
951 | 993 | ||
952 | /* should probably do some bounds checking here with the viewport... but later */ | 994 | /* should probably do some bounds checking here with the viewport... but later */ |
953 | region->action = ACTION_NONE; | 995 | region->action = ACTION_NONE; |
954 | region->x = element->params[0].data.number; | 996 | |
955 | region->y = element->params[1].data.number; | 997 | if (element->params[0].type == STRING) |
956 | region->width = element->params[2].data.number; | 998 | { |
957 | region->height = element->params[3].data.number; | 999 | region->label = element->params[0].data.text; |
1000 | p = 1; | ||
1001 | /* "[SI]III[SI]|S" is the param list. There MUST be 4 numbers | ||
1002 | * followed by at least one string. Verify that here */ | ||
1003 | if (element->params_count < 6 || | ||
1004 | element->params[4].type != INTEGER) | ||
1005 | return WPS_ERROR_INVALID_PARAM; | ||
1006 | } | ||
1007 | else | ||
1008 | { | ||
1009 | region->label = NULL; | ||
1010 | p = 0; | ||
1011 | } | ||
1012 | |||
1013 | region->x = element->params[p++].data.number; | ||
1014 | region->y = element->params[p++].data.number; | ||
1015 | region->width = element->params[p++].data.number; | ||
1016 | region->height = element->params[p++].data.number; | ||
958 | region->wvp = curr_vp; | 1017 | region->wvp = curr_vp; |
959 | region->armed = false; | 1018 | region->armed = false; |
960 | region->reverse_bar = false; | 1019 | region->reverse_bar = false; |
961 | region->data = NULL; | 1020 | region->data = NULL; |
962 | action = element->params[4].data.text; | 1021 | region->last_press = 0xffff; |
1022 | action = element->params[p++].data.text; | ||
963 | 1023 | ||
964 | strcpy(temp, action); | 1024 | strcpy(temp, action); |
965 | action = temp; | 1025 | action = temp; |
@@ -996,13 +1056,13 @@ static int parse_touchregion(struct skin_element *element, | |||
996 | if (region->action == ACTION_SETTINGS_INC || | 1056 | if (region->action == ACTION_SETTINGS_INC || |
997 | region->action == ACTION_SETTINGS_DEC) | 1057 | region->action == ACTION_SETTINGS_DEC) |
998 | { | 1058 | { |
999 | if (element->params_count < 6) | 1059 | if (element->params_count < p+1) |
1000 | { | 1060 | { |
1001 | return WPS_ERROR_INVALID_PARAM; | 1061 | return WPS_ERROR_INVALID_PARAM; |
1002 | } | 1062 | } |
1003 | else | 1063 | else |
1004 | { | 1064 | { |
1005 | char *name = element->params[5].data.text; | 1065 | char *name = element->params[p].data.text; |
1006 | int j; | 1066 | int j; |
1007 | /* Find the setting */ | 1067 | /* Find the setting */ |
1008 | for (j=0; j<nb_settings; j++) | 1068 | for (j=0; j<nb_settings; j++) |
@@ -1445,7 +1505,6 @@ static int skin_element_callback(struct skin_element* element, void* data) | |||
1445 | case SKIN_TOKEN_BUTTON_VOLUME: | 1505 | case SKIN_TOKEN_BUTTON_VOLUME: |
1446 | case SKIN_TOKEN_TRACK_STARTING: | 1506 | case SKIN_TOKEN_TRACK_STARTING: |
1447 | case SKIN_TOKEN_TRACK_ENDING: | 1507 | case SKIN_TOKEN_TRACK_ENDING: |
1448 | case SKIN_TOKEN_LASTTOUCH: | ||
1449 | function = parse_timeout_tag; | 1508 | function = parse_timeout_tag; |
1450 | break; | 1509 | break; |
1451 | #ifdef HAVE_LCD_BITMAP | 1510 | #ifdef HAVE_LCD_BITMAP |
@@ -1499,6 +1558,9 @@ static int skin_element_callback(struct skin_element* element, void* data) | |||
1499 | case SKIN_TOKEN_TOUCHREGION: | 1558 | case SKIN_TOKEN_TOUCHREGION: |
1500 | function = parse_touchregion; | 1559 | function = parse_touchregion; |
1501 | break; | 1560 | break; |
1561 | case SKIN_TOKEN_LASTTOUCH: | ||
1562 | function = parse_lasttouch; | ||
1563 | break; | ||
1502 | #endif | 1564 | #endif |
1503 | #ifdef HAVE_ALBUMART | 1565 | #ifdef HAVE_ALBUMART |
1504 | case SKIN_TOKEN_ALBUMART_DISPLAY: | 1566 | case SKIN_TOKEN_ALBUMART_DISPLAY: |