elm_spinner: add feature in spinner to change values while dragging relative to the...
authorgodly.talias <godly.talias@samsung.com>
Thu, 25 Jun 2015 14:27:09 +0000 (16:27 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Thu, 25 Jun 2015 15:24:08 +0000 (17:24 +0200)
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>
AUTHORS
src/bin/test_spinner.c
src/lib/elm_authors.h
src/lib/elm_spinner.c
src/lib/elm_widget_spinner.h

diff --git a/AUTHORS b/AUTHORS
index 4c6dc9a..404439a 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -164,3 +164,4 @@ Jee-Yong Um <conr2d@gmail.com>
 Ji-In Moon <jiin.moon@samsung.com> 
 Subodh Kumar <s7158.kumar@samsung.com>
 Kumar Navneet <k.navneet@samsung.com>
+Godly T Alias <godly.talias@samsung.com>
index e3c2c4d..41eb63f 100644 (file)
@@ -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",
index 6c2f996..71cc0f6 100644 (file)
  * @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-devel@lists.sourceforge.net> to get in
  * contact with the developers and maintainers.
index 9624380..654e1a6 100644 (file)
@@ -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);
 
index d0a4939..151b704 100644 (file)
@@ -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 */