diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2011-03-01 07:26:11 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2011-03-01 07:26:11 +0000 |
commit | fb3616368f5e9994716e30a040865f3cf398aa21 (patch) | |
tree | a5b6f171e058539394ecab91c45211341d21165b /apps/gui/skin_engine | |
parent | 55fab772b7399737e9c22737f91cd3e74c793872 (diff) |
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
Diffstat (limited to 'apps/gui/skin_engine')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 2 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_touchsupport.c | 41 |
2 files changed, 37 insertions, 6 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 6b0e5e65a0..25734954e5 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -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) diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c index e5a39cddc5..7a2e6c922b 100644 --- a/apps/gui/skin_engine/skin_touchsupport.c +++ b/apps/gui/skin_engine/skin_touchsupport.c @@ -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; |