summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-03-01 07:26:11 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-03-01 07:26:11 +0000
commitfb3616368f5e9994716e30a040865f3cf398aa21 (patch)
treea5b6f171e058539394ecab91c45211341d21165b /apps/gui
parent55fab772b7399737e9c22737f91cd3e74c793872 (diff)
downloadrockbox-fb3616368f5e9994716e30a040865f3cf398aa21.tar.gz
rockbox-fb3616368f5e9994716e30a040865f3cf398aa21.zip
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')
-rw-r--r--apps/gui/skin_engine/skin_parser.c2
-rw-r--r--apps/gui/skin_engine/skin_touchsupport.c41
-rw-r--r--apps/gui/statusbar-skinned.c20
-rw-r--r--apps/gui/wps.c20
4 files changed, 37 insertions, 46 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,
999 { 999 {
1000 region->label = element->params[0].data.text; 1000 region->label = element->params[0].data.text;
1001 p = 1; 1001 p = 1;
1002 /* "[SI]III[SI]|S" is the param list. There MUST be 4 numbers 1002 /* "[SI]III[SI]|SS" is the param list. There MUST be 4 numbers
1003 * followed by at least one string. Verify that here */ 1003 * followed by at least one string. Verify that here */
1004 if (element->params_count < 6 || 1004 if (element->params_count < 6 ||
1005 element->params[4].type != INTEGER) 1005 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 @@
24#include "action.h" 24#include "action.h"
25#include "skin_engine.h" 25#include "skin_engine.h"
26#include "wps_internals.h" 26#include "wps_internals.h"
27#include "misc.h"
28#include "option_select.h"
29#include "sound.h"
30
27 31
28/** Disarms all touchregions. */ 32/** Disarms all touchregions. */
29void skin_disarm_touchregions(struct wps_data *data) 33void skin_disarm_touchregions(struct wps_data *data)
@@ -48,7 +52,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
48 short vx, vy; 52 short vx, vy;
49 int type = action_get_touchscreen_press(&x, &y); 53 int type = action_get_touchscreen_press(&x, &y);
50 static int last_action = ACTION_NONE; 54 static int last_action = ACTION_NONE;
51 struct touchregion *r; 55 struct touchregion *r, *temp;
52 bool repeated = (type == BUTTON_REPEAT); 56 bool repeated = (type == BUTTON_REPEAT);
53 bool released = (type == BUTTON_REL); 57 bool released = (type == BUTTON_REL);
54 bool pressed = (type == BUTTON_TOUCHSCREEN); 58 bool pressed = (type == BUTTON_TOUCHSCREEN);
@@ -85,8 +89,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
85 { 89 {
86 last_action = r->action; 90 last_action = r->action;
87 returncode = r->action; 91 returncode = r->action;
88 if (retregion) 92 temp = r;
89 *retregion = r;
90 } 93 }
91 if (pressed) 94 if (pressed)
92 { 95 {
@@ -105,8 +108,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
105 *edge_offset = 100 - *edge_offset; 108 *edge_offset = 100 - *edge_offset;
106 } 109 }
107 returncode = r->type; 110 returncode = r->type;
108 if (retregion) 111 temp = r;
109 *retregion = r;
110 break; 112 break;
111 } 113 }
112 } 114 }
@@ -117,9 +119,38 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
117 /* On release, all regions are disarmed. */ 119 /* On release, all regions are disarmed. */
118 if (released) 120 if (released)
119 skin_disarm_touchregions(data); 121 skin_disarm_touchregions(data);
122 if (retregion)
123 *retregion = temp;
120 124
121 if (returncode != ACTION_NONE) 125 if (returncode != ACTION_NONE)
126 {
127 switch (returncode)
128 {
129 case ACTION_SETTINGS_INC:
130 case ACTION_SETTINGS_DEC:
131 {
132 const struct settings_list *setting = temp->data;
133 option_select_next_val(setting, returncode == ACTION_SETTINGS_DEC, true);
134 returncode = ACTION_REDRAW;
135 }
136 break;
137 case ACTION_TOUCH_MUTE:
138 {
139 const int min_vol = sound_min(SOUND_VOLUME);
140 if (global_settings.volume == min_vol)
141 global_settings.volume = temp->value;
142 else
143 {
144 temp->value = global_settings.volume;
145 global_settings.volume = min_vol;
146 }
147 setvol();
148 returncode = ACTION_REDRAW;
149 }
150 break;
151 }
122 return returncode; 152 return returncode;
153 }
123 154
124 last_action = ACTION_TOUCHSCREEN; 155 last_action = ACTION_TOUCHSCREEN;
125 return ACTION_TOUCHSCREEN; 156 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)
295 case ACTION_WPS_VOLDOWN: 295 case ACTION_WPS_VOLDOWN:
296 return ACTION_LIST_VOLDOWN; 296 return ACTION_LIST_VOLDOWN;
297#endif 297#endif
298 case ACTION_SETTINGS_INC:
299 case ACTION_SETTINGS_DEC:
300 {
301 const struct settings_list *setting = region->data;
302 option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true);
303 }
304 return ACTION_REDRAW;
305 case ACTION_TOUCH_MUTE:
306 {
307 const int min_vol = sound_min(SOUND_VOLUME);
308 if (global_settings.volume == min_vol)
309 global_settings.volume = region->value;
310 else
311 {
312 region->value = global_settings.volume;
313 global_settings.volume = min_vol;
314 }
315 setvol();
316 }
317 return ACTION_REDRAW;
318 /* TODO */ 298 /* TODO */
319 } 299 }
320 return button; 300 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)
239 setvol(); 239 setvol();
240 } 240 }
241 return ACTION_TOUCHSCREEN; 241 return ACTION_TOUCHSCREEN;
242 case ACTION_SETTINGS_INC:
243 case ACTION_SETTINGS_DEC:
244 {
245 const struct settings_list *setting = region->data;
246 option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true);
247 }
248 return ACTION_REDRAW;
249 case ACTION_TOUCH_MUTE:
250 {
251 const int min_vol = sound_min(SOUND_VOLUME);
252 if (global_settings.volume == min_vol)
253 global_settings.volume = region->value;
254 else
255 {
256 region->value = global_settings.volume;
257 global_settings.volume = min_vol;
258 }
259 setvol();
260 }
261 return ACTION_REDRAW;
262 } 242 }
263 return button; 243 return button;
264} 244}