From 94bc3ce471697957987fd3fefd52fe57361b060e Mon Sep 17 00:00:00 2001 From: Anand Date: Tue, 13 May 2014 11:24:19 +0900 Subject: [PATCH] focus: Fixed the animation issue related to bring_in. Summary: Calculating the coordinate of the object to retain the focus with in view port. Earlier focus was moving out of view port. Test Plan: elementary_test-> "Focus 3". Enable the Focus Auto scroll bring in and use keys to move focused item. Reviewers: raster, seoz, singh.amitesh, nirajkr Differential Revision: https://phab.enlightenment.org/D822 --- legacy/elementary/src/bin/test_focus.c | 30 ++++++++++++++++++++++++++ legacy/elementary/src/lib/elm_widget.c | 27 +++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/legacy/elementary/src/bin/test_focus.c b/legacy/elementary/src/bin/test_focus.c index 500486f1c4..d1742b5b3b 100644 --- a/legacy/elementary/src/bin/test_focus.c +++ b/legacy/elementary/src/bin/test_focus.c @@ -714,6 +714,21 @@ _focus_highlight_clip_disable_changed_cb(void *data EINA_UNUSED, elm_config_focus_highlight_clip_disabled_set(disable); } +static void +_focus_bring_in_changed_cb(void *data EINA_UNUSED, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + elm_config_focus_auto_scroll_bring_in_enabled_set(elm_check_state_get(obj)); +} + +static void +_horizontal_btn(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + Evas_Object *box_btn = data; + elm_box_horizontal_set(box_btn, elm_check_state_get(obj)); +} + void test_focus3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { @@ -791,6 +806,21 @@ test_focus3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in _focus_highlight_clip_disable_changed_cb, NULL); + ck = elm_check_add(box); + elm_object_text_set(ck, "Focus Auto scroll bring in enable"); + evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0); + evas_object_smart_callback_add(ck, "changed", _focus_bring_in_changed_cb, + NULL); + elm_check_state_set(ck, elm_config_focus_auto_scroll_bring_in_enabled_get()); + elm_box_pack_end(box, ck); + evas_object_show(ck); + + ck = elm_check_add(box); + elm_object_text_set(ck, "Horizontal Mode"); + evas_object_smart_callback_add(ck, "changed", _horizontal_btn, box_btn); + elm_box_pack_end(box, ck); + evas_object_show(ck); + evas_object_show(win); } diff --git a/legacy/elementary/src/lib/elm_widget.c b/legacy/elementary/src/lib/elm_widget.c index 57f05743f9..18ef77879c 100644 --- a/legacy/elementary/src/lib/elm_widget.c +++ b/legacy/elementary/src/lib/elm_widget.c @@ -3789,8 +3789,35 @@ elm_widget_focus_highlight_focus_part_geometry_get(const Evas_Object *obj, EOLIAN static void _elm_widget_focus_highlight_geometry_get(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { + Evas_Coord ox = 0, oy = 0, ow = 0, oh = 0; + Evas_Object *scroller = obj; + evas_object_geometry_get(obj, x, y, w, h); elm_widget_focus_highlight_focus_part_geometry_get(sd->resize_obj, x, y, w, h); + + if (!_elm_config->focus_auto_scroll_bring_in_enable) + return; + + while (scroller) + { + if (_elm_scrollable_is(scroller)) + { + eo_do(scroller, + elm_interface_scrollable_content_viewport_geometry_get(&ox, &oy, &ow, &oh)); + + if (*y < oy) + *y = oy; + else if ((oy + oh) < (*y + *h)) + *y = (oy + oh - *h); + else if (*x < ox) + *x = ox; + else if ((ox + ow) < (*x + *w)) + *x = (ox + ow - *w); + + break; + } + scroller = elm_widget_parent_get(scroller); + } } EOLIAN static Elm_Object_Item*