diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2009-08-16 21:22:57 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2009-08-16 21:22:57 +0000 |
commit | 271643c585952a9a45403b7136be4b0966d66662 (patch) | |
tree | b2c451e3f2a54fe76ee81881a2c66ea44d1cb5fa /apps/gui | |
parent | e49ffb23fc36e8a2ed468c7679219fe42da61889 (diff) | |
download | rockbox-271643c585952a9a45403b7136be4b0966d66662.tar.gz rockbox-271643c585952a9a45403b7136be4b0966d66662.zip |
remove the limit of touch regions in touchscreen skins
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22361 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 19 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 3 | ||||
-rw-r--r-- | 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[] = { | |||
356 | }; | 356 | }; |
357 | 357 | ||
358 | 358 | ||
359 | /* add a wpsll item to the list chain. ALWAYS appended because some of the | 359 | /* add a skin_token_list item to the list chain. ALWAYS appended because some of the |
360 | * chains require the order to be kept. | 360 | * chains require the order to be kept. |
361 | */ | 361 | */ |
362 | static void add_to_ll_chain(struct skin_token_list **list, struct skin_token_list *item) | 362 | 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 | |||
373 | } | 373 | } |
374 | /* create and init a new wpsll item. | 374 | /* create and init a new wpsll item. |
375 | * passing NULL to token will alloc a new one. | 375 | * passing NULL to token will alloc a new one. |
376 | * You should only pass NULL for the token when the token type (table above) | ||
377 | * is WPS_NO_TOKEN which means it is not stored automatically in the skins token array | ||
376 | */ | 378 | */ |
377 | static struct skin_token_list *new_skin_token_list_item(struct wps_token *token, | 379 | static struct skin_token_list *new_skin_token_list_item(struct wps_token *token, |
378 | void* token_data) | 380 | void* token_data) |
@@ -1102,7 +1104,7 @@ static int parse_touchregion(const char *wps_bufptr, | |||
1102 | { | 1104 | { |
1103 | (void)token; | 1105 | (void)token; |
1104 | unsigned i, imax; | 1106 | unsigned i, imax; |
1105 | struct touchregion *region; | 1107 | struct touchregion *region = NULL; |
1106 | const char *ptr = wps_bufptr; | 1108 | const char *ptr = wps_bufptr; |
1107 | const char *action; | 1109 | const char *action; |
1108 | const char pb_string[] = "progressbar"; | 1110 | const char pb_string[] = "progressbar"; |
@@ -1127,7 +1129,7 @@ static int parse_touchregion(const char *wps_bufptr, | |||
1127 | */ | 1129 | */ |
1128 | 1130 | ||
1129 | 1131 | ||
1130 | if ((wps_data->touchregion_count +1 >= MAX_TOUCHREGIONS) || (*ptr != '|')) | 1132 | if (*ptr != '|') |
1131 | return WPS_ERROR_INVALID_PARAM; | 1133 | return WPS_ERROR_INVALID_PARAM; |
1132 | ptr++; | 1134 | ptr++; |
1133 | 1135 | ||
@@ -1138,8 +1140,11 @@ static int parse_touchregion(const char *wps_bufptr, | |||
1138 | if (*ptr != '|') | 1140 | if (*ptr != '|') |
1139 | return WPS_ERROR_INVALID_PARAM; | 1141 | return WPS_ERROR_INVALID_PARAM; |
1140 | 1142 | ||
1143 | region = skin_buffer_alloc(sizeof(struct touchregion)); | ||
1144 | if (!region) | ||
1145 | return WPS_ERROR_INVALID_PARAM; | ||
1146 | |||
1141 | /* should probably do some bounds checking here with the viewport... but later */ | 1147 | /* should probably do some bounds checking here with the viewport... but later */ |
1142 | region = &wps_data->touchregion[wps_data->touchregion_count]; | ||
1143 | region->action = ACTION_NONE; | 1148 | region->action = ACTION_NONE; |
1144 | region->x = x; | 1149 | region->x = x; |
1145 | region->y = y; | 1150 | region->y = y; |
@@ -1180,8 +1185,10 @@ static int parse_touchregion(const char *wps_bufptr, | |||
1180 | if (region->action == ACTION_NONE) | 1185 | if (region->action == ACTION_NONE) |
1181 | return WPS_ERROR_INVALID_PARAM; | 1186 | return WPS_ERROR_INVALID_PARAM; |
1182 | } | 1187 | } |
1183 | 1188 | struct skin_token_list *item = new_skin_token_list_item(NULL, region); | |
1184 | wps_data->touchregion_count++; | 1189 | if (!item) |
1190 | return WPS_ERROR_INVALID_PARAM; | ||
1191 | add_to_ll_chain(&wps_data->touchregions, item); | ||
1185 | return skip_end_of_line(wps_bufptr); | 1192 | return skip_end_of_line(wps_bufptr); |
1186 | } | 1193 | } |
1187 | #endif | 1194 | #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 | |||
254 | #endif | 254 | #endif |
255 | 255 | ||
256 | #ifdef HAVE_TOUCHSCREEN | 256 | #ifdef HAVE_TOUCHSCREEN |
257 | struct touchregion touchregion[MAX_TOUCHREGIONS]; | 257 | struct skin_token_list *touchregions; |
258 | short touchregion_count; | ||
259 | #endif | 258 | #endif |
260 | 259 | ||
261 | #ifdef HAVE_REMOTE_LCD | 260 | #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) | |||
577 | short x,y; | 577 | short x,y; |
578 | short vx, vy; | 578 | short vx, vy; |
579 | int type = action_get_touchscreen_press(&x, &y); | 579 | int type = action_get_touchscreen_press(&x, &y); |
580 | int i; | ||
581 | static int last_action = ACTION_NONE; | 580 | static int last_action = ACTION_NONE; |
582 | struct touchregion *r; | 581 | struct touchregion *r; |
583 | bool repeated = (type == BUTTON_REPEAT); | 582 | bool repeated = (type == BUTTON_REPEAT); |
584 | bool released = (type == BUTTON_REL); | 583 | bool released = (type == BUTTON_REL); |
585 | for (i=0; i<data->touchregion_count; i++) | 584 | struct skin_token_list *regions = data->touchregions; |
585 | while (regions) | ||
586 | { | 586 | { |
587 | r = &data->touchregion[i]; | 587 | r = (struct touchregion *)regions->token->value.data; |
588 | /* make sure this region's viewport is visible */ | 588 | /* make sure this region's viewport is visible */ |
589 | if (r->wvp->hidden_flags&VP_DRAW_HIDDEN) | 589 | if (r->wvp->hidden_flags&VP_DRAW_HIDDEN) |
590 | { | ||
591 | regions = regions->next; | ||
590 | continue; | 592 | continue; |
593 | } | ||
591 | /* reposition the touch inside the viewport */ | 594 | /* reposition the touch inside the viewport */ |
592 | vx = x - r->wvp->vp.x; | 595 | vx = x - r->wvp->vp.x; |
593 | vy = y - r->wvp->vp.y; | 596 | vy = y - r->wvp->vp.y; |
@@ -644,6 +647,7 @@ int wps_get_touchaction(struct wps_data *data) | |||
644 | } | 647 | } |
645 | } | 648 | } |
646 | } | 649 | } |
650 | regions = regions->next; | ||
647 | } | 651 | } |
648 | 652 | ||
649 | if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD)) | 653 | if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD)) |