From c60aa98fed0fd5a27a0410b64c9f4aebeb400d65 Mon Sep 17 00:00:00 2001 From: jdgordon Date: Tue, 1 Mar 2011 07:26:11 +0000 Subject: [PATCH] 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_parser.c | 2 +- apps/gui/skin_engine/skin_touchsupport.c | 41 ++++++++++++++++++++++++++++---- apps/gui/statusbar-skinned.c | 20 ---------------- apps/gui/wps.c | 20 ---------------- apps/radio/radio_skin.c | 20 ---------------- lib/skin_parser/tag_table.c | 4 ++-- 6 files changed, 39 insertions(+), 68 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; diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c index 29e8d1a92a..887b0844d7 100644 --- a/apps/gui/statusbar-skinned.c +++ b/apps/gui/statusbar-skinned.c @@ -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; diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 48498fefd4..44e4adb372 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -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; } diff --git a/apps/radio/radio_skin.c b/apps/radio/radio_skin.c index 2e329230f7..c21d4a1046 100644 --- a/apps/radio/radio_skin.c +++ b/apps/radio/radio_skin.c @@ -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; diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c index a4989c1025..68e4b03a4e 100644 --- a/lib/skin_parser/tag_table.c +++ b/lib/skin_parser/tag_table.c @@ -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 }, -- 2.11.4.GIT