Remove code duplication in some generic skin touch action handling.
fix a bug which stopped the setting_inc/dec touch actions from parsing git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29477 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
55fab772b7
commit
fb3616368f
6 changed files with 39 additions and 68 deletions
|
@ -999,7 +999,7 @@ static int parse_touchregion(struct skin_element *element,
|
|||
{
|
||||
region->label = element->params[0].data.text;
|
||||
p = 1;
|
||||
/* "[SI]III[SI]|S" is the param list. There MUST be 4 numbers
|
||||
/* "[SI]III[SI]|SS" is the param list. There MUST be 4 numbers
|
||||
* followed by at least one string. Verify that here */
|
||||
if (element->params_count < 6 ||
|
||||
element->params[4].type != INTEGER)
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
#include "action.h"
|
||||
#include "skin_engine.h"
|
||||
#include "wps_internals.h"
|
||||
#include "misc.h"
|
||||
#include "option_select.h"
|
||||
#include "sound.h"
|
||||
|
||||
|
||||
/** Disarms all touchregions. */
|
||||
void skin_disarm_touchregions(struct wps_data *data)
|
||||
|
@ -48,7 +52,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
|
|||
short vx, vy;
|
||||
int type = action_get_touchscreen_press(&x, &y);
|
||||
static int last_action = ACTION_NONE;
|
||||
struct touchregion *r;
|
||||
struct touchregion *r, *temp;
|
||||
bool repeated = (type == BUTTON_REPEAT);
|
||||
bool released = (type == BUTTON_REL);
|
||||
bool pressed = (type == BUTTON_TOUCHSCREEN);
|
||||
|
@ -85,8 +89,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
|
|||
{
|
||||
last_action = r->action;
|
||||
returncode = r->action;
|
||||
if (retregion)
|
||||
*retregion = r;
|
||||
temp = r;
|
||||
}
|
||||
if (pressed)
|
||||
{
|
||||
|
@ -105,8 +108,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
|
|||
*edge_offset = 100 - *edge_offset;
|
||||
}
|
||||
returncode = r->type;
|
||||
if (retregion)
|
||||
*retregion = r;
|
||||
temp = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -117,9 +119,38 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
|
|||
/* On release, all regions are disarmed. */
|
||||
if (released)
|
||||
skin_disarm_touchregions(data);
|
||||
if (retregion)
|
||||
*retregion = temp;
|
||||
|
||||
if (returncode != ACTION_NONE)
|
||||
{
|
||||
switch (returncode)
|
||||
{
|
||||
case ACTION_SETTINGS_INC:
|
||||
case ACTION_SETTINGS_DEC:
|
||||
{
|
||||
const struct settings_list *setting = temp->data;
|
||||
option_select_next_val(setting, returncode == ACTION_SETTINGS_DEC, true);
|
||||
returncode = ACTION_REDRAW;
|
||||
}
|
||||
break;
|
||||
case ACTION_TOUCH_MUTE:
|
||||
{
|
||||
const int min_vol = sound_min(SOUND_VOLUME);
|
||||
if (global_settings.volume == min_vol)
|
||||
global_settings.volume = temp->value;
|
||||
else
|
||||
{
|
||||
temp->value = global_settings.volume;
|
||||
global_settings.volume = min_vol;
|
||||
}
|
||||
setvol();
|
||||
returncode = ACTION_REDRAW;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return returncode;
|
||||
}
|
||||
|
||||
last_action = ACTION_TOUCHSCREEN;
|
||||
return ACTION_TOUCHSCREEN;
|
||||
|
|
|
@ -295,26 +295,6 @@ int sb_touch_to_button(int context)
|
|||
case ACTION_WPS_VOLDOWN:
|
||||
return ACTION_LIST_VOLDOWN;
|
||||
#endif
|
||||
case ACTION_SETTINGS_INC:
|
||||
case ACTION_SETTINGS_DEC:
|
||||
{
|
||||
const struct settings_list *setting = region->data;
|
||||
option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true);
|
||||
}
|
||||
return ACTION_REDRAW;
|
||||
case ACTION_TOUCH_MUTE:
|
||||
{
|
||||
const int min_vol = sound_min(SOUND_VOLUME);
|
||||
if (global_settings.volume == min_vol)
|
||||
global_settings.volume = region->value;
|
||||
else
|
||||
{
|
||||
region->value = global_settings.volume;
|
||||
global_settings.volume = min_vol;
|
||||
}
|
||||
setvol();
|
||||
}
|
||||
return ACTION_REDRAW;
|
||||
/* TODO */
|
||||
}
|
||||
return button;
|
||||
|
|
|
@ -239,26 +239,6 @@ static int skintouch_to_wps(struct wps_data *data)
|
|||
setvol();
|
||||
}
|
||||
return ACTION_TOUCHSCREEN;
|
||||
case ACTION_SETTINGS_INC:
|
||||
case ACTION_SETTINGS_DEC:
|
||||
{
|
||||
const struct settings_list *setting = region->data;
|
||||
option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true);
|
||||
}
|
||||
return ACTION_REDRAW;
|
||||
case ACTION_TOUCH_MUTE:
|
||||
{
|
||||
const int min_vol = sound_min(SOUND_VOLUME);
|
||||
if (global_settings.volume == min_vol)
|
||||
global_settings.volume = region->value;
|
||||
else
|
||||
{
|
||||
region->value = global_settings.volume;
|
||||
global_settings.volume = min_vol;
|
||||
}
|
||||
setvol();
|
||||
}
|
||||
return ACTION_REDRAW;
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
|
|
@ -121,26 +121,6 @@ int fms_do_button_loop(bool update_screen)
|
|||
case WPS_TOUCHREGION_SCROLLBAR:
|
||||
/* TODO */
|
||||
break;
|
||||
case ACTION_SETTINGS_INC:
|
||||
case ACTION_SETTINGS_DEC:
|
||||
{
|
||||
const struct settings_list *setting = region->data;
|
||||
option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true);
|
||||
}
|
||||
return ACTION_REDRAW;
|
||||
case ACTION_TOUCH_MUTE:
|
||||
{
|
||||
const int min_vol = sound_min(SOUND_VOLUME);
|
||||
if (global_settings.volume == min_vol)
|
||||
global_settings.volume = region->value;
|
||||
else
|
||||
{
|
||||
region->value = global_settings.volume;
|
||||
global_settings.volume = min_vol;
|
||||
}
|
||||
setvol();
|
||||
}
|
||||
return ACTION_REDRAW;
|
||||
}
|
||||
#endif
|
||||
return button;
|
||||
|
|
|
@ -206,10 +206,10 @@ static const struct tag_info legal_tags[] =
|
|||
/* HACK Alert (jdgordon): The next two tags have hacks so we could
|
||||
* add a S param at the front without breaking old skins.
|
||||
* [SD]D <- handled by the callback, allows SD or S or D params
|
||||
* [SI]III[SI]|S -< SIIIIS|S or IIIIS|S
|
||||
* [SI]III[SI]|SS -< SIIIIS|S or IIIIS|S
|
||||
* keep in sync with parse_touchregion() and parse_lasttouch() */
|
||||
{ SKIN_TOKEN_LASTTOUCH, "Tl" , "|[SD]D", SKIN_REFRESH_DYNAMIC },
|
||||
{ SKIN_TOKEN_TOUCHREGION, "T" , "[SI]III[SI]|S", 0|NOBREAK },
|
||||
{ SKIN_TOKEN_TOUCHREGION, "T" , "[SI]III[SI]|SS", 0|NOBREAK },
|
||||
|
||||
{ SKIN_TOKEN_HAVE_TOUCH, "Tp", "", FEATURE_TAG },
|
||||
|
||||
|
|
Loading…
Reference in a new issue