efl_ui_focus: add parent_provider
authorMarcel Hollerbach <marcel@osg.samsung.com>
Thu, 12 Oct 2017 19:25:49 +0000 (21:25 +0200)
committerMarcel Hollerbach <marcel@osg.samsung.com>
Fri, 13 Oct 2017 10:31:47 +0000 (12:31 +0200)
thats just a little helper, where the logic to find and fetch the
provider is bound to the position in the widget tree, this means that
for example gengrid could change the way the logical parent is
evalulated. (For example to map the logical parent to a item)

src/Makefile_Elementary.am
src/lib/elementary/efl_ui_focus_parent_provider.c [new file with mode: 0644]
src/lib/elementary/efl_ui_focus_parent_provider.eo [new file with mode: 0644]
src/lib/elementary/efl_ui_focus_parent_provider_standard.c [new file with mode: 0644]
src/lib/elementary/efl_ui_focus_parent_provider_standard.eo [new file with mode: 0644]
src/lib/elementary/efl_ui_win.c
src/lib/elementary/elm_priv.h
src/lib/elementary/elm_widget.c
src/lib/elementary/elm_widget.h

index 039f50b..11ad8c3 100644 (file)
@@ -155,6 +155,8 @@ elm_private_eolian_files = \
        tests/elementary/focus_test_sub_main.eo \
        lib/elementary/efl_ui_focus_rectangle.eo \
        lib/elementary/elm_calendar_item.eo \
+       lib/elementary/efl_ui_focus_parent_provider.eo \
+       lib/elementary/efl_ui_focus_parent_provider_standard.eo \
        $(NULL)
 
 # Legacy classes - not part of public EO API
@@ -707,7 +709,9 @@ lib_elementary_libelementary_la_SOURCES = \
        lib/elementary/efl_ui_focus_manager_root_focus.c \
        lib/elementary/efl_ui_textpath.c \
        lib/elementary/efl_ui_focus_layer.c \
-  lib/elementary/efl_ui_focus_composition.c \
+       lib/elementary/efl_ui_focus_composition.c \
+       lib/elementary/efl_ui_focus_parent_provider.c \
+       lib/elementary/efl_ui_focus_parent_provider_standard.c \
        $(NULL)
 
 
diff --git a/src/lib/elementary/efl_ui_focus_parent_provider.c b/src/lib/elementary/efl_ui_focus_parent_provider.c
new file mode 100644 (file)
index 0000000..97de15a
--- /dev/null
@@ -0,0 +1,8 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#include <Elementary.h>
+#include "elm_priv.h"
+
+#include "efl_ui_focus_parent_provider.eo.c"
diff --git a/src/lib/elementary/efl_ui_focus_parent_provider.eo b/src/lib/elementary/efl_ui_focus_parent_provider.eo
new file mode 100644 (file)
index 0000000..13d4638
--- /dev/null
@@ -0,0 +1,11 @@
+interface Efl.Ui.Focus.Parent_Provider {
+   methods {
+      find_logical_parent {
+        [[Called to get the logical parent of widget]]
+        params {
+           widget : Efl.Ui.Focus.Object;
+        }
+        return : Efl.Ui.Focus.Object;
+      }
+   }
+}
diff --git a/src/lib/elementary/efl_ui_focus_parent_provider_standard.c b/src/lib/elementary/efl_ui_focus_parent_provider_standard.c
new file mode 100644 (file)
index 0000000..821d812
--- /dev/null
@@ -0,0 +1,19 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#include <Elementary.h>
+#include "elm_priv.h"
+
+typedef struct {
+
+} Efl_Ui_Focus_Parent_Provider_Standard_Data;
+
+EOLIAN static Efl_Ui_Focus_Object*
+_efl_ui_focus_parent_provider_standard_efl_ui_focus_parent_provider_find_logical_parent(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Parent_Provider_Standard_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *widget)
+{
+   return elm_object_parent_widget_get(widget);
+}
+
+
+#include "efl_ui_focus_parent_provider_standard.eo.c"
diff --git a/src/lib/elementary/efl_ui_focus_parent_provider_standard.eo b/src/lib/elementary/efl_ui_focus_parent_provider_standard.eo
new file mode 100644 (file)
index 0000000..9daa4ae
--- /dev/null
@@ -0,0 +1,5 @@
+class Efl.Ui.Focus.Parent_Provider.Standard(Efl.Object, Efl.Ui.Focus.Parent_Provider) {
+   implements {
+      Efl.Ui.Focus.Parent_Provider.find_logical_parent;
+   }
+}
index bc66ece..af94426 100644 (file)
@@ -176,6 +176,7 @@ struct _Efl_Ui_Win_Data
    Evas_Object *main_menu;
 
    Efl_Ui_Focus_Manager *manager;
+   Efl_Ui_Focus_Parent_Provider_Standard *provider;
 
    struct
    {
@@ -5361,6 +5362,7 @@ _efl_ui_win_efl_object_constructor(Eo *obj, Efl_Ui_Win_Data *pd)
 
    pd->obj = obj;
    pd->manager = elm_obj_widget_focus_manager_create(obj, obj);
+   pd->provider = efl_add(EFL_UI_FOCUS_PARENT_PROVIDER_STANDARD_CLASS, obj);
    pd->profile.available = eina_array_new(4);
 
    efl_composite_attach(obj, pd->manager);
@@ -6756,6 +6758,10 @@ _efl_ui_win_efl_object_provider_find(Eo *obj, Efl_Ui_Win_Data *pd EINA_UNUSED,
 {
     if (klass == EFL_UI_WIN_CLASS)
       return obj;
+
+    if (klass == EFL_UI_FOCUS_PARENT_PROVIDER_INTERFACE)
+      return pd->provider;
+
     return efl_provider_find(efl_super(obj, MY_CLASS), klass);
 }
 
index 8d905ca..03051ba 100644 (file)
@@ -53,6 +53,8 @@
 #include "elm_widget.h"
 #include "elm_access.eo.h"
 #include "elm_code_private.h"
+#include "efl_ui_focus_parent_provider.eo.h"
+#include "efl_ui_focus_parent_provider_standard.eo.h"
 
 #ifdef HAVE_LANGINFO_H
 # include <langinfo.h>
index 5d5dc62..880e291 100644 (file)
@@ -453,7 +453,10 @@ static Efl_Ui_Focus_Object*
 _logical_parent_eval(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd)
 {
    Elm_Widget *parent;
-   parent = pd->parent_obj;
+   Efl_Ui_Focus_Parent_Provider *provider;
+
+   parent = efl_ui_focus_parent_provider_find_logical_parent(pd->provider, obj);
+
    if (pd->logical.parent != parent)
      {
         Efl_Ui_Focus_Object *old = NULL;
@@ -5081,6 +5084,7 @@ _elm_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSE
    evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
    parent = efl_parent_get(obj);
    elm_obj_widget_parent_set(obj, parent);
+   sd->provider = efl_provider_find(obj, EFL_UI_FOCUS_PARENT_PROVIDER_INTERFACE);
    sd->on_create = EINA_FALSE;
 
    elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_UNKNOWN);
index 0f0caca..4f2f0df 100644 (file)
@@ -416,7 +416,7 @@ typedef struct _Elm_Widget_Smart_Data
    Eina_Inlist                  *translate_strings;
    Eina_List                    *focus_chain;
    Eina_List                    *event_cb;
-
+   Eo                           *provider;
    /* this is a hook to be set on-the-fly on widgets. this is code
     * handling the request of showing a specific region from an inner
     * widget (mainly issued by entries, on cursor moving) */