From 271643c585952a9a45403b7136be4b0966d66662 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 16 Aug 2009 21:22:57 +0000 Subject: remove the limit of touch regions in touchscreen skins git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22361 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_parser.c | 19 +++++++++++++------ apps/gui/skin_engine/wps_internals.h | 3 +-- apps/gui/wps.c | 10 +++++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 56e9e2b897..20156a665c 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -356,7 +356,7 @@ static const struct wps_tag all_tags[] = { }; -/* add a wpsll item to the list chain. ALWAYS appended because some of the +/* add a skin_token_list item to the list chain. ALWAYS appended because some of the * chains require the order to be kept. */ static void add_to_ll_chain(struct skin_token_list **list, struct skin_token_list *item) @@ -373,6 +373,8 @@ static void add_to_ll_chain(struct skin_token_list **list, struct skin_token_lis } /* create and init a new wpsll item. * passing NULL to token will alloc a new one. + * You should only pass NULL for the token when the token type (table above) + * is WPS_NO_TOKEN which means it is not stored automatically in the skins token array */ static struct skin_token_list *new_skin_token_list_item(struct wps_token *token, void* token_data) @@ -1102,7 +1104,7 @@ static int parse_touchregion(const char *wps_bufptr, { (void)token; unsigned i, imax; - struct touchregion *region; + struct touchregion *region = NULL; const char *ptr = wps_bufptr; const char *action; const char pb_string[] = "progressbar"; @@ -1127,7 +1129,7 @@ static int parse_touchregion(const char *wps_bufptr, */ - if ((wps_data->touchregion_count +1 >= MAX_TOUCHREGIONS) || (*ptr != '|')) + if (*ptr != '|') return WPS_ERROR_INVALID_PARAM; ptr++; @@ -1138,8 +1140,11 @@ static int parse_touchregion(const char *wps_bufptr, if (*ptr != '|') return WPS_ERROR_INVALID_PARAM; + region = skin_buffer_alloc(sizeof(struct touchregion)); + if (!region) + return WPS_ERROR_INVALID_PARAM; + /* should probably do some bounds checking here with the viewport... but later */ - region = &wps_data->touchregion[wps_data->touchregion_count]; region->action = ACTION_NONE; region->x = x; region->y = y; @@ -1180,8 +1185,10 @@ static int parse_touchregion(const char *wps_bufptr, if (region->action == ACTION_NONE) return WPS_ERROR_INVALID_PARAM; } - - wps_data->touchregion_count++; + struct skin_token_list *item = new_skin_token_list_item(NULL, region); + if (!item) + return WPS_ERROR_INVALID_PARAM; + add_to_ll_chain(&wps_data->touchregions, item); return skip_end_of_line(wps_bufptr); } #endif diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index bb68e578ab..813a92a2b9 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -254,8 +254,7 @@ struct wps_data #endif #ifdef HAVE_TOUCHSCREEN - struct touchregion touchregion[MAX_TOUCHREGIONS]; - short touchregion_count; + struct skin_token_list *touchregions; #endif #ifdef HAVE_REMOTE_LCD diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 30c4aa85bb..b57f06d2b5 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -577,17 +577,20 @@ int wps_get_touchaction(struct wps_data *data) short x,y; short vx, vy; int type = action_get_touchscreen_press(&x, &y); - int i; static int last_action = ACTION_NONE; struct touchregion *r; bool repeated = (type == BUTTON_REPEAT); bool released = (type == BUTTON_REL); - for (i=0; itouchregion_count; i++) + struct skin_token_list *regions = data->touchregions; + while (regions) { - r = &data->touchregion[i]; + r = (struct touchregion *)regions->token->value.data; /* make sure this region's viewport is visible */ if (r->wvp->hidden_flags&VP_DRAW_HIDDEN) + { + regions = regions->next; continue; + } /* reposition the touch inside the viewport */ vx = x - r->wvp->vp.x; vy = y - r->wvp->vp.y; @@ -644,6 +647,7 @@ int wps_get_touchaction(struct wps_data *data) } } } + regions = regions->next; } if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD)) -- cgit v1.2.3