summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_spin_button.c
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-05 18:18:33 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-08 19:56:39 +0200
commit7ddd286f7b3c454b9499f2a1357f8e4f7335710e (patch)
tree178c3f8dde0762ac7b2081a6658ed4d57ab2fe56 /src/lib/elementary/efl_ui_spin_button.c
parent1414b8a921cb150c48adaa3e0bbe3eb1edd17d8d (diff)
efl_ui_spin_button: cleanup internal data
there is no reason to store those two times in the internal data, as they do not change at all. Additionally, saving the direction in the internal data has also no reason, since it is *always* used in the call after the setting, so this makes this a parameter. Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Differential Revision: https://phab.enlightenment.org/D9229
Diffstat (limited to 'src/lib/elementary/efl_ui_spin_button.c')
-rw-r--r--src/lib/elementary/efl_ui_spin_button.c47
1 files changed, 16 insertions, 31 deletions
diff --git a/src/lib/elementary/efl_ui_spin_button.c b/src/lib/elementary/efl_ui_spin_button.c
index aff27f9..fa45e84 100644
--- a/src/lib/elementary/efl_ui_spin_button.c
+++ b/src/lib/elementary/efl_ui_spin_button.c
@@ -21,6 +21,11 @@
21 21
22#define EFL_UI_SPIN_BUTTON_DELAY_CHANGE_TIME 0.2 22#define EFL_UI_SPIN_BUTTON_DELAY_CHANGE_TIME 0.2
23 23
24//when a item is pressed but not released, this time passes by
25//until another step is added or removed from the current value.
26//given in seconds
27#define REPEAT_INTERVAL 0.85
28
24static const char PART_NAME_ENTRY[] = "entry"; 29static const char PART_NAME_ENTRY[] = "entry";
25static const char PART_NAME_DEC_BUTTON[] = "dec_button"; 30static const char PART_NAME_DEC_BUTTON[] = "dec_button";
26static const char PART_NAME_TEXT_BUTTON[] = "text_button"; 31static const char PART_NAME_TEXT_BUTTON[] = "text_button";
@@ -394,18 +399,15 @@ _entry_toggle_cb(void *data EINA_UNUSED,
394 _toggle_entry(obj); 399 _toggle_entry(obj);
395} 400}
396 401
397static Eina_Bool 402static void
398_spin_value(void *data) 403_spin_value(Efl_Ui_Spin *obj, Eina_Bool inc)
399{ 404{
400 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(data, MY_CLASS); 405 Efl_Ui_Spin_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_CLASS);
401 Efl_Ui_Spin_Data *pd = efl_data_scope_get(data, EFL_UI_SPIN_CLASS);
402
403 int absolut_value = pd->val + (sd->inc_val ? pd->step : -pd->step);
404 406
405 if (_value_set(data, MIN(MAX(absolut_value, pd->val_min), pd->val_max))) 407 int absolut_value = efl_ui_range_value_get(obj) + (inc ? pd->step : -pd->step);
406 _label_write(data);
407 408
408 return ECORE_CALLBACK_RENEW; 409 if (_value_set(obj, MIN(MAX(absolut_value, pd->val_min), pd->val_max)))
410 _label_write(obj);
409} 411}
410 412
411static void 413static void
@@ -415,8 +417,7 @@ _inc_dec_button_clicked_cb(void *data, const Efl_Event *event)
415 417
416 if (sd->entry_visible) _entry_value_apply(data); 418 if (sd->entry_visible) _entry_value_apply(data);
417 419
418 sd->inc_val = sd->inc_button == event->object ? EINA_TRUE : EINA_FALSE; 420 _spin_value(data, sd->inc_button == event->object);
419 _spin_value(data);
420 421
421 if (_elm_config->access_mode) 422 if (_elm_config->access_mode)
422 _access_increment_decrement_info_say(data, EINA_TRUE); 423 _access_increment_decrement_info_say(data, EINA_TRUE);
@@ -460,23 +461,9 @@ _efl_ui_spin_button_efl_ui_widget_widget_input_event_handler(Eo *obj, Efl_Ui_Spi
460 Eo *ev = eo_event->info; 461 Eo *ev = eo_event->info;
461 462
462 if (efl_input_processed_get(ev)) return EINA_FALSE; 463 if (efl_input_processed_get(ev)) return EINA_FALSE;
463 if (eo_event->desc == EFL_EVENT_KEY_DOWN) 464 if (eo_event->desc == EFL_EVENT_POINTER_WHEEL)
464 { 465 {
465 return EINA_FALSE; 466 _spin_value(obj, efl_input_pointer_wheel_delta_get(ev) < 0);
466 }
467 else if (eo_event->desc == EFL_EVENT_KEY_UP)
468 {
469 return EINA_FALSE;
470 }
471 else if (eo_event->desc == EFL_EVENT_POINTER_WHEEL)
472 {
473 sd->interval = sd->first_interval;
474 if (efl_input_pointer_wheel_delta_get(ev) < 0)
475 sd->inc_val = EINA_TRUE;
476 else
477 sd->inc_val = EINA_FALSE;
478
479 _spin_value(obj);
480 } 467 }
481 else return EINA_FALSE; 468 else return EINA_FALSE;
482 469
@@ -724,12 +711,10 @@ _efl_ui_spin_button_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Button_Data *sd)
724 711
725 free(group); 712 free(group);
726 713
727 sd->first_interval = 0.85;
728
729 sd->inc_button = efl_add(EFL_UI_BUTTON_CLASS, obj, 714 sd->inc_button = efl_add(EFL_UI_BUTTON_CLASS, obj,
730 efl_ui_autorepeat_enabled_set(efl_added, EINA_TRUE), 715 efl_ui_autorepeat_enabled_set(efl_added, EINA_TRUE),
731 efl_ui_autorepeat_initial_timeout_set(efl_added, _elm_config->longpress_timeout), 716 efl_ui_autorepeat_initial_timeout_set(efl_added, _elm_config->longpress_timeout),
732 efl_ui_autorepeat_gap_timeout_set(efl_added, sd->first_interval), 717 efl_ui_autorepeat_gap_timeout_set(efl_added, REPEAT_INTERVAL),
733 elm_widget_element_update(obj, efl_added, PART_NAME_INC_BUTTON), 718 elm_widget_element_update(obj, efl_added, PART_NAME_INC_BUTTON),
734 efl_event_callback_array_add(efl_added, _inc_dec_button_cb(), obj), 719 efl_event_callback_array_add(efl_added, _inc_dec_button_cb(), obj),
735 efl_content_set(efl_part(obj, "efl.inc_button"), efl_added)); 720 efl_content_set(efl_part(obj, "efl.inc_button"), efl_added));
@@ -743,7 +728,7 @@ _efl_ui_spin_button_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Button_Data *sd)
743 sd->dec_button = efl_add(EFL_UI_BUTTON_CLASS, obj, 728 sd->dec_button = efl_add(EFL_UI_BUTTON_CLASS, obj,
744 efl_ui_autorepeat_enabled_set(efl_added, EINA_TRUE), 729 efl_ui_autorepeat_enabled_set(efl_added, EINA_TRUE),
745 efl_ui_autorepeat_initial_timeout_set(efl_added, _elm_config->longpress_timeout), 730 efl_ui_autorepeat_initial_timeout_set(efl_added, _elm_config->longpress_timeout),
746 efl_ui_autorepeat_gap_timeout_set(efl_added, sd->first_interval), 731 efl_ui_autorepeat_gap_timeout_set(efl_added, REPEAT_INTERVAL),
747 elm_widget_element_update(obj, efl_added, PART_NAME_DEC_BUTTON), 732 elm_widget_element_update(obj, efl_added, PART_NAME_DEC_BUTTON),
748 efl_event_callback_array_add(efl_added, _inc_dec_button_cb(), obj), 733 efl_event_callback_array_add(efl_added, _inc_dec_button_cb(), obj),
749 efl_content_set(efl_part(obj, "efl.dec_button"), efl_added)); 734 efl_content_set(efl_part(obj, "efl.dec_button"), efl_added));