[Datetime/spinner]: When user edit's value through keyboard and value is
authorshilpa singh <shilpa.singh@samsung.com>
Mon, 19 Aug 2013 15:21:15 +0000 (20:51 +0530)
committerSungho Kwak <sungho1.kwak@samsung.com>
Fri, 13 Sep 2013 01:54:06 +0000 (10:54 +0900)
not committed yet and then when user taps on ^/v button, value should get
committed and incremented/decremented.

Change-Id: I7d87360faf7d6f3ad4e8d95f2804304337d8c21f

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

index 71d3527..f9713d5 100644 (file)
@@ -221,15 +221,6 @@ _entry_hide(Evas_Object *obj)
 }
 
 static void
-_reset_value(Evas_Object *obj)
-{
-   ELM_SPINNER_DATA_GET(obj, sd);
-
-   _entry_hide(obj);
-   elm_spinner_value_set(obj, sd->orig_val);
-}
-
-static void
 _entry_value_apply(Evas_Object *obj)
 {
    const char *str;
@@ -265,10 +256,7 @@ _entry_toggle_cb(void *data,
    if (!sd->editable) return;
    if (sd->entry_visible) _entry_value_apply(data);
    else
-     {
-        sd->orig_val = sd->val;
-        elm_layout_signal_emit(data, "elm,state,active", "elm");
-     }
+     elm_layout_signal_emit(data, "elm,state,active", "elm");
 }
 
 static void
@@ -359,10 +347,12 @@ _button_inc_start_cb(void *data,
 {
    ELM_SPINNER_DATA_GET(data, sd);
 
+   /* FIXME: When entry is still visible and inc button is clicked
+    * commit entry text and then increment the committed text */
    if (sd->entry_visible)
      {
-        _reset_value(data);
-        return;
+        _entry_value_apply(obj);
+        if ((sd->val_updated) && (sd->val == sd->val_min)) return;
      }
    _val_inc_start(data);
 }
@@ -383,11 +373,12 @@ _button_dec_start_cb(void *data,
                      const char *source __UNUSED__)
 {
    ELM_SPINNER_DATA_GET(data, sd);
-
+   /* FIXME: When entry is still visible and inc button is clicked
+    * commit entry text and then increment the committed text */
    if (sd->entry_visible)
      {
-        _reset_value(data);
-        return;
+        _entry_value_apply(obj);
+        if ((sd->val_updated) && (sd->val == sd->val_max)) return;
      }
    _val_dec_start(data);
 }
@@ -936,8 +927,17 @@ elm_spinner_value_set(Evas_Object *obj,
 
    if (sd->val == val) return;
    sd->val = val;
-   if (sd->val < sd->val_min) sd->val = sd->val_min;
-   if (sd->val > sd->val_max) sd->val = sd->val_max;
+   sd->val_updated = EINA_FALSE;
+   if (sd->val < sd->val_min)
+     {
+        sd->val = sd->val_min;
+        sd->val_updated = EINA_TRUE;
+     }
+   if (sd->val > sd->val_max)
+     {
+        sd->val = sd->val_max;
+        sd->val_updated = EINA_TRUE;
+     }
    _val_set(obj);
    _label_write(obj);
    evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
index 5468916..2f9ceea 100644 (file)
@@ -129,7 +129,7 @@ struct _Elm_Spinner_Smart_Data
 
    Evas_Object          *ent;
    const char           *label;
-   double                val, val_min, val_max, orig_val, step, val_base;
+   double                val, val_min, val_max, step, val_base;
    double                drag_start_pos, spin_speed, interval, first_interval;
    int                   round;
    Ecore_Timer          *delay, *spin;
@@ -139,6 +139,7 @@ struct _Elm_Spinner_Smart_Data
    Eina_Bool             dragging : 1;
    Eina_Bool             editable : 1;
    Eina_Bool             wrap : 1;
+   Eina_Bool             val_updated : 1;
 };
 
 typedef struct _Elm_Spinner_Special_Value Elm_Spinner_Special_Value;