From fb3616368f5e9994716e30a040865f3cf398aa21 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Tue, 1 Mar 2011 07:26:11 +0000 Subject: 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 --- apps/gui/skin_engine/skin_touchsupport.c | 41 ++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'apps/gui/skin_engine/skin_touchsupport.c') 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; -- cgit v1.2.3