summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_spin_button.c
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-07 16:58:01 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-08 19:56:41 +0200
commitd5df7e459d0bddd63b213ab8ac7a87cd0b1c08fc (patch)
tree2f877754ea77097111ac22609fb1371e5af184d1 /src/lib/elementary/efl_ui_spin_button.c
parentd8f32042c46e0090178249c6556d26277650313c (diff)
efl_ui_spin_button: fix event calling in spin_button
before the spin event for changing the value was called twice if you changed the value by the entry. Additionally, the changed,delay event is not emitted when the value was changed via the arrow buttons. This corrects this, additionally, this enables the delay timer when focus is gone, this is expected and should be supported by the API. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9231
Diffstat (limited to 'src/lib/elementary/efl_ui_spin_button.c')
-rw-r--r--src/lib/elementary/efl_ui_spin_button.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/lib/elementary/efl_ui_spin_button.c b/src/lib/elementary/efl_ui_spin_button.c
index 34de0b7..f14c365 100644
--- a/src/lib/elementary/efl_ui_spin_button.c
+++ b/src/lib/elementary/efl_ui_spin_button.c
@@ -138,6 +138,12 @@ _value_set(Evas_Object *obj,
138 else if (new_val > pd->val_max) 138 else if (new_val > pd->val_max)
139 new_val = pd->val_min; 139 new_val = pd->val_min;
140 } 140 }
141 else
142 {
143 new_val = MIN(pd->val_max, MAX(pd->val_min, new_val));
144 }
145
146 if (EINA_DBL_EQ(new_val, efl_ui_range_value_get(obj))) return EINA_TRUE;
141 147
142 efl_ui_range_value_set(obj, new_val); 148 efl_ui_range_value_set(obj, new_val);
143 ecore_timer_del(sd->delay_change_timer); 149 ecore_timer_del(sd->delay_change_timer);
@@ -165,12 +171,10 @@ static void
165_entry_value_apply(Evas_Object *obj) 171_entry_value_apply(Evas_Object *obj)
166{ 172{
167 const char *str; 173 const char *str;
168 double val, val_min, val_max; 174 double val;
169 char *end; 175 char *end;
170 176
171 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(obj, MY_CLASS); 177 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(obj, MY_CLASS);
172 Efl_Ui_Spin_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_CLASS);
173
174 if (!sd->entry_visible) return; 178 if (!sd->entry_visible) return;
175 179
176 efl_event_callback_del(sd->ent, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED, 180 efl_event_callback_del(sd->ent, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
@@ -180,15 +184,7 @@ _entry_value_apply(Evas_Object *obj)
180 if (!str) return; 184 if (!str) return;
181 185
182 val = strtod(str, &end); 186 val = strtod(str, &end);
183 if (((*end != '\0') && (!isspace(*end))) || (fabs(val - pd->val) < DBL_EPSILON)) return; 187 _value_set(obj, val);
184 efl_ui_range_limits_get(obj, &val_min, &val_max);
185 val = MIN(val_max, MAX(val_min, val));
186 efl_ui_range_value_set(obj, val);
187
188 efl_event_callback_call(obj, EFL_UI_SPIN_EVENT_CHANGED, NULL);
189 ecore_timer_del(sd->delay_change_timer);
190 sd->delay_change_timer = ecore_timer_add(EFL_UI_SPIN_BUTTON_DELAY_CHANGE_TIME,
191 _delay_change_timer_cb, obj);
192} 188}
193 189
194static void 190static void
@@ -403,8 +399,7 @@ _spin_value(Efl_Ui_Spin *obj, Eina_Bool inc)
403 399
404 int absolut_value = efl_ui_range_value_get(obj) + (inc ? pd->step : -pd->step); 400 int absolut_value = efl_ui_range_value_get(obj) + (inc ? pd->step : -pd->step);
405 401
406 if (_value_set(obj, MIN(MAX(absolut_value, pd->val_min), pd->val_max))) 402 _value_set(obj, absolut_value);
407 _label_write(obj);
408} 403}
409 404
410static void 405static void
@@ -476,11 +471,7 @@ _efl_ui_spin_button_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Spin_But
476 int_ret = efl_ui_focus_object_on_focus_update(efl_super(obj, MY_CLASS)); 471 int_ret = efl_ui_focus_object_on_focus_update(efl_super(obj, MY_CLASS));
477 if (!int_ret) return EINA_FALSE; 472 if (!int_ret) return EINA_FALSE;
478 473
479 if (!efl_ui_focus_object_focus_get(obj)) 474 if (efl_ui_focus_object_focus_get(obj))
480 {
481 ELM_SAFE_FREE(sd->delay_change_timer, ecore_timer_del);
482 }
483 else
484 { 475 {
485 if (sd->entry_reactivate) 476 if (sd->entry_reactivate)
486 { 477 {