spinner: After long press of inc/dec buttons, start continuously increasing/decreasing
authorShilpa Singh <shilpa.singh@samsung.com>
Tue, 4 Feb 2014 16:29:14 +0000 (01:29 +0900)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Tue, 4 Feb 2014 16:43:10 +0000 (01:43 +0900)
Summary:
When inc/dec buttons are pressed, start changing value after longpress has happened on buttons and not immediately.
Signed-off by: Mohammad Irfan (mohammad.i@samsung.com)
Signed-off by: Shilpa Singh(shilpa.singh@samsung.com)

Test Plan: Long press on inc/dec buttons of spinner.

Reviewers: seoz, woohyun

CC: Hermet, jchanwook, raster
Differential Revision: https://phab.enlightenment.org/D365

AUTHORS
src/lib/elm_authors.h
src/lib/elm_spinner.c
src/lib/elm_widget_spinner.h

diff --git a/AUTHORS b/AUTHORS
index 59f64e3..c19025f 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -88,3 +88,4 @@ Sanghyeon Lee <sh10233.lee@samsung.com>
 Anil Kumar Nahak <ak.nahak@samsung.com>
 Michal Jagiello <m.jagiello@samsung.com>
 Chinmaya Panigrahi <c.panigrahi@samsung.com>
+Mohammad Irfan <mohammad.i@samsung.com>
index 7e9f0e5..5f4ce50 100644 (file)
@@ -90,6 +90,7 @@
  * @author Anil Kumar Nahak <ak.nahak@@samsung.com>
  * @author Michal Jagiello <m.jagiello@@samsung.com>
  * @author Chinmaya Panigrahi <c.panigrahi@@samsung.com>
+ * @author Mohammad Irfan <mohammad.i@@samsung.com>
  *
  * Please contact <enlightenment-devel@lists.sourceforge.net> to get in
  * contact with the developers and maintainers.
index 9c059b6..ffeb975 100644 (file)
@@ -323,16 +323,18 @@ _spin_value(void *data)
    return ECORE_CALLBACK_RENEW;
 }
 
-static void
-_val_inc_start(Evas_Object *obj)
+static Eina_Bool
+_val_inc_start(void *data)
 {
-   ELM_SPINNER_DATA_GET(obj, sd);
+   ELM_SPINNER_DATA_GET(data, sd);
 
    sd->interval = sd->first_interval;
    sd->spin_speed = sd->step;
+   sd->longpress_timer = NULL;
    ecore_timer_del(sd->spin_timer);
-   sd->spin_timer = ecore_timer_add(sd->interval, _spin_value, obj);
-   _spin_value(obj);
+   sd->spin_timer = ecore_timer_add(sd->interval, _spin_value, data);
+   _spin_value(data);
+   return ECORE_CALLBACK_CANCEL;
 }
 
 static void
@@ -345,16 +347,18 @@ _val_inc_stop(Evas_Object *obj)
    ELM_SAFE_FREE(sd->spin_timer, ecore_timer_del);
 }
 
-static void
-_val_dec_start(Evas_Object *obj)
+static Eina_Bool
+_val_dec_start(void *data)
 {
-   ELM_SPINNER_DATA_GET(obj, sd);
+   ELM_SPINNER_DATA_GET(data, sd);
 
    sd->interval = sd->first_interval;
    sd->spin_speed = -sd->step;
+   sd->longpress_timer = NULL;
    ecore_timer_del(sd->spin_timer);
-   sd->spin_timer = ecore_timer_add(sd->interval, _spin_value, obj);
-   _spin_value(obj);
+   sd->spin_timer = ecore_timer_add(sd->interval, _spin_value, data);
+   _spin_value(data);
+   return ECORE_CALLBACK_CANCEL;
 }
 
 static void
@@ -381,7 +385,9 @@ _button_inc_start_cb(void *data,
         if ((sd->val_updated) && (sd->val == sd->val_min)) return;
         return;
      }
-   _val_inc_start(data);
+   ecore_timer_del(sd->longpress_timer);
+   sd->longpress_timer = ecore_timer_add
+            (_elm_config->longpress_timeout, _val_inc_start, data);
 }
 
 static void
@@ -390,6 +396,13 @@ _button_inc_stop_cb(void *data,
                     const char *emission EINA_UNUSED,
                     const char *source EINA_UNUSED)
 {
+    ELM_SPINNER_DATA_GET(data, sd);
+    if (sd->longpress_timer)
+      {
+         ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
+         sd->spin_speed = sd->step;
+         _spin_value(data);
+      }
    _val_inc_stop(data);
 }
 
@@ -406,7 +419,9 @@ _button_dec_start_cb(void *data,
         _entry_value_apply(obj);
         if ((sd->val_updated) && (sd->val == sd->val_max)) return;
      }
-   _val_dec_start(data);
+   ecore_timer_del(sd->longpress_timer);
+   sd->longpress_timer = ecore_timer_add
+             (_elm_config->longpress_timeout, _val_dec_start, data);
 }
 
 static void
@@ -415,6 +430,13 @@ _button_dec_stop_cb(void *data,
                     const char *emission EINA_UNUSED,
                     const char *source EINA_UNUSED)
 {
+   ELM_SPINNER_DATA_GET(data, sd);
+   if (sd->longpress_timer)
+     {
+        ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
+        sd->spin_speed = -sd->step;
+        _spin_value(data);
+     }
    _val_dec_stop(data);
 }
 
index b4225c2..0e9c308 100644 (file)
@@ -32,6 +32,8 @@ struct _Elm_Spinner_Smart_Data
    int                   round;
    Ecore_Timer          *delay_change_timer; /*<< a timer for a delay,changed smart callback */
    Ecore_Timer          *spin_timer; /*<< a timer for a repeated spinner value change on mouse down */
+   Ecore_Timer          *longpress_timer; /*<< a timer to detect long press. After lonpress timeout,
+                                          start continuous change of values until mouse up */
    Eina_List            *special_values;
 
    Eina_Bool             entry_visible : 1;