summaryrefslogtreecommitdiff
path: root/src/lib/elementary
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel@osg.samsung.com>2017-10-19 14:02:46 +0200
committerMarcel Hollerbach <marcel@osg.samsung.com>2017-10-19 15:20:59 +0200
commit8d20422e8bf9a8fcee7ba67f288b524d0fd04c82 (patch)
tree6b7583e5a134dbfca7210e98de936c3dd399c2c0 /src/lib/elementary
parent3184e0f550ac1dc7a0a247cd38df4692bf82c82d (diff)
elm_scroller: scroll to a focused element
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/elm_scroller.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/lib/elementary/elm_scroller.c b/src/lib/elementary/elm_scroller.c
index 89bdb3bf14..9842a910d4 100644
--- a/src/lib/elementary/elm_scroller.c
+++ b/src/lib/elementary/elm_scroller.c
@@ -851,6 +851,34 @@ elm_scroller_add(Evas_Object *parent)
851 return efl_add(MY_CLASS, parent, efl_canvas_object_legacy_ctor(efl_added)); 851 return efl_add(MY_CLASS, parent, efl_canvas_object_legacy_ctor(efl_added));
852} 852}
853 853
854static void
855_focused_element(void *data, const Efl_Event *event)
856{
857 Eina_Rect geom;
858 Efl_Ui_Focus_Object *obj = data;
859 Efl_Ui_Focus_Object *focus = event->info;
860 Elm_Scrollable_Smart_Interface_Data *pd;
861 Eina_Position2D pos;
862 int pan_x, pan_y;
863
864 pd = efl_data_scope_get(obj, ELM_INTERFACE_SCROLLABLE_MIXIN);
865
866 if (!focus) return;
867
868 geom = efl_ui_focus_object_focus_geometry_get(focus);
869 pos = efl_gfx_position_get(obj);
870 elm_obj_pan_pos_get(pd->pan_obj, &pan_x, &pan_y);
871 geom.x = geom.x + pan_x - pos.x;
872 geom.y = geom.y + pan_y - pos.y;
873
874 elm_interface_scrollable_region_bring_in(obj, geom.x, geom.y, geom.w, geom.h);
875
876 geom = efl_gfx_geometry_get(obj);
877 geom.x = geom.y = 0;
878 elm_widget_show_region_set(obj, geom, EINA_TRUE);
879
880}
881
854EOLIAN static Eo * 882EOLIAN static Eo *
855_elm_scroller_efl_object_constructor(Eo *obj, Elm_Scroller_Data *_pd EINA_UNUSED) 883_elm_scroller_efl_object_constructor(Eo *obj, Elm_Scroller_Data *_pd EINA_UNUSED)
856{ 884{
@@ -858,7 +886,7 @@ _elm_scroller_efl_object_constructor(Eo *obj, Elm_Scroller_Data *_pd EINA_UNUSED
858 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); 886 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
859 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 887 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
860 efl_access_role_set(obj, EFL_ACCESS_ROLE_SCROLL_PANE); 888 efl_access_role_set(obj, EFL_ACCESS_ROLE_SCROLL_PANE);
861 889 efl_event_callback_add(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, _focused_element, obj);
862 return obj; 890 return obj;
863} 891}
864 892