efl_ui_focus: add parent_provider

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)
This commit is contained in:
Marcel Hollerbach 2017-10-12 21:25:49 +02:00
parent 441776f7cf
commit 75f5ea686f
9 changed files with 62 additions and 3 deletions

View 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)

View File

@ -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"

View File

@ -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;
}
}
}

View File

@ -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"

View File

@ -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;
}
}

View 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);
}

View 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>

View 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);

View 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) */