multibuttonentry: Apply focus UI feature for the item 93/94193/3
authorWoochan Lee <wc0917.lee@samsung.com>
Thu, 27 Oct 2016 10:51:01 +0000 (19:51 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 1 Nov 2016 00:53:00 +0000 (17:53 -0700)
Change-Id: I26670681fe9f98185877cb6e71d05528e53e371e

src/lib/elc_multibuttonentry.c
src/lib/elm_multibuttonentry.eo

index 2e80192f12b018b67d831146caab832cdea48d31..58a8d51c532b9b056a2b160665be0620b1bed9d9 100644 (file)
@@ -45,6 +45,9 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {NULL, NULL}
 };
 
+static Eina_Bool _elm_multibuttonentry_smart_focus_next_enable = EINA_FALSE;
+static Eina_Bool _elm_multibuttonentry_smart_focus_direction_enable = EINA_TRUE;
+
 static Eina_Bool
 _entry_changed_cb(void *data, Eo *obj EINA_UNUSED,
                   const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED);
@@ -313,6 +316,11 @@ _shrink_mode_set(Evas_Object *obj,
           (void *)(uintptr_t)sd->shrink));
      }
 
+   if (sd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
+     _elm_multibuttonentry_smart_focus_direction_enable = EINA_FALSE;
+   else
+     _elm_multibuttonentry_smart_focus_direction_enable = EINA_TRUE;
+
    if (sd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
      _visual_guide_text_set(obj);
 }
@@ -554,12 +562,24 @@ _on_item_deleted(void *data,
      }
 }
 
+static void
+_on_item_focused(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Elm_Multibuttonentry_Item_Data *it = data;
+   ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(WIDGET(it), sd);
+
+   if (!it) return;
+   sd->selected_it = it;
+}
+
 static void
 _on_item_unfocused(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
 {
    Elm_Multibuttonentry_Item_Data *it = data;
+   ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(WIDGET(it), sd);
 
    if (!it) return;
+   sd->selected_it = NULL;
    elm_layout_signal_emit(VIEW(it), "elm,state,unfocused", "elm");
 }
 
@@ -831,6 +851,8 @@ _item_new(Elm_Multibuttonentry_Data *sd,
    //
    elm_layout_signal_callback_add
      (VIEW(item), "elm,deleted", "elm", _on_item_deleted, EO_OBJ(item));
+   evas_object_smart_callback_add
+     (VIEW(item), "focused", _on_item_focused, item);
    evas_object_smart_callback_add
      (VIEW(item), "unfocused", _on_item_unfocused, item);
    evas_object_event_callback_add
@@ -1181,6 +1203,14 @@ _layout_key_down_cb(void *data,
                   elm_object_focus_set(sd->entry, EINA_TRUE);
                }
           }
+        else if (sd->selected_it &&
+            ((!strcmp(ev->key, "KP_Enter")) ||
+             (!strcmp(ev->key, "Return"))))
+          {
+             Elm_Multibuttonentry_Item_Data *item = sd->selected_it;
+             if (item)
+               _on_item_clicked(EO_OBJ(item), NULL, NULL, NULL);
+          }
         else if (((!sd->selected_it && (sd->n_str == 0) &&
                    (!strcmp(ev->key, "BackSpace"))) ||
                   (!strcmp(ev->key, "Delete"))))
@@ -1695,12 +1725,25 @@ _elm_multibuttonentry_evas_object_smart_del(Eo *obj, Elm_Multibuttonentry_Data *
    eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
 }
 
-static Eina_Bool _elm_multibuttonentry_smart_focus_next_enable = EINA_FALSE;
-
 EOLIAN static Eina_Bool
 _elm_multibuttonentry_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Multibuttonentry_Data *sd EINA_UNUSED)
 {
-   return EINA_FALSE;
+   return _elm_multibuttonentry_smart_focus_direction_enable;
+}
+
+EOLIAN static Eina_Bool
+_elm_multibuttonentry_elm_widget_focus_direction(Eo *obj EINA_UNUSED, Elm_Multibuttonentry_Data *sd, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
+{
+   Eina_Bool ret;
+   Eina_List *items = NULL;
+
+   items = eina_list_append(items, sd->box);
+
+   ret = elm_widget_focus_list_direction_get
+      (obj, base, items, eina_list_data_get, degree, direction, direction_item, weight);
+   eina_list_free(items);
+
+   return ret;
 }
 
 EOLIAN static Eina_Bool
index d4014a6dccc128a7ba596026c066024cc0ee8377..26cac83660e98fc8bcf2de0c84135b5108124bb9 100644 (file)
@@ -285,6 +285,7 @@ class Elm.Multibuttonentry (Elm.Layout)
       //register/unregister access objects accordingly.
       Elm.Widget.atspi;
       //
+      Elm.Widget.focus_direction;
       Elm.Widget.focus_next;
       Elm.Widget.on_focus;
       Elm.Widget.translate;