From 7994fa3f684508c5ed07ca571ddec8353b13f471 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Tue, 20 Dec 2016 18:21:58 +0100 Subject: [PATCH] elm_interface_scrollable: fix bringing in of items --- src/lib/elementary/efl_ui_focus_manager.c | 1 + src/lib/elementary/efl_ui_focus_manager.eo | 1 + src/lib/elementary/elm_interface_scrollable.c | 28 ++++++++++++++++++++++++++ src/lib/elementary/elm_interface_scrollable.eo | 1 - 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/lib/elementary/efl_ui_focus_manager.c b/src/lib/elementary/efl_ui_focus_manager.c index 87afd28..3ec1c7a 100644 --- a/src/lib/elementary/efl_ui_focus_manager.c +++ b/src/lib/elementary/efl_ui_focus_manager.c @@ -1132,6 +1132,7 @@ _efl_ui_focus_manager_focus(Eo *obj, Efl_Ui_Focus_Manager_Data *pd, Efl_Ui_Focus //populate the new change if (old_focus) efl_ui_focus_object_focus_set(old_focus->focusable, EINA_FALSE); efl_ui_focus_object_focus_set(node->focusable, EINA_TRUE); + efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, node->focusable); } else if (node->redirect_manager) { diff --git a/src/lib/elementary/efl_ui_focus_manager.eo b/src/lib/elementary/efl_ui_focus_manager.eo index 9f85659..dd13e71 100644 --- a/src/lib/elementary/efl_ui_focus_manager.eo +++ b/src/lib/elementary/efl_ui_focus_manager.eo @@ -176,5 +176,6 @@ class Efl.Ui.Focus.Manager (Efl.Object) { redirect,changed : Efl.Ui.Focus.Manager; [[Emitted when the redirect object has changed, the old manager is passed as event info]] pre,flush; [[Emitted once the graph calculationg will be performed]] coords,dirty; [[Emitted once the graph is dirty, this means there are potential changes in border_elements you want to know about]] + focused : Efl.Ui.Focus.Object; [[Emitted if the manager has focused a object]] } } \ No newline at end of file diff --git a/src/lib/elementary/elm_interface_scrollable.c b/src/lib/elementary/elm_interface_scrollable.c index a5c9854..e92d7df 100644 --- a/src/lib/elementary/elm_interface_scrollable.c +++ b/src/lib/elementary/elm_interface_scrollable.c @@ -4632,6 +4632,28 @@ _elm_interface_scrollable_class_constructor(Efl_Class *klass) EAPI void elm_pan_gravity_set(Elm_Pan *obj EINA_UNUSED, double x EINA_UNUSED, double y EINA_UNUSED) {} EAPI void elm_pan_gravity_get(const Elm_Pan *obj EINA_UNUSED, double *x EINA_UNUSED, double *y EINA_UNUSED) {} +static void +_focused_element(void *data, const Efl_Event *event) +{ + Eina_Rectangle geom; + Eina_Rectangle obj_geom; + Efl_Ui_Focus_Object *obj = data; + Efl_Ui_Focus_Object *focus = event->info; + Elm_Scrollable_Smart_Interface_Data *pd; + + pd = efl_data_scope_get(obj, MY_SCROLLABLE_INTERFACE); + + if (!focus) return; + + evas_object_geometry_get(focus, &geom.x, &geom.y, &geom.w, &geom.h); + evas_object_geometry_get(pd->content, &obj_geom.x, &obj_geom.y, &obj_geom.w, &obj_geom.h); + + geom.x = geom.x - obj_geom.x; + geom.y = geom.y - obj_geom.y; + + elm_interface_scrollable_region_bring_in(obj, geom.x, geom.y, geom.w, geom.h); +} + EOLIAN static Efl_Object* _elm_interface_scrollable_efl_object_constructor(Eo *obj, Elm_Scrollable_Smart_Interface_Data *pd EINA_UNUSED) { @@ -4640,6 +4662,12 @@ _elm_interface_scrollable_efl_object_constructor(Eo *obj, Elm_Scrollable_Smart_I efl_composite_attach(obj, pd->manager); + efl_event_callback_forwarder_add(pd->manager, EFL_UI_FOCUS_MANAGER_EVENT_REDIRECT_CHANGED, obj); + efl_event_callback_forwarder_add(pd->manager, EFL_UI_FOCUS_MANAGER_EVENT_PRE_FLUSH , obj); + efl_event_callback_forwarder_add(pd->manager, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY , obj); + efl_event_callback_forwarder_add(pd->manager, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, obj); + efl_event_callback_add(pd->manager, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, _focused_element, obj); + return efl_constructor(efl_super(obj, MY_SCROLLABLE_INTERFACE)); } diff --git a/src/lib/elementary/elm_interface_scrollable.eo b/src/lib/elementary/elm_interface_scrollable.eo index 3aff179..ec8a76c 100644 --- a/src/lib/elementary/elm_interface_scrollable.eo +++ b/src/lib/elementary/elm_interface_scrollable.eo @@ -683,7 +683,6 @@ mixin Elm.Interface_Scrollable(Efl.Ui.Scrollable, Efl.Canvas.Group, Efl.Ui.Focus Efl.Canvas.Group.group_add; Efl.Canvas.Group.group_del; Efl.Ui.Focus.Manager.border_elements.get; - Efl.Ui.Focus.Manager.focus; } events { changed; [[Called when content changed]] -- 2.7.4