summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgodly.talias <godly.talias@samsung.com>2015-06-25 16:27:09 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-06-25 17:24:08 +0200
commit1fa9c23544617907caf0e706c74545117f034c7d (patch)
tree11e0e4ff492c3574fa31ca87a29d5dc247c4220e
parent8889b728774bd479294ee5029730c90cdddf4450 (diff)
elm_spinner: add feature in spinner to change values while dragging relative to the speed of dragging
Summary: Currently the values in spinner change while dragging only based on the amount of pixels dragged, this patch will enable Spinner to change value based on the speed of dragging so that it will be more user friendly. This will help users to alter drag values by big amounts if dragged in a good speed. Test Plan: test_spinner.c in elementary_test Reviewers: raster, prince.dubey, shilpasingh, cedric Reviewed By: cedric Subscribers: poornima.srinivasan, rajeshps, govi Differential Revision: https://phab.enlightenment.org/D2659 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--AUTHORS1
-rw-r--r--src/bin/test_spinner.c2
-rw-r--r--src/lib/elm_authors.h1
-rw-r--r--src/lib/elm_spinner.c17
-rw-r--r--src/lib/elm_widget_spinner.h3
5 files changed, 17 insertions, 7 deletions
diff --git a/AUTHORS b/AUTHORS
index 4c6dc9a2d..404439a76 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -164,3 +164,4 @@ Jee-Yong Um <conr2d@gmail.com>
164Ji-In Moon <jiin.moon@samsung.com> 164Ji-In Moon <jiin.moon@samsung.com>
165Subodh Kumar <s7158.kumar@samsung.com> 165Subodh Kumar <s7158.kumar@samsung.com>
166Kumar Navneet <k.navneet@samsung.com> 166Kumar Navneet <k.navneet@samsung.com>
167Godly T Alias <godly.talias@samsung.com>
diff --git a/src/bin/test_spinner.c b/src/bin/test_spinner.c
index e3c2c4dda..41eb63f48 100644
--- a/src/bin/test_spinner.c
+++ b/src/bin/test_spinner.c
@@ -35,7 +35,7 @@ test_spinner(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i
35 elm_spinner_label_format_set(sp, "%1.1f units"); 35 elm_spinner_label_format_set(sp, "%1.1f units");
36 elm_spinner_step_set(sp, 1.3); 36 elm_spinner_step_set(sp, 1.3);
37 elm_spinner_wrap_set(sp, EINA_TRUE); 37 elm_spinner_wrap_set(sp, EINA_TRUE);
38 elm_spinner_min_max_set(sp, -50.0, 250.0); 38 elm_spinner_min_max_set(sp, -5000.0, 5000.0);
39 evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5); 39 evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
40 evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 40 evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
41 evas_object_smart_callback_add(sp, "spinner,drag,start", 41 evas_object_smart_callback_add(sp, "spinner,drag,start",
diff --git a/src/lib/elm_authors.h b/src/lib/elm_authors.h
index 6c2f99672..71cc0f6c1 100644
--- a/src/lib/elm_authors.h
+++ b/src/lib/elm_authors.h
@@ -162,6 +162,7 @@
162 * @author yinsc <shouchen.yin@@samsung.com> 162 * @author yinsc <shouchen.yin@@samsung.com>
163 * @author Subodh Kumar <s7158.kumar@@samsung.com> 163 * @author Subodh Kumar <s7158.kumar@@samsung.com>
164 * @author Kumar Navneet <k.navneet@@samsung.com> 164 * @author Kumar Navneet <k.navneet@@samsung.com>
165 * @author Godly T Alias <godly.talias@@samsung.com>
165 * 166 *
166 * Please contact <enlightenment-devel@lists.sourceforge.net> to get in 167 * Please contact <enlightenment-devel@lists.sourceforge.net> to get in
167 * contact with the developers and maintainers. 168 * contact with the developers and maintainers.
diff --git a/src/lib/elm_spinner.c b/src/lib/elm_spinner.c
index 9624380a6..654e1a67a 100644
--- a/src/lib/elm_spinner.c
+++ b/src/lib/elm_spinner.c
@@ -217,11 +217,18 @@ _drag_cb(void *data,
217 else 217 else
218 eo_do((Eo *)wd->resize_obj, 218 eo_do((Eo *)wd->resize_obj,
219 edje_obj_part_drag_value_get("elm.dragable.slider", &pos, NULL)); 219 edje_obj_part_drag_value_get("elm.dragable.slider", &pos, NULL));
220 if (sd->drag_prev_pos != 0)
221 sd->drag_val_step = pow((pos - sd->drag_prev_pos), 2);
222 else
223 sd->drag_val_step = 1;
224
220 225
221 delta = pos * sd->step * _elm_config->scale; 226 delta = sd->drag_val_step * sd->step * _elm_config->scale;
227 if (pos < sd->drag_prev_pos) delta *= -1;
228 sd->drag_prev_pos = pos;
222 /* If we are on rtl mode, change the delta to be negative on such changes */ 229 /* If we are on rtl mode, change the delta to be negative on such changes */
223 if (elm_widget_mirrored_get(obj)) delta *= -1; 230 if (elm_widget_mirrored_get(obj)) delta *= -1;
224 if (_value_set(data, sd->drag_start_val + delta)) _label_write(data); 231 if (_value_set(data, sd->val + delta)) _label_write(data);
225 sd->dragging = 1; 232 sd->dragging = 1;
226} 233}
227 234
@@ -233,7 +240,8 @@ _drag_start_cb(void *data,
233{ 240{
234 ELM_SPINNER_DATA_GET(data, sd); 241 ELM_SPINNER_DATA_GET(data, sd);
235 242
236 sd->drag_start_val = sd->val; 243 sd->drag_prev_pos = 0;
244 sd->drag_val_step = 1;
237 245
238 evas_object_smart_callback_call(obj, SIG_DRAG_START, NULL); 246 evas_object_smart_callback_call(obj, SIG_DRAG_START, NULL);
239} 247}
@@ -247,7 +255,8 @@ _drag_stop_cb(void *data,
247 ELM_SPINNER_DATA_GET(data, sd); 255 ELM_SPINNER_DATA_GET(data, sd);
248 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); 256 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
249 257
250 sd->drag_start_val = 0; 258 sd->drag_prev_pos = 0;
259 sd->drag_val_step = 1;
251 edje_object_part_drag_value_set 260 edje_object_part_drag_value_set
252 (wd->resize_obj, "elm.dragable.slider", 0.0, 0.0); 261 (wd->resize_obj, "elm.dragable.slider", 0.0, 0.0);
253 262
diff --git a/src/lib/elm_widget_spinner.h b/src/lib/elm_widget_spinner.h
index d0a4939dc..151b704ea 100644
--- a/src/lib/elm_widget_spinner.h
+++ b/src/lib/elm_widget_spinner.h
@@ -32,8 +32,7 @@ struct _Elm_Spinner_Data
32 const char *label; 32 const char *label;
33 double val, val_min, val_max, val_base; 33 double val, val_min, val_max, val_base;
34 double step; /**< step for the value change. 1 by default. */ 34 double step; /**< step for the value change. 1 by default. */
35 double drag_start_val; /**< spinner value on drag start. 35 double drag_prev_pos, drag_val_step;
36 this is reset to 0 when drag stops. */
37 double spin_speed, interval, first_interval; 36 double spin_speed, interval, first_interval;
38 int round; 37 int round;
39 Ecore_Timer *delay_change_timer; /**< a timer for a delay,changed smart callback */ 38 Ecore_Timer *delay_change_timer; /**< a timer for a delay,changed smart callback */