cedric pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=1fa9c23544617907caf0e706c74545117f034c7d

commit 1fa9c23544617907caf0e706c74545117f034c7d
Author: godly.talias <godly.tal...@samsung.com>
Date:   Thu Jun 25 16:27:09 2015 +0200

    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 <ced...@osg.samsung.com>
---
 AUTHORS                      |  1 +
 src/bin/test_spinner.c       |  2 +-
 src/lib/elm_authors.h        |  1 +
 src/lib/elm_spinner.c        | 17 +++++++++++++----
 src/lib/elm_widget_spinner.h |  3 +--
 5 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 4c6dc9a..404439a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -164,3 +164,4 @@ Jee-Yong Um <con...@gmail.com>
 Ji-In Moon <jiin.m...@samsung.com> 
 Subodh Kumar <s7158.ku...@samsung.com>
 Kumar Navneet <k.navn...@samsung.com>
+Godly T Alias <godly.tal...@samsung.com>
diff --git a/src/bin/test_spinner.c b/src/bin/test_spinner.c
index e3c2c4d..41eb63f 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
    elm_spinner_label_format_set(sp, "%1.1f units");
    elm_spinner_step_set(sp, 1.3);
    elm_spinner_wrap_set(sp, EINA_TRUE);
-   elm_spinner_min_max_set(sp, -50.0, 250.0);
+   elm_spinner_min_max_set(sp, -5000.0, 5000.0);
    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_smart_callback_add(sp, "spinner,drag,start",
diff --git a/src/lib/elm_authors.h b/src/lib/elm_authors.h
index 6c2f996..71cc0f6 100644
--- a/src/lib/elm_authors.h
+++ b/src/lib/elm_authors.h
@@ -162,6 +162,7 @@
  * @author yinsc <shouchen.yin@@samsung.com>
  * @author Subodh Kumar <s7158.kumar@@samsung.com>
  * @author Kumar Navneet <k.navneet@@samsung.com>
+ * @author Godly T Alias <godly.talias@@samsung.com>
  *
  * Please contact <enlightenment-de...@lists.sourceforge.net> to get in
  * contact with the developers and maintainers.
diff --git a/src/lib/elm_spinner.c b/src/lib/elm_spinner.c
index 9624380..654e1a6 100644
--- a/src/lib/elm_spinner.c
+++ b/src/lib/elm_spinner.c
@@ -217,11 +217,18 @@ _drag_cb(void *data,
    else
      eo_do((Eo *)wd->resize_obj,
            edje_obj_part_drag_value_get("elm.dragable.slider", &pos, NULL));
+   if (sd->drag_prev_pos != 0)
+     sd->drag_val_step = pow((pos - sd->drag_prev_pos), 2);
+   else
+     sd->drag_val_step = 1;
+
 
-   delta = pos * sd->step * _elm_config->scale;
+   delta = sd->drag_val_step * sd->step * _elm_config->scale;
+   if (pos < sd->drag_prev_pos) delta *= -1;
+   sd->drag_prev_pos = pos;
    /* If we are on rtl mode, change the delta to be negative on such changes */
    if (elm_widget_mirrored_get(obj)) delta *= -1;
-   if (_value_set(data, sd->drag_start_val + delta)) _label_write(data);
+   if (_value_set(data, sd->val + delta)) _label_write(data);
    sd->dragging = 1;
 }
 
@@ -233,7 +240,8 @@ _drag_start_cb(void *data,
 {
    ELM_SPINNER_DATA_GET(data, sd);
 
-   sd->drag_start_val = sd->val;
+   sd->drag_prev_pos = 0;
+   sd->drag_val_step = 1;
 
    evas_object_smart_callback_call(obj, SIG_DRAG_START, NULL);
 }
@@ -247,7 +255,8 @@ _drag_stop_cb(void *data,
    ELM_SPINNER_DATA_GET(data, sd);
    ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
 
-   sd->drag_start_val = 0;
+   sd->drag_prev_pos = 0;
+   sd->drag_val_step = 1;
    edje_object_part_drag_value_set
      (wd->resize_obj, "elm.dragable.slider", 0.0, 0.0);
 
diff --git a/src/lib/elm_widget_spinner.h b/src/lib/elm_widget_spinner.h
index d0a4939..151b704 100644
--- a/src/lib/elm_widget_spinner.h
+++ b/src/lib/elm_widget_spinner.h
@@ -32,8 +32,7 @@ struct _Elm_Spinner_Data
    const char           *label;
    double                val, val_min, val_max, val_base;
    double                step; /**< step for the value change. 1 by default. */
-   double                drag_start_val; /**< spinner value on drag start.
-                                         this is reset to 0 when drag stops. */
+   double                drag_prev_pos, drag_val_step;
    double                spin_speed, interval, first_interval;
    int                   round;
    Ecore_Timer          *delay_change_timer; /**< a timer for a delay,changed 
smart callback */

-- 


Reply via email to