summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2018-12-03 11:46:48 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2018-12-17 09:12:22 +0100
commitdfc9cd8a6735b5fa77ca953ad7d7e4ec50ee495a (patch)
tree2dd78ad051dc4ce6bb0a0a8d990f356b689e5673
parent2d4f25fb3298756a024f96367fc2aeea26b1e9fe (diff)
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 <yj34.lee@samsung.com> Differential Revision: https://phab.enlightenment.org/D7408
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_focus.c62
-rw-r--r--src/lib/elementary/elm_focus_legacy.c21
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);
258void test_focus4(void *data, Evas_Object *obj, void *event_info); 258void test_focus4(void *data, Evas_Object *obj, void *event_info);
259void test_focus5(void *data, Evas_Object *obj, void *event_info); 259void test_focus5(void *data, Evas_Object *obj, void *event_info);
260void test_focus6(void *data, Evas_Object *obj, void *event_info); 260void test_focus6(void *data, Evas_Object *obj, void *event_info);
261void test_focus7(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
261void test_flipselector(void *data, Evas_Object *obj, void *event_info); 262void test_flipselector(void *data, Evas_Object *obj, void *event_info);
262void test_diskselector(void *data, Evas_Object *obj, void *event_info); 263void test_diskselector(void *data, Evas_Object *obj, void *event_info);
263void test_colorselector(void *data, Evas_Object *obj, void *event_info); 264void test_colorselector(void *data, Evas_Object *obj, void *event_info);
@@ -1147,6 +1148,7 @@ add_tests:
1147 ADD_TEST(NULL, "Focus", "Focus 4", test_focus4); 1148 ADD_TEST(NULL, "Focus", "Focus 4", test_focus4);
1148 ADD_TEST(NULL, "Focus", "Focus 5", test_focus5); 1149 ADD_TEST(NULL, "Focus", "Focus 5", test_focus5);
1149 ADD_TEST(NULL, "Focus", "Focus 6", test_focus6); 1150 ADD_TEST(NULL, "Focus", "Focus 6", test_focus6);
1151 ADD_TEST(NULL, "Focus", "Focus 7", test_focus7);
1150 1152
1151 //------------------------------// 1153 //------------------------------//
1152 ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe); 1154 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
1031 Evas_Object *grid = data; 1031 Evas_Object *grid = data;
1032 struct _focus5_obj *layout = evas_object_data_get(grid, "layout"); 1032 struct _focus5_obj *layout = evas_object_data_get(grid, "layout");
1033 1033
1034 // brrr...a really naive looping 1034 // brrr...a really naive looping
1035 if (layout == _focus5_layout_data1) 1035 if (layout == _focus5_layout_data1)
1036 _focus5_layout(grid, _focus5_layout_data2); 1036 _focus5_layout(grid, _focus5_layout_data2);
1037 else if (layout == _focus5_layout_data2) 1037 else if (layout == _focus5_layout_data2)
@@ -1224,3 +1224,63 @@ test_focus6(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
1224 evas_object_resize(win, 400, 400); 1224 evas_object_resize(win, 400, 400);
1225 evas_object_show(win); 1225 evas_object_show(win);
1226} 1226}
1227
1228void
1229test_focus7(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1230{
1231 Evas_Object *win, *box, *btn, *gl;
1232 Elm_Genlist_Item_Class *itc;
1233 Elm_Object_Item *it;
1234 int i;
1235
1236 win = elm_win_util_standard_add("focus7", "Focus 7");
1237 elm_win_autodel_set(win, EINA_TRUE);
1238 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
1239
1240 // main vertical box
1241 box = elm_box_add(win);
1242 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1243 elm_win_resize_object_add(win, box);
1244 evas_object_show(box);
1245
1246 // genlist in a swallow
1247 gl = elm_genlist_add(box);
1248 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1249 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1250 elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_ALWAYS);
1251 elm_box_pack_end(box, gl);
1252
1253 itc = elm_genlist_item_class_new();
1254 itc->item_style = "default";
1255 itc->func.text_get = _focus6_gl_text_get;
1256 for (i = 0; i < 3; i++)
1257 {
1258 it = elm_genlist_item_append(gl, itc, (void*)(uintptr_t)i, NULL,
1259 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1260
1261 if (i == 1)
1262 {
1263 elm_genlist_item_selected_set(it, EINA_TRUE);
1264
1265 /* focus should start from second item */
1266 elm_object_item_focus_set(it, EINA_TRUE);
1267 }
1268 }
1269 elm_genlist_item_class_free(itc);
1270 evas_object_show(gl);
1271
1272 btn = elm_button_add(win);
1273 elm_object_text_set(btn, "To the right will result in genlist focus");
1274 elm_object_focus_next_item_set(btn, it, ELM_FOCUS_RIGHT);
1275 elm_box_pack_end(box, btn);
1276 evas_object_show(btn);
1277
1278 btn = elm_button_add(win);
1279 elm_object_text_set(btn, "UP");
1280 elm_box_pack_end(box, btn);
1281 evas_object_show(btn);
1282
1283 // size and show the window
1284 evas_object_resize(win, 400, 400);
1285 evas_object_show(win);
1286}
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,
194 Efl_Ui_Focus_Object *legacy_target = NULL; 194 Efl_Ui_Focus_Object *legacy_target = NULL;
195 ELM_WIDGET_DATA_GET_OR_RETURN(logical, pd_logical); 195 ELM_WIDGET_DATA_GET_OR_RETURN(logical, pd_logical);
196 196
197 #define MAP(direction, field) if (dir == EFL_UI_FOCUS_DIRECTION_ ##direction && pd_logical->legacy_focus.field) legacy_target = pd_logical->legacy_focus.field; 197
198 #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);
198 MAPPING() 199 MAPPING()
199 #undef MAP 200 #undef MAP
200 201
202 if (!legacy_target)
203 {
204 #define MAP(direction, field) if (dir == EFL_UI_FOCUS_DIRECTION_ ##direction && pd_logical->legacy_focus.field) legacy_target = pd_logical->legacy_focus.field;
205 MAPPING()
206 #undef MAP
207 }
208
201 if (legacy_target) 209 if (legacy_target)
202 { 210 {
203 efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, legacy_target); 211 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,
242 Elm_Focus_Direction dir EINA_UNUSED) 250 Elm_Focus_Direction dir EINA_UNUSED)
243{ 251{
244 API_ENTRY_VAL(NULL) 252 API_ENTRY_VAL(NULL)
245 /* FOCUS-FIXME */ 253
254 #define MAP(direction, field) if (dir == EFL_UI_FOCUS_DIRECTION_ ##direction && pd->legacy_focus.item_ ##field) return pd->legacy_focus.item_ ##field;
255 MAPPING()
256 #undef MAP
257
246 return NULL; 258 return NULL;
247} 259}
248 260
@@ -252,7 +264,10 @@ elm_object_focus_next_item_set(Evas_Object *obj,
252 Elm_Focus_Direction dir EINA_UNUSED) 264 Elm_Focus_Direction dir EINA_UNUSED)
253{ 265{
254 API_ENTRY() 266 API_ENTRY()
255 /* FOCUS-FIXME */ 267
268 #define MAP(direction, field) if (dir == EFL_UI_FOCUS_DIRECTION_ ##direction) pd->legacy_focus.item_ ##field = next_item;
269 MAPPING()
270 #undef MAP
256} 271}
257 272
258EAPI Evas_Object * 273EAPI Evas_Object *