elm_spinner: Spinner internal focus logic fixed to following New focused UI concept. 02/103702/4
authorWoochan Lee <wc0917.lee@samsung.com>
Fri, 9 Dec 2016 07:37:33 +0000 (16:37 +0900)
committerwoochan lee <wc0917.lee@samsung.com>
Sat, 10 Dec 2016 08:16:56 +0000 (00:16 -0800)
https://phab.enlightenment.org/D4475

Change-Id: Iff81c703daaff8176f17b79688b113c01cbb4c2b

src/lib/elm_spinner.c

index 21e479e..e5ffa97 100644 (file)
@@ -63,11 +63,11 @@ static Eina_Bool
 _text_button_focused_cb(void *data, Eo *obj EINA_UNUSED,
                         const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED);
 static Eina_Bool
-_button_focused_cb(void *data, Eo *obj EINA_UNUSED,
-                   const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED);
-static Eina_Bool
 _entry_unfocused_cb(void *data, Eo *obj EINA_UNUSED,
                     const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED);
+static Eina_Bool
+_entry_activated_cb(void *data, Eo *obj EINA_UNUSED,
+                    const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED);
 
 EO_CALLBACKS_ARRAY_DEFINE(_inc_dec_button_cb,
    { EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _inc_dec_button_clicked_cb},
@@ -393,14 +393,18 @@ _entry_hide(Evas_Object *obj)
 
    if (sd->button_layout)
      {
-        elm_layout_signal_emit(obj, "elm,state,entry,inactive", "elm");
-        evas_object_hide(sd->ent);
         elm_layout_signal_emit(obj, "elm,state,button,active", "elm");
         evas_object_show(sd->text_button);
+        elm_layout_signal_emit(obj, "elm,state,entry,inactive", "elm");
+        evas_object_hide(sd->ent);
      }
    else
      elm_layout_signal_emit(obj, "elm,state,inactive", "elm");
 
+
+   if (sd->entry_visible && !evas_focus_state_get(evas_object_evas_get(obj)))
+     sd->entry_reactivate = EINA_TRUE;
+
    //TIZEN_ONLY(20160606): Forcefully setting highlight frame on spinner entry as on entry activation frame goes to window again.
    if (_elm_atspi_enabled()) eo_do(obj, elm_interface_atspi_component_highlight_clear());
    //
@@ -418,6 +422,8 @@ _entry_value_apply(Evas_Object *obj)
 
    if (!sd->entry_visible) return;
 
+   eo_do(sd->ent, eo_event_callback_del
+         (ELM_WIDGET_EVENT_UNFOCUSED, _entry_unfocused_cb, obj));
    _entry_hide(obj);
    str = elm_object_text_get(sd->ent);
    if (!str) return;
@@ -700,14 +706,8 @@ _toggle_entry(Evas_Object *obj)
              elm_entry_markup_filter_append(sd->ent, _invalid_input_validity_filter, NULL);
              if (_elm_config->spinner_min_max_filter_enable)
                elm_entry_markup_filter_append(sd->ent, _min_max_validity_filter, obj);
-             if (sd->inc_button)
-               eo_do(sd->inc_button, eo_event_callback_add
-                     (ELM_WIDGET_EVENT_FOCUSED, _button_focused_cb, obj));
-             if (sd->dec_button)
-               eo_do(sd->dec_button, eo_event_callback_add
-                     (ELM_WIDGET_EVENT_FOCUSED, _button_focused_cb, obj));
              eo_do(sd->ent, eo_event_callback_add
-                   (ELM_ENTRY_EVENT_ACTIVATED, _entry_unfocused_cb, obj));
+                   (ELM_ENTRY_EVENT_ACTIVATED, _entry_activated_cb, obj));
           }
         if (!sd->button_layout)
           {
@@ -717,6 +717,10 @@ _toggle_entry(Evas_Object *obj)
              elm_widget_focus_set(sd->ent, EINA_TRUE);
              sd->entry_visible = EINA_TRUE;
           }
+
+        eo_do(sd->ent, eo_event_callback_add
+              (ELM_WIDGET_EVENT_UNFOCUSED, _entry_unfocused_cb, obj));
+        sd->entry_visible = EINA_TRUE;
         elm_layout_signal_emit(obj, "elm,state,entry,active", "elm");
         evas_object_show(sd->ent);
      }
@@ -912,7 +916,6 @@ _inc_dec_button_clicked_cb(void *data,
    sd->spin_speed = sd->inc_btn_activated ? sd->step : -sd->step;
    _spin_value(data);
 
-   if (sd->entry_visible) _entry_value_apply(data);
    if (_elm_config->access_mode)
      _access_increment_decrement_info_say(data, EINA_TRUE);
 
@@ -934,11 +937,6 @@ _inc_dec_button_pressed_cb(void *data,
                            (_elm_config->longpress_timeout,
                             _val_inc_dec_start, data);
 
-   if (sd->entry_visible) _entry_value_apply(data);
-   //TIZEN_ONLY(20160623): Add entry visible, focus check flag for reactivating entry.
-   if (sd->entry_reactivate) sd->entry_reactivate = EINA_FALSE;
-   //
-
    return EINA_TRUE;
 }
 
@@ -965,24 +963,17 @@ _text_button_focused_cb(void *data,
                    Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
                    void *event_info EINA_UNUSED)
 {
-   ELM_SPINNER_DATA_GET(data, sd);
-
-   sd->entry_visible = EINA_FALSE;
    _toggle_entry(data);
 
    return EINA_TRUE;
 }
 
 static Eina_Bool
-_button_focused_cb(void *data,
-                   Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
-                   void *event_info EINA_UNUSED)
+_entry_activated_cb(void *data,
+                    Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
+                    void *event_info EINA_UNUSED)
 {
-   ELM_SPINNER_DATA_GET(data, sd);
-
-   sd->entry_visible = EINA_TRUE;
    _toggle_entry(data);
-
    return EINA_TRUE;
 }
 
@@ -991,9 +982,6 @@ _entry_unfocused_cb(void *data,
                     Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
                     void *event_info EINA_UNUSED)
 {
-   ELM_SPINNER_DATA_GET(data, sd);
-
-   sd->entry_visible = EINA_TRUE;
    _toggle_entry(data);
 
    return EINA_TRUE;
@@ -1055,11 +1043,6 @@ _elm_spinner_elm_widget_on_focus(Eo *obj, Elm_Spinner_Data *sd, Elm_Object_Item
         ELM_SAFE_FREE(sd->delay_change_timer, ecore_timer_del);
         ELM_SAFE_FREE(sd->spin_timer, ecore_timer_del);
 
-        //TIZEN_ONLY(20160623): Add entry visible, focus check flag for reactivating entry.
-        if (sd->entry_visible) sd->entry_reactivate = EINA_TRUE;
-        //
-
-        _entry_value_apply(obj);
      }
    //TIZEN_ONLY(20160623): Add entry visible, focus check flag for reactivating entry.
    else
@@ -1534,10 +1517,7 @@ _elm_spinner_elm_widget_focus_direction(Eo *obj, Elm_Spinner_Data *_pd, const Ev
    list_data_get = eina_list_data_get;
 
    items = eina_list_append(items, _pd->inc_button);
-   if (_pd->entry_visible)
-     items = eina_list_append(items, _pd->ent);
-   else
-     items = eina_list_append(items, _pd->text_button);
+   items = eina_list_append(items, _pd->text_button);
    items = eina_list_append(items, _pd->dec_button);
 
    ret = elm_widget_focus_list_direction_get
@@ -1576,13 +1556,7 @@ _elm_spinner_elm_widget_focus_next(Eo *obj, Elm_Spinner_Data *_pd, Elm_Focus_Dir
    if (!elm_widget_disabled_get(obj))
      {
         items = eina_list_append(items, _pd->dec_button);
-        if (_pd->entry_visible)
-          items = eina_list_append(items, _pd->ent);
-        else
-          {
-             if (_pd->entry_reactivate) _pd->entry_reactivate = EINA_FALSE;
-             items = eina_list_append(items, _pd->text_button);
-          }
+        items = eina_list_append(items, _pd->text_button);
         items = eina_list_append(items, _pd->inc_button);
      }
    return elm_widget_focus_list_next_get