[TimerView] Refactor selector button longpress implementation 85/121585/3
authorKamil Lipiszko <k.lipiszko@samsung.com>
Tue, 28 Mar 2017 09:08:50 +0000 (11:08 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 28 Mar 2017 12:52:28 +0000 (05:52 -0700)
Change-Id: I5adcbeeb19918db889087911a4917e0c6092d5de

clock/inc/View/TimerView.h
clock/src/View/TimerView.cpp

index 20fc70d791cb31bb5baef5cde395e348105de54f..81405558f332612108e9a075d7557494559231bf 100644 (file)
@@ -169,9 +169,6 @@ namespace view {
                Evas_Object *conformant = NULL;
                view::CounterView *counter_ = NULL;
 
-               Ecore_Timer *timer_ = NULL;
-               bool isLongpressed_ = false;
-
                enum class ButtonArrowDirection {
                        ARROW_UP,
                        ARROW_DOWN,
@@ -209,8 +206,7 @@ namespace view {
                static void ResumeButtonClicked(void *data, Evas_Object *obj, void *event_info);
                static void ResetButtonClicked(void *data, Evas_Object *obj, void *event_info);
 
-               static void ButtonPressedCb(void *data, Evas_Object *obj, void *event_info);
-               static void ButtonUnpressedCb(void *data, Evas_Object *obj, void *event_info);
+               static void ButtonClickedCb(void *data, Evas_Object *obj, void *event_info);
                static void EntryFocusedCb(void *data, Evas_Object *obj, void *event_info);
                static void EntryUnfocusedCb(void *data, Evas_Object *obj, void *event_info);
                static void EntryChangedCb(void *data, Evas_Object *obj, void *event_info);
index add4e3acbae5edb083d296ecafecfdda68b175ea..0a3546b596bd7716738438176b1918accd9bbda6 100644 (file)
@@ -90,8 +90,6 @@ void TimerView::VirtualKeypadVisibleCb(void *data, Evas_Object *obj, void *event
 {
        TimerView *object = static_cast<TimerView *>(data);
 
-       DBG("");
-
        elm_object_signal_emit(object->layout_, "keypad.visible", "timer");
 }
 
@@ -99,8 +97,6 @@ void TimerView::VirtualKeypadHiddenCb(void *data, Evas_Object *obj, void *event_
 {
        TimerView *object = static_cast<TimerView *>(data);
 
-       DBG("");
-
        elm_object_signal_emit(object->layout_, "keypad.hidden", "timer");
        object->UnfocusEntries();
 }
@@ -145,49 +141,14 @@ void TimerView::UpdateSetTime(const char *part)
        UpdateView();
 }
 
-Eina_Bool TimerView::TimerCb(void *data)
-{
-       Evas_Object *button = (Evas_Object *)data;
-
-       TimerView *object = static_cast<TimerView *>(evas_object_data_get(button, "object"));
-
-       double current_interval = ecore_timer_interval_get(object->timer_);
-       if (current_interval > 0.1)
-               ecore_timer_interval_set(object->timer_, 0.1);
-
-       object->UnfocusEntries();
-
-       char *part = (char *)evas_object_data_get(button, "btn.type");
-       object->UpdateSetTime(part);
-
-       object->isLongpressed_ = true;
-
-       return EINA_TRUE;
-}
-
-void TimerView::ButtonPressedCb(void *data, Evas_Object *obj, void *event_info)
-{
-       TimerView *object = static_cast<TimerView *>(data);
-
-       if (object->timer_)
-               ecore_timer_del(object->timer_);
-
-       object->isLongpressed_ = false;
-
-       object->timer_ = ecore_timer_add(0.75, TimerCb, obj);
-}
-
-void TimerView::ButtonUnpressedCb(void *data, Evas_Object *obj, void *event_info)
+void TimerView::ButtonClickedCb(void *data, Evas_Object *obj, void *event_info)
 {
        TimerView *object = static_cast<TimerView *>(data);
 
-       ecore_timer_del(object->timer_);
-       object->timer_ = nullptr;
+       object->UnfocusEntries();
 
        char *part = (char *)evas_object_data_get(obj, "btn.type");
-
-       if (!object->isLongpressed_)
-               object->UpdateSetTime(part);
+       object->UpdateSetTime(part);
 }
 
 void TimerView::DisplayTime(int hour, int min, int sec)
@@ -256,11 +217,14 @@ void TimerView::CreateSelectorsButton(const char *part, ButtonArrowDirection dir
 
        elm_object_part_content_set(layout_, part, button);
 
-       evas_object_data_set(button, "object", this);
        evas_object_data_set(button, "btn.type", part);
 
-       evas_object_smart_callback_add(button, "pressed", ButtonPressedCb, this);
-       evas_object_smart_callback_add(button, "unpressed", ButtonUnpressedCb, this);
+       evas_object_smart_callback_add(button, "clicked", ButtonClickedCb, this);
+       evas_object_smart_callback_add(button, "repeated", ButtonClickedCb, this);
+
+       elm_button_autorepeat_gap_timeout_set(button, 0.1);
+       elm_button_autorepeat_initial_timeout_set(button, 0.7);
+       elm_button_autorepeat_set(button, EINA_TRUE);
 
        if (!elm_object_style_set(button, "arrow"))
                ERR("Button style setting failed");