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
This commit is contained in:
Jonathan Gordon 2010-02-24 06:19:25 +00:00
parent 6c4b80c67b
commit 31fb4f6ff6
4 changed files with 38 additions and 3 deletions

View file

@ -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) == '|')

View file

@ -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

View file

@ -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;

View file

@ -530,6 +530,7 @@ Mark Borgerding
Tobias Diedrich
Andrew Engelbrecht
Kevin Schoedel
Jens Theeß
The libmad team
The wavpack team