Change how touchscreen regions work slightly... "It modifies the behaviour of touch buttons to be more similar to the way gui buttons operate in desktop applications. Upon a touch press event, the button at the touch position is armed. Upon a touch repeat or release, the button at the touch position is triggered only if it is armed. Upon release (and wps entry), all buttons are disarmed. E.g. when you touch press on an empty area, then while pressing drag your finger on a button, then release the button, the button is not triggered."
Author: Jens Theeß
Flyspray: FS#10982
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24876 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index cf790c3..844fe5f 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -1477,6 +1477,7 @@
region->width = w;
region->height = h;
region->wvp = curr_vp;
+ region->armed = false;
if(!strncmp(pb_string, action, sizeof(pb_string)-1)
&& *(action + sizeof(pb_string)-1) == '|')
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 04a295a..f6c7463 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -222,6 +222,8 @@
} type; /* type of touch region */
bool repeat; /* requires the area be held for the action */
int action; /* action this button will return */
+ bool armed; /* A region is armed on press. Only armed regions are triggered
+ on repeat or release. */
};
#endif
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 6afed43..c58181e 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -86,6 +86,10 @@
static void track_changed_callback(void *param);
static void nextid3available_callback(void* param);
+#ifdef HAVE_TOUCHSCREEN
+static void wps_disarm_touchregions(struct wps_data *data);
+#endif
+
#define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps"
#ifdef HAVE_REMOTE_LCD
#define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps"
@@ -623,14 +627,30 @@
#endif
display->clear_display();
skin_update(gwps, WPS_REFRESH_ALL);
+
+#ifdef HAVE_TOUCHSCREEN
+ wps_disarm_touchregions(gui_wps[i].data);
+#endif
}
/* force statusbar/skin update since we just cleared the whole screen */
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1);
}
#ifdef HAVE_TOUCHSCREEN
+/** Disarms all touchregions. */
+static void wps_disarm_touchregions(struct wps_data *data)
+{
+ struct skin_token_list *regions = data->touchregions;
+ while (regions)
+ {
+ ((struct touchregion *)regions->token->value.data)->armed = false;
+ regions = regions->next;
+ }
+}
+
int wps_get_touchaction(struct wps_data *data)
{
+ int returncode = ACTION_NONE;
short x,y;
short vx, vy;
int type = action_get_touchscreen_press(&x, &y);
@@ -638,7 +658,9 @@
struct touchregion *r;
bool repeated = (type == BUTTON_REPEAT);
bool released = (type == BUTTON_REL);
+ bool pressed = (type == BUTTON_TOUCHSCREEN);
struct skin_token_list *regions = data->touchregions;
+
while (regions)
{
r = (struct touchregion *)regions->token->value.data;
@@ -665,11 +687,13 @@
switch(r->type)
{
case WPS_TOUCHREGION_ACTION:
- if ((repeated && r->repeat) || (released && !r->repeat))
+ if (r->armed && ((repeated && r->repeat) || (released && !r->repeat)))
{
last_action = r->action;
- return r->action;
+ returncode = r->action;
}
+ if (pressed)
+ r->armed = true;
break;
case WPS_TOUCHREGION_SCROLLBAR:
if(r->width > r->height)
@@ -708,7 +732,7 @@
global_settings.volume += min_vol;
setvol();
- return ACTION_REDRAW;
+ returncode = ACTION_REDRAW;
}
}
}
@@ -716,6 +740,13 @@
regions = regions->next;
}
+ /* On release, all regions are disarmed. */
+ if (released)
+ wps_disarm_touchregions(data);
+
+ if (returncode != ACTION_NONE)
+ return returncode;
+
if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD))
return ACTION_WPS_STOPSEEK;
last_action = ACTION_TOUCHSCREEN;
diff --git a/docs/CREDITS b/docs/CREDITS
index d077595..0da7d49 100644
--- a/docs/CREDITS
+++ b/docs/CREDITS
@@ -530,6 +530,7 @@
Tobias Diedrich
Andrew Engelbrecht
Kevin Schoedel
+Jens Theeß
The libmad team
The wavpack team