From 53052abaa69de163066ab506f26fe32ba744abf0 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Fri, 10 Nov 2017 15:26:33 +0100 Subject: [PATCH] elm_widget_item: refactor logic from gengrid into seperated class --- src/Makefile_Elementary.am | 2 ++ src/lib/elementary/elm_gengrid_item.eo | 2 +- src/lib/elementary/elm_priv.h | 1 + src/lib/elementary/elm_widget_item_static_focus.c | 39 ++++++++++++++++++++++ src/lib/elementary/elm_widget_item_static_focus.eo | 7 ++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/lib/elementary/elm_widget_item_static_focus.c create mode 100644 src/lib/elementary/elm_widget_item_static_focus.eo diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index 1c41f58..4c79dc8 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -148,6 +148,7 @@ elm_legacy_eolian_files = \ lib/elementary/elm_menu_item.eo \ lib/elementary/elm_ctxpopup_item.eo \ lib/elementary/elm_index_item.eo \ + lib/elementary/elm_widget_item_static_focus.eo \ lib/elementary/elm_genlist_item.eo \ lib/elementary/elm_gengrid_item.eo \ lib/elementary/elm_list_item.eo \ @@ -700,6 +701,7 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/efl_ui_focus_parent_provider.c \ lib/elementary/efl_ui_focus_parent_provider_standard.c \ lib/elementary/efl_ui_focus_parent_provider_gen.c \ + lib/elementary/elm_widget_item_static_focus.c \ $(NULL) diff --git a/src/lib/elementary/elm_gengrid_item.eo b/src/lib/elementary/elm_gengrid_item.eo index 3f0e736..8a0cb65 100644 --- a/src/lib/elementary/elm_gengrid_item.eo +++ b/src/lib/elementary/elm_gengrid_item.eo @@ -25,7 +25,7 @@ enum Elm.Gengrid.Item.Field_Type } -class Elm.Gengrid.Item(Elm.Widget.Item, Efl.Ui.Focus.Object) +class Elm.Gengrid.Item(Elm.Widget.Item.Static_Focus, Efl.Ui.Focus.Object) { [[Elementary gengrid item class]] legacy_prefix: elm_gengrid_item; diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h index c5a631f..8029384 100644 --- a/src/lib/elementary/elm_priv.h +++ b/src/lib/elementary/elm_priv.h @@ -55,6 +55,7 @@ #include "elm_code_private.h" #include "efl_ui_focus_parent_provider.eo.h" #include "efl_ui_focus_parent_provider_standard.eo.h" +#include "elm_widget_item_static_focus.eo.h" #ifdef HAVE_LANGINFO_H # include diff --git a/src/lib/elementary/elm_widget_item_static_focus.c b/src/lib/elementary/elm_widget_item_static_focus.c new file mode 100644 index 0000000..905bc26 --- /dev/null +++ b/src/lib/elementary/elm_widget_item_static_focus.c @@ -0,0 +1,39 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define ELM_WIDGET_ITEM_PROTECTED + +#include +#include "elm_priv.h" +#include "efl_ui_focus_composition_adapter.eo.h" + +typedef struct { + Eo *adapter; +} Elm_Widget_Item_Static_Focus_Data; + +EOLIAN static void +_elm_widget_item_static_focus_efl_ui_focus_object_prepare_logical(Eo *obj, Elm_Widget_Item_Static_Focus_Data *pd EINA_UNUSED) +{ + Elm_Widget_Item_Data *wpd = efl_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS); + + efl_ui_focus_object_prepare_logical(efl_super(obj, ELM_WIDGET_ITEM_STATIC_FOCUS_CLASS)); + + if (!efl_ui_focus_manager_request_subchild(wpd->widget, obj)) + { + if (!pd->adapter) + { + pd->adapter = efl_add(EFL_UI_FOCUS_COMPOSITION_ADAPTER_CLASS, obj, efl_ui_focus_composition_adapter_canvas_object_set(efl_added, wpd->view)); + efl_wref_add(pd->adapter, &pd->adapter); + efl_ui_focus_manager_calc_register(wpd->widget, pd->adapter, obj, NULL); + } + } + else if (pd->adapter) + { + efl_ui_focus_manager_calc_unregister(wpd->widget, pd->adapter); + efl_del(pd->adapter); + pd->adapter = NULL; + } +} + +#include "elm_widget_item_static_focus.eo.c" diff --git a/src/lib/elementary/elm_widget_item_static_focus.eo b/src/lib/elementary/elm_widget_item_static_focus.eo new file mode 100644 index 0000000..874466c --- /dev/null +++ b/src/lib/elementary/elm_widget_item_static_focus.eo @@ -0,0 +1,7 @@ +class Elm.Widget.Item.Static_Focus (Elm.Widget.Item, Efl.Ui.Focus.Object) +{ + [[A class that ensures that at least ONE focusable target is behind this widget item. If there is none registered to it after a prepare call it will register the view of the item as item.]] + implements { + Efl.Ui.Focus.Object.prepare_logical; + } +} -- 2.7.4