summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/skin_engine')
-rw-r--r--apps/gui/skin_engine/skin_parser.c80
-rw-r--r--apps/gui/skin_engine/skin_tokens.c6
-rw-r--r--apps/gui/skin_engine/skin_touchsupport.c3
-rw-r--r--apps/gui/skin_engine/wps_internals.h7
4 files changed, 86 insertions, 10 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
550static int parse_timeout_tag(struct skin_element *element, 551static 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
881struct 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
896static 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
882struct touchaction {const char* s; int action;}; 923struct touchaction {const char* s; int action;};
883static const struct touchaction touchactions[] = { 924static 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:
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 1fbe3d714e..cf71014a62 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -1413,8 +1413,12 @@ const char *get_token_value(struct gui_wps *gwps,
1413 { 1413 {
1414#ifdef HAVE_TOUCHSCREEN 1414#ifdef HAVE_TOUCHSCREEN
1415 unsigned int last_touch = touchscreen_last_touch(); 1415 unsigned int last_touch = touchscreen_last_touch();
1416 struct touchregion_lastpress *data = token->value.data;
1417 if (data->region)
1418 last_touch = data->region->last_press;
1419
1416 if (last_touch != 0xffff && 1420 if (last_touch != 0xffff &&
1417 TIME_BEFORE(current_tick, token->value.i + last_touch)) 1421 TIME_BEFORE(current_tick, data->timeout + last_touch))
1418 return "t"; 1422 return "t";
1419#endif 1423#endif
1420 } 1424 }
diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c
index 850c1c0647..e5a39cddc5 100644
--- a/apps/gui/skin_engine/skin_touchsupport.c
+++ b/apps/gui/skin_engine/skin_touchsupport.c
@@ -89,7 +89,10 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
89 *retregion = r; 89 *retregion = r;
90 } 90 }
91 if (pressed) 91 if (pressed)
92 {
92 r->armed = true; 93 r->armed = true;
94 r->last_press = current_tick;
95 }
93 break; 96 break;
94 default: 97 default:
95 if (edge_offset) 98 if (edge_offset)
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 83e94b6f8d..28697c8b69 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -182,6 +182,7 @@ struct viewport_colour {
182}; 182};
183#ifdef HAVE_TOUCHSCREEN 183#ifdef HAVE_TOUCHSCREEN
184struct touchregion { 184struct touchregion {
185 char* label; /* label to identify this region */
185 struct skin_viewport* wvp;/* The viewport this region is in */ 186 struct skin_viewport* wvp;/* The viewport this region is in */
186 short int x; /* x-pos */ 187 short int x; /* x-pos */
187 short int y; /* y-pos */ 188 short int y; /* y-pos */
@@ -201,6 +202,12 @@ struct touchregion {
201 void* data; 202 void* data;
202 int value; 203 int value;
203 }; 204 };
205 long last_press; /* last tick this was pressed */
206};
207
208struct touchregion_lastpress {
209 struct touchregion *region;
210 long timeout;
204}; 211};
205#endif 212#endif
206 213