elm_interface_scrollable: fix bringing in of items
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>
Tue, 20 Dec 2016 17:21:58 +0000 (18:21 +0100)
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>
Thu, 20 Apr 2017 12:38:58 +0000 (14:38 +0200)
src/lib/elementary/efl_ui_focus_manager.c
src/lib/elementary/efl_ui_focus_manager.eo
src/lib/elementary/elm_interface_scrollable.c
src/lib/elementary/elm_interface_scrollable.eo

index 87afd28..3ec1c7a 100644 (file)
@@ -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)
      {
index 9f85659..dd13e71 100644 (file)
@@ -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
index a5c9854..e92d7df 100644 (file)
@@ -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));
 }
 
index 3aff179..ec8a76c 100644 (file)
@@ -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]]