summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-03-27 07:23:38 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-03-27 07:23:38 +0000
commit443b1349830912add7211e07557029b9c185d948 (patch)
treebffa8efdf04b0eb8d3502e0af4691c9a257f1c8f /apps/gui
parent86c4ec7277ac1c2a130a9ac1a3500c8360af5c7e (diff)
Fix touchregions muting volume, and change &<action> to mean 'needs long press but only fire once'. Use *<action> for 'long press and allow repeats'
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29653 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/skin_engine/skin_parser.c16
-rw-r--r--apps/gui/skin_engine/skin_touchsupport.c38
-rw-r--r--apps/gui/skin_engine/wps_internals.h11
-rw-r--r--apps/gui/wps.c4
4 files changed, 39 insertions, 30 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 236c6feea1..468f6808c4 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -1030,6 +1030,7 @@ static int parse_touchregion(struct skin_element *element,
region->reverse_bar = false;
region->value = 0;
region->last_press = 0xffff;
+ region->press_length = PRESS;
action = element->params[p++].data.text;
strcpy(temp, action);
@@ -1042,20 +1043,23 @@ static int parse_touchregion(struct skin_element *element,
}
if(!strcmp(pb_string, action))
- region->type = WPS_TOUCHREGION_SCROLLBAR;
+ region->action = ACTION_TOUCH_SCROLLBAR;
else if(!strcmp(vol_string, action))
- region->type = WPS_TOUCHREGION_VOLUME;
+ region->action = ACTION_TOUCH_VOLUME;
else
{
- region->type = WPS_TOUCHREGION_ACTION;
-
if (*action == '&')
{
action++;
- region->repeat = true;
+ region->press_length = LONG_PRESS;
+ }
+ else if(*action == '*')
+ {
+ action++;
+ region->press_length = REPEAT;
}
else
- region->repeat = false;
+ region->press_length = PRESS;
imax = ARRAYLEN(touchactions);
for (i = 0; i < imax; i++)
diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c
index e1a7d0688e..beb6780c3c 100644
--- a/apps/gui/skin_engine/skin_touchsupport.c
+++ b/apps/gui/skin_engine/skin_touchsupport.c
@@ -62,6 +62,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
bool released = (type == BUTTON_REL);
bool pressed = (type == BUTTON_TOUCHSCREEN);
struct skin_token_list *regions = data->touchregions;
+ bool needs_repeat;
while (regions)
{
@@ -72,6 +73,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
regions = regions->next;
continue;
}
+ needs_repeat = r->press_length != PRESS;
/* check if it's inside this viewport */
if (viewport_point_within_vp(&(r->wvp->vp), x, y))
{ /* reposition the touch inside the viewport since touchregions
@@ -87,22 +89,10 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
vy -= r->y;
- switch(r->type)
+ switch(r->action)
{
- case WPS_TOUCHREGION_ACTION:
- if (r->armed && ((repeated && r->repeat) || (released && !r->repeat)))
- {
- last_action = r->action;
- returncode = r->action;
- temp = r;
- }
- if (pressed)
- {
- r->armed = true;
- r->last_press = current_tick;
- }
- break;
- default:
+ case ACTION_TOUCH_SCROLLBAR:
+ case ACTION_TOUCH_VOLUME:
if (edge_offset)
{
if(r->width > r->height)
@@ -112,8 +102,22 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
if (r->reverse_bar)
*edge_offset = 100 - *edge_offset;
}
- returncode = r->type;
temp = r;
+ returncode = r->action;
+ break;
+ default:
+ if (r->armed && ((repeated && needs_repeat) ||
+ (released && !needs_repeat)))
+ {
+ last_action = r->action;
+ returncode = r->action;
+ temp = r;
+ }
+ if (pressed)
+ {
+ r->armed = true;
+ r->last_press = current_tick;
+ }
break;
}
}
@@ -126,6 +130,8 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
skin_disarm_touchregions(data);
if (retregion && temp)
*retregion = temp;
+ if (temp && temp->press_length == LONG_PRESS)
+ temp->armed = false;
if (returncode != ACTION_NONE)
{
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 47453ed34b..0f5cb6df0c 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -188,13 +188,12 @@ struct touchregion {
short int y; /* y-pos */
short int width; /* width */
short int height; /* height */
- enum {
- WPS_TOUCHREGION_ACTION,
- WPS_TOUCHREGION_SCROLLBAR,
- WPS_TOUCHREGION_VOLUME
- } type; /* type of touch region */
bool reverse_bar; /* if true 0% is the left or top */
- bool repeat; /* requires the area be held for the action */
+ enum {
+ PRESS, /* quick press only */
+ LONG_PRESS, /* Long press without repeat */
+ REPEAT, /* long press allowing repeats */
+ } press_length;
int action; /* action this button will return */
bool armed; /* A region is armed on press. Only armed regions are triggered
on repeat or release. */
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index fc91b9abb2..c33268e6bd 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -217,7 +217,7 @@ static int skintouch_to_wps(struct wps_data *data)
case ACTION_STD_HOTKEY:
return ACTION_WPS_HOTKEY;
#endif
- case WPS_TOUCHREGION_SCROLLBAR:
+ case ACTION_TOUCH_SCROLLBAR:
skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100;
if (!skin_get_global_state()->paused)
#if (CONFIG_CODEC == SWCODEC)
@@ -231,7 +231,7 @@ static int skintouch_to_wps(struct wps_data *data)
audio_resume();
#endif
return ACTION_TOUCHSCREEN;
- case WPS_TOUCHREGION_VOLUME:
+ case ACTION_TOUCH_VOLUME:
{
const int min_vol = sound_min(SOUND_VOLUME);
const int max_vol = sound_max(SOUND_VOLUME);