summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-02-24 06:19:25 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-02-24 06:19:25 +0000
commit31fb4f6ff65db32a23217c097d4848fd9292973b (patch)
treee5bb4dba9d6f81880a4494b91425b82178d8477c
parent6c4b80c67bcfb9593852bde584b1e2e6ee3c5c82 (diff)
downloadrockbox-31fb4f6ff65db32a23217c097d4848fd9292973b.tar.gz
rockbox-31fb4f6ff65db32a23217c097d4848fd9292973b.zip
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
-rw-r--r--apps/gui/skin_engine/skin_parser.c1
-rw-r--r--apps/gui/skin_engine/wps_internals.h2
-rw-r--r--apps/gui/wps.c37
-rw-r--r--docs/CREDITS1
4 files changed, 38 insertions, 3 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index cf790c3796..844fe5f120 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -1477,6 +1477,7 @@ static int parse_touchregion(const char *wps_bufptr,
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 04a295a449..f6c7463804 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -222,6 +222,8 @@ struct touchregion {
} 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 6afed43213..c58181ed36 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -86,6 +86,10 @@ static void wps_state_init(void);
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 @@ static void gwps_enter_wps(void)
#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 @@ int wps_get_touchaction(struct wps_data *data)
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 @@ int wps_get_touchaction(struct wps_data *data)
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 @@ int wps_get_touchaction(struct wps_data *data)
global_settings.volume += min_vol;
setvol();
- return ACTION_REDRAW;
+ returncode = ACTION_REDRAW;
}
}
}
@@ -716,6 +740,13 @@ int wps_get_touchaction(struct wps_data *data)
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 d077595b4e..0da7d49367 100644
--- a/docs/CREDITS
+++ b/docs/CREDITS
@@ -530,6 +530,7 @@ Mark Borgerding
Tobias Diedrich
Andrew Engelbrecht
Kevin Schoedel
+Jens Theeß
The libmad team
The wavpack team