bu5hm4n pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=af858d1d935f3507cb72f9d4a0f67fdfbb5b7463
commit af858d1d935f3507cb72f9d4a0f67fdfbb5b7463 Author: Marcel Hollerbach <marcel-hollerb...@t-online.de> Date: Thu Jun 8 23:52:37 2017 +0200 elm_widget: add factory method to the widget with this function you can trap the creation of the mangers, and change the behaviour as you need it. For example returning a custom manager. --- src/lib/elementary/efl_ui_win.c | 16 +++++++++++++--- src/lib/elementary/efl_ui_win.eo | 1 + src/lib/elementary/elm_hover.c | 16 +++++++++++++--- src/lib/elementary/elm_hover.eo | 1 + src/lib/elementary/elm_interface_scrollable.c | 15 +++++++++++++-- src/lib/elementary/elm_interface_scrollable.eo | 3 ++- src/lib/elementary/elm_inwin.c | 18 +++++++++++++++--- src/lib/elementary/elm_inwin.eo | 1 + src/lib/elementary/elm_menu.c | 26 ++++++++++++++++---------- src/lib/elementary/elm_menu.eo | 1 + src/lib/elementary/elm_widget.c | 8 ++++++++ src/lib/elementary/elm_widget.eo | 10 ++++++++++ 12 files changed, 94 insertions(+), 22 deletions(-) diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index 37f55f3f58..62005bbc8d 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -5276,15 +5276,25 @@ _efl_ui_win_efl_canvas_object_legacy_ctor(Eo *obj, Efl_Ui_Win_Data *sd) efl_canvas_object_legacy_ctor(efl_super(obj, MY_CLASS)); } +EOLIAN static Efl_Ui_Focus_Manager* +_efl_ui_win_elm_widget_focus_manager_factory(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root) +{ + Efl_Ui_Focus_Manager *manager; + + manager = efl_add(EFL_UI_FOCUS_MANAGER_CLASS, NULL, + efl_ui_focus_manager_root_set(efl_added, root) + ); + + return manager; +} + EOLIAN static Eo * _efl_ui_win_efl_object_constructor(Eo *obj, Efl_Ui_Win_Data *pd) { /* Do nothing. */ /* XXX: We are calling the constructor chain from the finalizer. It's * really bad and hacky. Needs fixing. */ - pd->manager = efl_add(EFL_UI_FOCUS_MANAGER_CLASS, obj, - efl_ui_focus_manager_root_set(efl_added, obj) - ); + pd->manager = elm_obj_widget_focus_manager_factory(obj, obj); efl_composite_attach(obj, pd->manager); diff --git a/src/lib/elementary/efl_ui_win.eo b/src/lib/elementary/efl_ui_win.eo index 86a529a15b..e520830be3 100644 --- a/src/lib/elementary/efl_ui_win.eo +++ b/src/lib/elementary/efl_ui_win.eo @@ -937,6 +937,7 @@ class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window, Elm.Widget.theme_apply; Elm.Widget.on_focus; Elm.Widget.widget_event; + Elm.Widget.focus_manager_factory; Elm.Interface.Atspi_Accessible.parent { get; } Elm.Interface.Atspi_Accessible.state_set { get; } Elm.Interface.Atspi_Accessible.name { get; } diff --git a/src/lib/elementary/elm_hover.c b/src/lib/elementary/elm_hover.c index 22f40a3f27..c8eae1321a 100644 --- a/src/lib/elementary/elm_hover.c +++ b/src/lib/elementary/elm_hover.c @@ -687,6 +687,18 @@ elm_hover_add(Evas_Object *parent) return obj; } +EOLIAN static Efl_Ui_Focus_Manager* +_elm_hover_elm_widget_focus_manager_factory(Eo *obj EINA_UNUSED, Elm_Hover_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root) +{ + Efl_Ui_Focus_Manager *manager; + + manager = efl_add(EFL_UI_FOCUS_MANAGER_CLASS, NULL, + efl_ui_focus_manager_root_set(efl_added, root) + ); + + return manager; +} + EOLIAN static Eo * _elm_hover_efl_object_constructor(Eo *obj, Elm_Hover_Data *pd) { @@ -695,9 +707,7 @@ _elm_hover_efl_object_constructor(Eo *obj, Elm_Hover_Data *pd) evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_POPUP_MENU); - pd->manager = efl_add(EFL_UI_FOCUS_MANAGER_CLASS, NULL, - efl_ui_focus_manager_root_set(efl_added, obj) - ); + pd->manager = elm_obj_widget_focus_manager_factory(obj, obj); efl_composite_attach(obj, pd->manager); diff --git a/src/lib/elementary/elm_hover.eo b/src/lib/elementary/elm_hover.eo index d8a3635c0f..8321a383a9 100644 --- a/src/lib/elementary/elm_hover.eo +++ b/src/lib/elementary/elm_hover.eo @@ -70,6 +70,7 @@ class Elm.Hover (Elm.Layout, Efl.Ui.Clickable, Elm.Interface.Atspi_Widget_Action Elm.Widget.focus_direction_manager_is; Elm.Widget.focus_next_manager_is; Elm.Widget.sub_object_del; + Elm.Widget.focus_manager_factory; Elm.Layout.sizing_eval; Elm.Layout.content_aliases { get; } Elm.Interface.Atspi_Widget_Action.elm_actions { get; } diff --git a/src/lib/elementary/elm_interface_scrollable.c b/src/lib/elementary/elm_interface_scrollable.c index f008d0b6b0..961ad4e5a6 100644 --- a/src/lib/elementary/elm_interface_scrollable.c +++ b/src/lib/elementary/elm_interface_scrollable.c @@ -4654,11 +4654,22 @@ _focused_element(void *data, const Efl_Event *event) elm_interface_scrollable_region_bring_in(obj, geom.x, geom.y, geom.w, geom.h); } +EOLIAN static Efl_Ui_Focus_Manager* +_elm_interface_scrollable_elm_widget_focus_manager_factory(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root) +{ + Efl_Ui_Focus_Manager *manager; + + manager = efl_add(EFL_UI_FOCUS_MANAGER_SUB_CLASS, obj, + efl_ui_focus_manager_root_set(efl_added, root) + ); + + return manager; +} + EOLIAN static Efl_Object* _elm_interface_scrollable_efl_object_constructor(Eo *obj, Elm_Scrollable_Smart_Interface_Data *pd EINA_UNUSED) { - pd->manager = efl_add(EFL_UI_FOCUS_MANAGER_SUB_CLASS, obj, - efl_ui_focus_manager_root_set(efl_added, obj)); + pd->manager = elm_obj_widget_focus_manager_factory(obj, obj); efl_composite_attach(obj, pd->manager); diff --git a/src/lib/elementary/elm_interface_scrollable.eo b/src/lib/elementary/elm_interface_scrollable.eo index 6f9520b45e..fd05fcc096 100644 --- a/src/lib/elementary/elm_interface_scrollable.eo +++ b/src/lib/elementary/elm_interface_scrollable.eo @@ -42,7 +42,7 @@ enum Elm.Scroller.Movement_Block } -mixin Elm.Interface_Scrollable(Efl.Ui.Scrollable, Efl.Canvas.Group, Efl.Ui.Focus.Manager) +mixin Elm.Interface_Scrollable(Efl.Ui.Scrollable, Efl.Canvas.Group, Efl.Ui.Focus.Manager, Elm.Widget) { [[Elm scrollable mixin]] eo_prefix: elm_interface_scrollable; @@ -682,6 +682,7 @@ mixin Elm.Interface_Scrollable(Efl.Ui.Scrollable, Efl.Canvas.Group, Efl.Ui.Focus Efl.Object.constructor; Efl.Ui.Focus.Manager.border_elements { get; } Efl.Ui.Focus.Manager.focus; + Elm.Widget.focus_manager_factory; } events { changed; [[Called when content changed]] diff --git a/src/lib/elementary/elm_inwin.c b/src/lib/elementary/elm_inwin.c index d19788a7d2..d671ec8427 100644 --- a/src/lib/elementary/elm_inwin.c +++ b/src/lib/elementary/elm_inwin.c @@ -108,6 +108,20 @@ elm_win_inwin_add(Evas_Object *parent) return obj; } + +EOLIAN static Efl_Ui_Focus_Manager* +_elm_inwin_elm_widget_focus_manager_factory(Eo *obj EINA_UNUSED, Elm_Inwin_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root) +{ + Efl_Ui_Focus_Manager *manager; + + manager = efl_add(EFL_UI_FOCUS_MANAGER_ROOT_FOCUS_CLASS, NULL, + efl_ui_focus_manager_root_set(efl_added, root) + ); + + return manager; +} + + EOLIAN static Eo * _elm_inwin_efl_object_constructor(Eo *obj, Elm_Inwin_Data *pd EINA_UNUSED) { @@ -125,9 +139,7 @@ _elm_inwin_efl_object_constructor(Eo *obj, Elm_Inwin_Data *pd EINA_UNUSED) efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_GLASS_PANE); - pd->manager = efl_add(EFL_UI_FOCUS_MANAGER_ROOT_FOCUS_CLASS, NULL, - efl_ui_focus_manager_root_set(efl_added, obj) - ); + pd->manager = elm_obj_widget_focus_manager_factory(obj, obj); efl_composite_attach(obj, pd->manager); diff --git a/src/lib/elementary/elm_inwin.eo b/src/lib/elementary/elm_inwin.eo index dd831a9aa3..0a1e2b60c8 100644 --- a/src/lib/elementary/elm_inwin.eo +++ b/src/lib/elementary/elm_inwin.eo @@ -24,6 +24,7 @@ class Elm.Inwin (Elm.Layout, Efl.Ui.Focus.Manager) Elm.Widget.widget_parent { set; } Elm.Widget.focus_next_manager_is; Elm.Widget.focus_next; + Elm.Widget.focus_manager_factory; Elm.Layout.content_aliases { get; } Elm.Layout.sizing_eval; Efl.Gfx.visible { set; } diff --git a/src/lib/elementary/elm_menu.c b/src/lib/elementary/elm_menu.c index 8a79866c1b..e6d270240b 100644 --- a/src/lib/elementary/elm_menu.c +++ b/src/lib/elementary/elm_menu.c @@ -801,21 +801,27 @@ elm_menu_add(Evas_Object *parent) return efl_add(MY_CLASS, parent); } +EOLIAN static Efl_Ui_Focus_Manager* +_elm_menu_elm_widget_focus_manager_factory(Eo *obj EINA_UNUSED, Elm_Menu_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root) +{ + Efl_Ui_Focus_Manager *manager; + + manager = efl_add(EFL_UI_FOCUS_MANAGER_CLASS, NULL, + efl_ui_focus_manager_root_set(efl_added, root) + ); + + return manager; +} + EOLIAN static Eo * _elm_menu_efl_object_constructor(Eo *obj, Elm_Menu_Data *sd) { Eo *parent = NULL; + Efl_Ui_Focus_Manager *manager; - { - Efl_Ui_Focus_Manager *manager; - - manager = efl_add(EFL_UI_FOCUS_MANAGER_CLASS, NULL, - efl_ui_focus_manager_root_set(efl_added, obj) - ); - - efl_composite_attach(obj, manager); - _efl_ui_focus_manager_redirect_events_add(manager, obj); - } + manager = elm_obj_widget_focus_manager_factory(obj, obj); + efl_composite_attach(obj, manager); + _efl_ui_focus_manager_redirect_events_add(manager, obj); obj = efl_constructor(efl_super(obj, MY_CLASS)); efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); diff --git a/src/lib/elementary/elm_menu.eo b/src/lib/elementary/elm_menu.eo index 314b87db06..de428b0d66 100644 --- a/src/lib/elementary/elm_menu.eo +++ b/src/lib/elementary/elm_menu.eo @@ -54,6 +54,7 @@ class Elm.Menu (Elm.Widget, Efl.Ui.Clickable, Efl.Ui.Menu, Elm.Widget.widget_parent { get; set; } Elm.Widget.theme_apply; Elm.Widget.translate; + Elm.Widget.focus_manager_factory; Elm.Interface.Atspi_Accessible.children { get; } Elm.Interface.Atspi.Selection.selected_children_count { get; } Elm.Interface.Atspi.Selection.selected_child { get; } diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c index 57c2d25eb0..b8606c6f43 100644 --- a/src/lib/elementary/elm_widget.c +++ b/src/lib/elementary/elm_widget.c @@ -6504,6 +6504,14 @@ _elm_widget_efl_ui_focus_object_focus_set(Eo *obj, Elm_Widget_Smart_Data *pd, Ei efl_ui_focus_object_focus_set(efl_super(obj, MY_CLASS), focus); } +EOLIAN static Efl_Ui_Focus_Manager* +_elm_widget_focus_manager_factory(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root EINA_UNUSED) +{ + ERR("No manager presented"); + return NULL; +} + + /* Internal EO APIs and hidden overrides */ #define ELM_WIDGET_EXTRA_OPS \ diff --git a/src/lib/elementary/elm_widget.eo b/src/lib/elementary/elm_widget.eo index bb1cf071c5..4b9dcb828e 100644 --- a/src/lib/elementary/elm_widget.eo +++ b/src/lib/elementary/elm_widget.eo @@ -799,6 +799,16 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible, Elm.Inter } return : bool; [[return if it registered fully or not]] } + focus_manager_factory { + [[If the widget needs a manager, this function is called + + It can be used and overriden to inject your own manager or set custom options on the manager + ]] + params { + root : Efl.Ui.Focus.Object; [[the logical root to use in the manager.]] + } + return : Efl.Ui.Focus.Manager; + } } implements { class.constructor; --