bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=dfc9cd8a6735b5fa77ca953ad7d7e4ec50ee495a

commit dfc9cd8a6735b5fa77ca953ad7d7e4ec50ee495a
Author: Marcel Hollerbach <[email protected]>
Date:   Mon Dec 3 11:46:48 2018 +0100

    elm_focus: implement elm_object_focus_next_item_set / get
    
    you can use this now to let the focus move to the widget container of
    the passed item.
    
    I know this patch contains a whitespace change, but i have to get out
    this whitespace each & every time i am editing the file - which is
    annoying. So remove it once, which makes further work easier.
    
    fixes T6183.
    
    Reviewed-by: YeongJong Lee <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D7408
---
 src/bin/elementary/test.c             |  2 ++
 src/bin/elementary/test_focus.c       | 62 ++++++++++++++++++++++++++++++++++-
 src/lib/elementary/elm_focus_legacy.c | 21 ++++++++++--
 3 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 1cedec20ac..9298e9b2e2 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -258,6 +258,7 @@ void test_focus_object_policy(void *data, Evas_Object *obj, 
void *event_info);
 void test_focus4(void *data, Evas_Object *obj, void *event_info);
 void test_focus5(void *data, Evas_Object *obj, void *event_info);
 void test_focus6(void *data, Evas_Object *obj, void *event_info);
+void test_focus7(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void 
*event_info EINA_UNUSED);
 void test_flipselector(void *data, Evas_Object *obj, void *event_info);
 void test_diskselector(void *data, Evas_Object *obj, void *event_info);
 void test_colorselector(void *data, Evas_Object *obj, void *event_info);
@@ -1147,6 +1148,7 @@ add_tests:
    ADD_TEST(NULL, "Focus", "Focus 4", test_focus4);
    ADD_TEST(NULL, "Focus", "Focus 5", test_focus5);
    ADD_TEST(NULL, "Focus", "Focus 6", test_focus6);
+   ADD_TEST(NULL, "Focus", "Focus 7", test_focus7);
 
    //------------------------------//
    ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe);
diff --git a/src/bin/elementary/test_focus.c b/src/bin/elementary/test_focus.c
index ceb6e5cdd5..d1b04eef5e 100644
--- a/src/bin/elementary/test_focus.c
+++ b/src/bin/elementary/test_focus.c
@@ -1031,7 +1031,7 @@ _focus5_btn_clicked(void *data, Evas_Object *obj 
EINA_UNUSED, void *event_info E
    Evas_Object *grid = data;
    struct _focus5_obj *layout = evas_object_data_get(grid, "layout");
 
-   // brrr...a really naive looping 
+   // brrr...a really naive looping
    if (layout == _focus5_layout_data1)
       _focus5_layout(grid, _focus5_layout_data2);
    else if (layout == _focus5_layout_data2)
@@ -1224,3 +1224,63 @@ test_focus6(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *event_in
    evas_object_resize(win, 400, 400);
    evas_object_show(win);
 }
+
+void
+test_focus7(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void 
*event_info EINA_UNUSED)
+{
+   Evas_Object *win, *box, *btn, *gl;
+   Elm_Genlist_Item_Class *itc;
+   Elm_Object_Item *it;
+   int i;
+
+   win = elm_win_util_standard_add("focus7", "Focus 7");
+   elm_win_autodel_set(win, EINA_TRUE);
+   elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
+
+   // main vertical box
+   box = elm_box_add(win);
+   evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, box);
+   evas_object_show(box);
+
+   // genlist in a swallow
+   gl = elm_genlist_add(box);
+   evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_ALWAYS);
+   elm_box_pack_end(box, gl);
+
+   itc = elm_genlist_item_class_new();
+   itc->item_style = "default";
+   itc->func.text_get = _focus6_gl_text_get;
+   for (i = 0; i < 3; i++)
+     {
+        it = elm_genlist_item_append(gl, itc, (void*)(uintptr_t)i, NULL,
+                                     ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+        if (i == 1)
+          {
+             elm_genlist_item_selected_set(it, EINA_TRUE);
+
+             /* focus should start from second item */
+             elm_object_item_focus_set(it, EINA_TRUE);
+          }
+     }
+   elm_genlist_item_class_free(itc);
+   evas_object_show(gl);
+
+   btn = elm_button_add(win);
+   elm_object_text_set(btn, "To the right will result in genlist focus");
+   elm_object_focus_next_item_set(btn, it, ELM_FOCUS_RIGHT);
+   elm_box_pack_end(box, btn);
+   evas_object_show(btn);
+
+   btn = elm_button_add(win);
+   elm_object_text_set(btn, "UP");
+   elm_box_pack_end(box, btn);
+   evas_object_show(btn);
+
+   // size and show the window
+   evas_object_resize(win, 400, 400);
+   evas_object_show(win);
+}
diff --git a/src/lib/elementary/elm_focus_legacy.c 
b/src/lib/elementary/elm_focus_legacy.c
index 15da74aadc..8075ab2233 100644
--- a/src/lib/elementary/elm_focus_legacy.c
+++ b/src/lib/elementary/elm_focus_legacy.c
@@ -194,10 +194,18 @@ elm_object_focus_next(Evas_Object        *obj,
         Efl_Ui_Focus_Object *legacy_target = NULL;
         ELM_WIDGET_DATA_GET_OR_RETURN(logical, pd_logical);
 
-        #define MAP(direction, field)  if (dir == EFL_UI_FOCUS_DIRECTION_ 
##direction && pd_logical->legacy_focus.field) legacy_target = 
pd_logical->legacy_focus.field;
+
+        #define MAP(direction, field)  if (dir == EFL_UI_FOCUS_DIRECTION_ 
##direction && pd_logical->legacy_focus.item_ ##field) legacy_target = 
elm_object_item_widget_get(pd_logical->legacy_focus.item_ ##field);
         MAPPING()
         #undef MAP
 
+        if (!legacy_target)
+          {
+             #define MAP(direction, field)  if (dir == EFL_UI_FOCUS_DIRECTION_ 
##direction && pd_logical->legacy_focus.field) legacy_target = 
pd_logical->legacy_focus.field;
+             MAPPING()
+             #undef MAP
+          }
+
         if (legacy_target)
           {
              efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, legacy_target);
@@ -242,7 +250,11 @@ elm_object_focus_next_item_get(const Evas_Object  *obj,
                                Elm_Focus_Direction dir EINA_UNUSED)
 {
    API_ENTRY_VAL(NULL)
-   /* FOCUS-FIXME */
+
+   #define MAP(direction, field)  if (dir == EFL_UI_FOCUS_DIRECTION_ 
##direction && pd->legacy_focus.item_ ##field) return pd->legacy_focus.item_ 
##field;
+   MAPPING()
+   #undef MAP
+
    return NULL;
 }
 
@@ -252,7 +264,10 @@ elm_object_focus_next_item_set(Evas_Object     *obj,
                                Elm_Focus_Direction dir EINA_UNUSED)
 {
    API_ENTRY()
-   /* FOCUS-FIXME */
+
+   #define MAP(direction, field)  if (dir == EFL_UI_FOCUS_DIRECTION_ 
##direction) pd->legacy_focus.item_ ##field = next_item;
+   MAPPING()
+   #undef MAP
 }
 
 EAPI Evas_Object *

-- 


Reply via email to