summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r--apps/gui/skin_engine/skin_parser.c80
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,
return 0;
}
+
static int parse_timeout_tag(struct skin_element *element,
struct wps_token *token,
struct wps_data *wps_data)
@@ -562,7 +563,6 @@ static int parse_timeout_tag(struct skin_element *element,
case SKIN_TOKEN_BUTTON_VOLUME:
case SKIN_TOKEN_TRACK_STARTING:
case SKIN_TOKEN_TRACK_ENDING:
- case SKIN_TOKEN_LASTTOUCH:
val = 10;
break;
default:
@@ -878,6 +878,47 @@ static int parse_albumart_load(struct skin_element* element,
#endif /* HAVE_ALBUMART */
#ifdef HAVE_TOUCHSCREEN
+struct touchregion* find_touchregion(const char *label,
+ struct wps_data *data)
+{
+ struct skin_token_list *list = data->touchregions;
+ while (list)
+ {
+ struct touchregion *tr =
+ (struct touchregion *)list->token->value.data;
+ if (tr->label && !strcmp(tr->label, label))
+ return tr;
+ list = list->next;
+ }
+ return NULL;
+}
+
+static int parse_lasttouch(struct skin_element *element,
+ struct wps_token *token,
+ struct wps_data *wps_data)
+{
+ struct touchregion_lastpress *data =
+ (struct touchregion_lastpress*)skin_buffer_alloc(
+ sizeof(struct touchregion_lastpress));
+ int i;
+ if (!data)
+ return WPS_ERROR_INVALID_PARAM;
+ data->region = NULL;
+ data->timeout = 10;
+
+ for (i=0; i<element->params_count; i++)
+ {
+ if (element->params[i].type == STRING)
+ data->region = find_touchregion(
+ element->params[i].data.text, wps_data);
+ else if (element->params[i].type == INTEGER)
+ data->timeout = element->params[i].data.number;
+ }
+
+ data->timeout *= TIMEOUT_UNIT;
+ token->value.data = data;
+ return 0;
+}
struct touchaction {const char* s; int action;};
static const struct touchaction touchactions[] = {
@@ -917,6 +958,7 @@ static int parse_touchregion(struct skin_element *element,
{
(void)token;
unsigned i, imax;
+ int p;
struct touchregion *region = NULL;
const char *action;
const char pb_string[] = "progressbar";
@@ -951,15 +993,33 @@ static int parse_touchregion(struct skin_element *element,
/* should probably do some bounds checking here with the viewport... but later */
region->action = ACTION_NONE;
- region->x = element->params[0].data.number;
- region->y = element->params[1].data.number;
- region->width = element->params[2].data.number;
- region->height = element->params[3].data.number;
+
+ if (element->params[0].type == STRING)
+ {
+ region->label = element->params[0].data.text;
+ p = 1;
+ /* "[SI]III[SI]|S" is the param list. There MUST be 4 numbers
+ * followed by at least one string. Verify that here */
+ if (element->params_count < 6 ||
+ element->params[4].type != INTEGER)
+ return WPS_ERROR_INVALID_PARAM;
+ }
+ else
+ {
+ region->label = NULL;
+ p = 0;
+ }
+
+ region->x = element->params[p++].data.number;
+ region->y = element->params[p++].data.number;
+ region->width = element->params[p++].data.number;
+ region->height = element->params[p++].data.number;
region->wvp = curr_vp;
region->armed = false;
region->reverse_bar = false;
region->data = NULL;
- action = element->params[4].data.text;
+ region->last_press = 0xffff;
+ action = element->params[p++].data.text;
strcpy(temp, action);
action = temp;
@@ -996,13 +1056,13 @@ static int parse_touchregion(struct skin_element *element,
if (region->action == ACTION_SETTINGS_INC ||
region->action == ACTION_SETTINGS_DEC)
{
- if (element->params_count < 6)
+ if (element->params_count < p+1)
{
return WPS_ERROR_INVALID_PARAM;
}
else
{
- char *name = element->params[5].data.text;
+ char *name = element->params[p].data.text;
int j;
/* Find the setting */
for (j=0; j<nb_settings; j++)
@@ -1445,7 +1505,6 @@ static int skin_element_callback(struct skin_element* element, void* data)
case SKIN_TOKEN_BUTTON_VOLUME:
case SKIN_TOKEN_TRACK_STARTING:
case SKIN_TOKEN_TRACK_ENDING:
- case SKIN_TOKEN_LASTTOUCH:
function = parse_timeout_tag;
break;
#ifdef HAVE_LCD_BITMAP
@@ -1499,6 +1558,9 @@ static int skin_element_callback(struct skin_element* element, void* data)
case SKIN_TOKEN_TOUCHREGION:
function = parse_touchregion;
break;
+ case SKIN_TOKEN_LASTTOUCH:
+ function = parse_lasttouch;
+ break;
#endif
#ifdef HAVE_ALBUMART
case SKIN_TOKEN_ALBUMART_DISPLAY: