summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-03-24 17:59:50 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-03-24 18:02:03 +0900
commitc336820fb032fc5efff93cf91e4ed0a6183b032a (patch)
tree5764619e8d2ad93f32a94ca3d14457fd96ff7582
parent54855a435e781f3f91c8c6dc3a76131e83cab52b (diff)
Revert "adding focus direction for gengrid"
This reverts commit 4fe82cc740eda0c6b50ee09aedcf173aac1e775d.
-rw-r--r--.gitignore2
-rw-r--r--config/default/base.src2
-rw-r--r--config/mobile/base.src2
-rw-r--r--config/standard/base.src2
-rw-r--r--configure.ac1
-rw-r--r--src/bin/test.c2
-rw-r--r--src/bin/test_gengrid.c115
-rw-r--r--src/lib/elm_gengrid.c92
-rw-r--r--src/lib/elm_gengrid_common.h10
-rw-r--r--src/lib/elm_widget_gengrid.h11
-rw-r--r--src/modules/Makefile.am3
-rw-r--r--src/modules/gengrid_focus_hook/Makefile.am38
-rw-r--r--src/modules/gengrid_focus_hook/gengrid_focus_hook.c491
13 files changed, 6 insertions, 765 deletions
diff --git a/.gitignore b/.gitignore
index 0944c10eb..84e5f7e54 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,5 +52,3 @@ tags
52*.gmo 52*.gmo
53/config.cache-env 53/config.cache-env
54/compile 54/compile
55build.conf
56.gitignore
diff --git a/config/default/base.src b/config/default/base.src
index 29173631e..c7860496c 100644
--- a/config/default/base.src
+++ b/config/default/base.src
@@ -39,7 +39,7 @@ group "Elm_Config" struct {
39 value "finger_size" int: 40; 39 value "finger_size" int: 40;
40 value "fps" double: 60.0; 40 value "fps" double: 60.0;
41 value "theme" string: "default"; 41 value "theme" string: "default";
42 value "modules" string: "prefs>prefs_iface:access_output>access/api:datetime_input_ctxpopup>datetime/api:gengrid_focus_hook>gengrid_focus/api"; 42 value "modules" string: "prefs>prefs_iface:access_output>access/api:datetime_input_ctxpopup>datetime/api";
43 value "tooltip_delay" double: 1.0; 43 value "tooltip_delay" double: 1.0;
44 value "cursor_engine_only" uchar: 1; 44 value "cursor_engine_only" uchar: 1;
45 value "focus_highlight_enable" uchar: 0; 45 value "focus_highlight_enable" uchar: 0;
diff --git a/config/mobile/base.src b/config/mobile/base.src
index de9111fad..60a152129 100644
--- a/config/mobile/base.src
+++ b/config/mobile/base.src
@@ -39,7 +39,7 @@ group "Elm_Config" struct {
39 value "finger_size" int: 40; 39 value "finger_size" int: 40;
40 value "fps" double: 60.0; 40 value "fps" double: 60.0;
41 value "theme" string: "default"; 41 value "theme" string: "default";
42 value "modules" string: "prefs>prefs_iface:access_output>access/api:datetime_input_ctxpopup>datetime/api:gengrid_focus_hook>gengrid_focus/api"; 42 value "modules" string: "prefs>prefs_iface:access_output>access/api:datetime_input_ctxpopup>datetime/api";
43 value "tooltip_delay" double: 1.0; 43 value "tooltip_delay" double: 1.0;
44 value "cursor_engine_only" uchar: 1; 44 value "cursor_engine_only" uchar: 1;
45 value "focus_highlight_enable" uchar: 0; 45 value "focus_highlight_enable" uchar: 0;
diff --git a/config/standard/base.src b/config/standard/base.src
index 88bd1b486..838d95804 100644
--- a/config/standard/base.src
+++ b/config/standard/base.src
@@ -39,7 +39,7 @@ group "Elm_Config" struct {
39 value "finger_size" int: 10; 39 value "finger_size" int: 10;
40 value "fps" double: 60.0; 40 value "fps" double: 60.0;
41 value "theme" string: "default"; 41 value "theme" string: "default";
42 value "modules" string: "prefs>prefs_iface:access_output>access/api:datetime_input_ctxpopup>datetime/api:gengrid_focus_hook>gengrid_focus/api"; 42 value "modules" string: "prefs>prefs_iface:access_output>access/api:datetime_input_ctxpopup>datetime/api";
43 value "tooltip_delay" double: 1.0; 43 value "tooltip_delay" double: 1.0;
44 value "cursor_engine_only" uchar: 1; 44 value "cursor_engine_only" uchar: 1;
45 value "focus_highlight_enable" uchar: 0; 45 value "focus_highlight_enable" uchar: 0;
diff --git a/configure.ac b/configure.ac
index c3149c1d5..fcae23988 100644
--- a/configure.ac
+++ b/configure.ac
@@ -726,7 +726,6 @@ src/modules/Makefile
726src/modules/prefs/Makefile 726src/modules/prefs/Makefile
727src/modules/access_output/Makefile 727src/modules/access_output/Makefile
728src/modules/datetime_input_ctxpopup/Makefile 728src/modules/datetime_input_ctxpopup/Makefile
729src/modules/gengrid_focus_hook/Makefile
730src/modules/test_entry/Makefile 729src/modules/test_entry/Makefile
731src/modules/test_map/Makefile 730src/modules/test_map/Makefile
732src/edje_externals/Makefile 731src/edje_externals/Makefile
diff --git a/src/bin/test.c b/src/bin/test.c
index 7e6c43743..1dd840c2c 100644
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -130,7 +130,6 @@ void test_gengrid(void *data, Evas_Object *obj, void *event_info);
130void test_gengrid2(void *data, Evas_Object *obj, void *event_info); 130void test_gengrid2(void *data, Evas_Object *obj, void *event_info);
131void test_gengrid3(void *data, Evas_Object *obj, void *event_info); 131void test_gengrid3(void *data, Evas_Object *obj, void *event_info);
132void test_gengrid_item_styles(void *data, Evas_Object *obj, void *event_info); 132void test_gengrid_item_styles(void *data, Evas_Object *obj, void *event_info);
133void test_gengrid_focus_direction(void *data, Evas_Object *obj, void *event_info);
134void test_gengrid4(void *data, Evas_Object *obj, void *event_info); 133void test_gengrid4(void *data, Evas_Object *obj, void *event_info);
135void test_gengrid_speed(void *data, Evas_Object *obj, void *event_info); 134void test_gengrid_speed(void *data, Evas_Object *obj, void *event_info);
136void test_gengrid_focus(void *data, Evas_Object *obj, void *event_info); 135void test_gengrid_focus(void *data, Evas_Object *obj, void *event_info);
@@ -666,7 +665,6 @@ add_tests:
666 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Item Styles", test_gengrid_item_styles); 665 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Item Styles", test_gengrid_item_styles);
667 ADD_TEST(NULL, "Lists - Gengrid", "Gengrid Update Speed", test_gengrid_speed); 666 ADD_TEST(NULL, "Lists - Gengrid", "Gengrid Update Speed", test_gengrid_speed);
668 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Focus", test_gengrid_focus); 667 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Focus", test_gengrid_focus);
669 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Focus Direction", test_gengrid_focus_direction);
670 668
671 //------------------------------// 669 //------------------------------//
672 ADD_TEST(NULL, "General", "Scaling", test_scaling); 670 ADD_TEST(NULL, "General", "Scaling", test_scaling);
diff --git a/src/bin/test_gengrid.c b/src/bin/test_gengrid.c
index 8150ef476..b153767e7 100644
--- a/src/bin/test_gengrid.c
+++ b/src/bin/test_gengrid.c
@@ -252,23 +252,6 @@ grid_content_get(void *data, Evas_Object *obj, const char *part)
252 return NULL; 252 return NULL;
253} 253}
254 254
255Evas_Object *
256grid_content_buttons_get(void *data, Evas_Object *obj, const char *part)
257{
258 const Item_Data *id = data;
259 if (!strcmp(part, "elm.swallow.icon"))
260 {
261 Evas_Object *bt = elm_button_add(obj);
262 Evas_Object *ic = elm_icon_add(obj);
263 elm_image_file_set(ic, id->path, NULL);
264 elm_image_aspect_fixed_set(ic, EINA_FALSE);
265 elm_object_part_content_set(bt, "icon", ic);
266 evas_object_show(bt);
267 return bt;
268 }
269 return NULL;
270}
271
272Eina_Bool 255Eina_Bool
273grid_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) 256grid_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
274{ 257{
@@ -365,54 +348,6 @@ create_gengrid(Evas_Object *obj, int items)
365 return grid; 348 return grid;
366} 349}
367 350
368static Evas_Object *
369create_gengrid_buttons(Evas_Object *obj, int items)
370{
371 Evas_Object *grid = NULL;
372 static Item_Data id[144];
373 int i, n;
374 char buf[PATH_MAX];
375
376 grid = elm_gengrid_add(obj);
377 elm_gengrid_item_size_set(grid,
378 elm_config_scale_get() * 200,
379 elm_config_scale_get() * 150);
380 elm_gengrid_reorder_mode_set(grid, EINA_TRUE);
381 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
382 evas_object_smart_callback_add(grid, "clicked,double", grid_double_clicked, NULL);
383 evas_object_smart_callback_add(grid, "longpressed", grid_longpress, NULL);
384 evas_object_smart_callback_add(grid, "moved", grid_moved, NULL);
385 evas_object_smart_callback_add(grid, "drag,start,up", grid_drag_up, NULL);
386 evas_object_smart_callback_add(grid, "drag,start,right", grid_drag_right, NULL);
387 evas_object_smart_callback_add(grid, "drag,start,down", grid_drag_down, NULL);
388 evas_object_smart_callback_add(grid, "drag,start,left", grid_drag_left, NULL);
389 evas_object_smart_callback_add(grid, "drag,stop", grid_drag_stop, NULL);
390 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
391 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
392
393 gic = elm_gengrid_item_class_new();
394 gic->item_style = "default";
395 gic->func.text_get = grid_text_get;
396 gic->func.content_get = grid_content_buttons_get;
397 gic->func.state_get = grid_state_get;
398 gic->func.del = NULL;
399
400 n = 0;
401 for (i = 0; i < items; i++)
402 {
403 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
404 n = (n + 1) % 9;
405 id[i].mode = i;
406 id[i].path = eina_stringshare_add(buf);
407 id[i].item = elm_gengrid_item_append(grid, gic, &(id[i]), grid_sel, NULL);
408 if (!(i % 5))
409 elm_gengrid_item_selected_set(id[i].item, EINA_TRUE);
410 }
411 elm_gengrid_item_class_free(gic);
412
413 return grid;
414}
415
416static void 351static void
417restore_bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 352restore_bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
418{ 353{
@@ -1339,56 +1274,6 @@ test_gengrid4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
1339} 1274}
1340 1275
1341void 1276void
1342test_gengrid_focus_direction(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1343{
1344 Evas_Object *win, *bt, *bxx, *bx;
1345
1346
1347 win = elm_win_util_standard_add("gengrid", "GenGrid");
1348 elm_win_autodel_set(win, EINA_TRUE);
1349 evas_object_resize(win, 600, 600);
1350 evas_object_show(win);
1351
1352 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
1353 elm_win_focus_highlight_animate_set(win, EINA_TRUE);
1354
1355 bxx = elm_box_add(win);
1356 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1357 elm_win_resize_object_add(win, bxx);
1358 evas_object_show(bxx);
1359
1360 bt = elm_button_add(win);
1361 elm_object_text_set(bt, "Next API function");
1362 elm_box_pack_end(bxx, bt);
1363 evas_object_show(bt);
1364
1365 /* Create GenGrid */
1366 Evas_Object *grid = create_gengrid_buttons(win, (12 * 12));
1367 elm_box_pack_end(bxx, grid);
1368 evas_object_show(grid);
1369
1370 elm_gengrid_focus_direction_allow_set(grid, EINA_TRUE);
1371// elm_object_focus_allow_set(grid, EINA_FALSE);
1372
1373 bx = elm_box_add(win);
1374 elm_box_horizontal_set(bx, EINA_TRUE);
1375 elm_box_pack_end(bxx, bx);
1376 evas_object_show(bx);
1377
1378 bt = elm_button_add(win);
1379 elm_object_text_set(bt, "Bring in");
1380 evas_object_smart_callback_add(bt, "clicked", _btn_bring_in_clicked_cb, grid);
1381 elm_box_pack_end(bx, bt);
1382 evas_object_show(bt);
1383
1384 bt = elm_button_add(win);
1385 elm_object_text_set(bt, "Show");
1386 evas_object_smart_callback_add(bt, "clicked", _btn_show_clicked_cb, grid);
1387 elm_box_pack_end(bx, bt);
1388 evas_object_show(bt);
1389}
1390
1391void
1392test_gengrid_speed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1277test_gengrid_speed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1393{ 1278{
1394 Evas_Object *win, *fr, *bx; 1279 Evas_Object *win, *fr, *bx;
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
index 3359aba45..a362aa968 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -87,27 +87,6 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
87}; 87};
88#undef ELM_PRIV_GENGRID_SIGNALS 88#undef ELM_PRIV_GENGRID_SIGNALS
89 89
90static Gengrid_Focus_Direction_Mod_Api *gengrid_focus_direction_mod = NULL;
91
92static Gengrid_Focus_Direction_Mod_Api *
93_gengrid_focus_direction_mod_init(void)
94{
95 Elm_Module *mod = NULL;
96
97 if (!(mod = _elm_module_find_as("gengrid_focus/api"))) return NULL;
98
99 mod->api = malloc(sizeof(Gengrid_Focus_Direction_Mod_Api));
100 if (!mod->api) return NULL;
101
102 ((Gengrid_Focus_Direction_Mod_Api *)(mod->api))->hook_ptr =
103 _elm_module_symbol_get(mod, "gen_focus_direction");
104
105 if (!((Gengrid_Focus_Direction_Mod_Api *)(mod->api))->hook_ptr)
106 return NULL;
107
108 return mod->api;
109}
110
111static void 90static void
112_item_show_region(void *data) 91_item_show_region(void *data)
113{ 92{
@@ -571,34 +550,6 @@ _elm_gengrid_item_unrealize(Elm_Gen_Item *it,
571 evas_event_thaw_eval(evas_object_evas_get(WIDGET(it))); 550 evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
572} 551}
573 552
574
575static void
576_elm_gengrid_item_focused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
577{
578 Elm_Gen_Item *it = data;
579 Elm_Gengrid_Smart_Data *sd = GG_IT(it)->wsd;
580 if (sd->focus_direction && gengrid_focus_direction_mod)
581 {
582 Evas_Coord x = 0;
583 Evas_Coord y = 0;
584 Evas_Coord v_w = 0;
585 Evas_Coord v_h = 0;
586 Evas_Coord step_x = 0;
587 Evas_Coord step_y = 0;
588 Evas_Coord page_x = 0;
589 Evas_Coord page_y = 0;
590
591 eo_do(sd->obj,
592 elm_interface_scrollable_content_pos_get(&x, &y),
593 elm_interface_scrollable_step_size_get(&step_x, &step_y),
594 elm_interface_scrollable_page_size_get(&page_x, &page_y),
595 elm_interface_scrollable_content_viewport_size_get(&v_w, &v_h));
596
597 elm_gengrid_item_selected_set((Elm_Object_Item *)it, EINA_TRUE);
598 elm_gengrid_item_show((Elm_Object_Item *)it, ELM_GENGRID_ITEM_SCROLLTO_IN);
599 }
600}
601
602static void 553static void
603_item_mouse_up_cb(void *data, 554_item_mouse_up_cb(void *data,
604 Evas *evas EINA_UNUSED, 555 Evas *evas EINA_UNUSED,
@@ -865,7 +816,6 @@ _item_realize(Elm_Gen_Item *it)
865 edje_object_part_swallow(VIEW(it), key, ic); 816 edje_object_part_swallow(VIEW(it), key, ic);
866 evas_object_show(ic); 817 evas_object_show(ic);
867 elm_widget_sub_object_add(WIDGET(it), ic); 818 elm_widget_sub_object_add(WIDGET(it), ic);
868 evas_object_smart_callback_add(ic, "focused", _elm_gengrid_item_focused_cb, it);
869 } 819 }
870 } 820 }
871 } 821 }
@@ -1964,8 +1914,6 @@ _elm_gengrid_smart_event(Eo *obj, void *_pd, va_list *list)
1964 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; 1914 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1965 if (!sd->items) return; 1915 if (!sd->items) return;
1966 1916
1967 if (sd->focus_direction && gengrid_focus_direction_mod) return;
1968
1969 eo_do(obj, 1917 eo_do(obj,
1970 elm_interface_scrollable_content_pos_get(&x, &y), 1918 elm_interface_scrollable_content_pos_get(&x, &y),
1971 elm_interface_scrollable_step_size_get(&step_x, &step_y), 1919 elm_interface_scrollable_step_size_get(&step_x, &step_y),
@@ -2225,13 +2173,7 @@ _elm_gengrid_smart_on_focus(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
2225 Elm_Object_Item *it = NULL; 2173 Elm_Object_Item *it = NULL;
2226 Eina_Bool is_sel = EINA_FALSE; 2174 Eina_Bool is_sel = EINA_FALSE;
2227 2175
2228 if (sd->focus_direction && gengrid_focus_direction_mod)
2229 {
2230 if (ret) *ret = EINA_TRUE;
2231 return;
2232 }
2233 eo_do_super(obj, MY_CLASS, elm_obj_widget_on_focus(&int_ret)); 2176 eo_do_super(obj, MY_CLASS, elm_obj_widget_on_focus(&int_ret));
2234
2235 if (!int_ret) return; 2177 if (!int_ret) return;
2236 2178
2237 if (elm_widget_focus_get(obj) && (sd->selected) && 2179 if (elm_widget_focus_get(obj) && (sd->selected) &&
@@ -2286,28 +2228,10 @@ _elm_gengrid_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNU
2286} 2228}
2287 2229
2288static void 2230static void
2289_elm_gengrid_smart_focus_direction_manager_is(Eo *obj EINA_UNUSED, void *_pd, va_list *list) 2231_elm_gengrid_smart_focus_direction_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
2290{ 2232{
2291 Eina_Bool *ret = va_arg(*list, Eina_Bool *); 2233 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
2292 Elm_Gengrid_Smart_Data *sd = _pd;
2293 *ret = EINA_FALSE; 2234 *ret = EINA_FALSE;
2294 if (sd->focus_direction && gengrid_focus_direction_mod)
2295 *ret = EINA_TRUE;
2296}
2297
2298static void
2299_elm_gengrid_smart_focus_direction(Eo *obj, void *_pd, va_list *list)
2300{
2301 Elm_Gengrid_Smart_Data *sd = _pd;
2302 if (sd->focus_direction && gengrid_focus_direction_mod)
2303 {
2304 gengrid_focus_direction_mod->hook_ptr(obj, _pd, list);
2305 }
2306 else
2307 {
2308 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
2309 *ret = EINA_FALSE;
2310 }
2311} 2235}
2312 2236
2313static void 2237static void
@@ -2813,7 +2737,6 @@ _elm_gengrid_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
2813 elm_widget_style_get(obj))) 2737 elm_widget_style_get(obj)))
2814 CRI("Failed to set layout!"); 2738 CRI("Failed to set layout!");
2815 2739
2816 if (!gengrid_focus_direction_mod) gengrid_focus_direction_mod = _gengrid_focus_direction_mod_init();
2817 eo_do(obj, elm_interface_scrollable_objects_set(wd->resize_obj, priv->hit_rect)); 2740 eo_do(obj, elm_interface_scrollable_objects_set(wd->resize_obj, priv->hit_rect));
2818 2741
2819 priv->old_h_bounce = bounce; 2742 priv->old_h_bounce = bounce;
@@ -2821,7 +2744,6 @@ _elm_gengrid_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
2821 2744
2822 eo_do(obj, elm_interface_scrollable_bounce_allow_set(bounce, bounce)); 2745 eo_do(obj, elm_interface_scrollable_bounce_allow_set(bounce, bounce));
2823 2746
2824
2825 eo_do(obj, 2747 eo_do(obj,
2826 elm_interface_scrollable_animate_start_cb_set 2748 elm_interface_scrollable_animate_start_cb_set
2827 (_scroll_animate_start_cb), 2749 (_scroll_animate_start_cb),
@@ -2838,7 +2760,6 @@ _elm_gengrid_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
2838 priv->align_x = 0.5; 2760 priv->align_x = 0.5;
2839 priv->align_y = 0.5; 2761 priv->align_y = 0.5;
2840 priv->highlight = EINA_TRUE; 2762 priv->highlight = EINA_TRUE;
2841 priv->focus_direction = EINA_FALSE;
2842 2763
2843 priv->pan_obj = eo_add(MY_PAN_CLASS, evas_object_evas_get(obj)); 2764 priv->pan_obj = eo_add(MY_PAN_CLASS, evas_object_evas_get(obj));
2844 pan_data = eo_data_scope_get(priv->pan_obj, MY_PAN_CLASS); 2765 pan_data = eo_data_scope_get(priv->pan_obj, MY_PAN_CLASS);
@@ -3326,15 +3247,6 @@ elm_gengrid_horizontal_set(Evas_Object *obj,
3326 eo_do(obj, elm_obj_gengrid_horizontal_set(horizontal)); 3247 eo_do(obj, elm_obj_gengrid_horizontal_set(horizontal));
3327} 3248}
3328 3249
3329EAPI void
3330elm_gengrid_focus_direction_allow_set(Evas_Object *obj,
3331 Eina_Bool flag)
3332{
3333 ELM_GENGRID_CHECK(obj);
3334 ELM_GENGRID_DATA_GET(obj, sd);
3335 sd->focus_direction = flag;
3336}
3337
3338static void 3250static void
3339_horizontal_set(Eo *obj, void *_pd, va_list *list) 3251_horizontal_set(Eo *obj, void *_pd, va_list *list)
3340{ 3252{
@@ -4224,6 +4136,7 @@ elm_gengrid_item_show(Elm_Object_Item *item,
4224 4136
4225 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it); 4137 ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
4226 sd = GG_IT(it)->wsd; 4138 sd = GG_IT(it)->wsd;
4139
4227 if ((it->generation < sd->generation)) return; 4140 if ((it->generation < sd->generation)) return;
4228 4141
4229 sd->show_region = EINA_TRUE; 4142 sd->show_region = EINA_TRUE;
@@ -4571,7 +4484,6 @@ _class_constructor(Eo_Class *klass)
4571 EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_gengrid_smart_focus_direction_manager_is), 4484 EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_gengrid_smart_focus_direction_manager_is),
4572 EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_HIGHLIGHT_GEOMETRY_GET), _elm_gengrid_focus_highlight_geometry_get), 4485 EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_HIGHLIGHT_GEOMETRY_GET), _elm_gengrid_focus_highlight_geometry_get),
4573 EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUSED_ITEM_GET), _elm_gengrid_focused_item_get), 4486 EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUSED_ITEM_GET), _elm_gengrid_focused_item_get),
4574 EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_DIRECTION), _elm_gengrid_smart_focus_direction),
4575 4487
4576 EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_EVAL), _elm_gengrid_smart_sizing_eval), 4488 EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_EVAL), _elm_gengrid_smart_sizing_eval),
4577 4489
diff --git a/src/lib/elm_gengrid_common.h b/src/lib/elm_gengrid_common.h
index eedc076ca..be770388d 100644
--- a/src/lib/elm_gengrid_common.h
+++ b/src/lib/elm_gengrid_common.h
@@ -565,13 +565,3 @@ EAPI void elm_gengrid_item_select_mode_set(Elm_Object_I
565 */ 565 */
566EAPI Elm_Object_Select_Mode elm_gengrid_item_select_mode_get(const Elm_Object_Item *it); 566EAPI Elm_Object_Select_Mode elm_gengrid_item_select_mode_get(const Elm_Object_Item *it);
567 567
568
569/**
570 * Set if gengrid should manage focus direction.
571 *
572 * @param obj The gengrid object
573 * @param flag The state which should be set.
574 *
575 * @ingroup Gengrid
576 */
577EAPI void elm_gengrid_focus_direction_allow_set(Evas_Object *obj, Eina_Bool flag);
diff --git a/src/lib/elm_widget_gengrid.h b/src/lib/elm_widget_gengrid.h
index 9be4ab7cb..f551f8454 100644
--- a/src/lib/elm_widget_gengrid.h
+++ b/src/lib/elm_widget_gengrid.h
@@ -15,15 +15,6 @@
15 * other widgets which are a gengrid with some more logic on top. 15 * other widgets which are a gengrid with some more logic on top.
16 */ 16 */
17 17
18
19typedef struct _Gengrid_Focus_Direction_Mod_Api Gengrid_Focus_Direction_Mod_Api;
20
21struct _Gengrid_Focus_Direction_Mod_Api
22{
23 eo_op_func_type hook_ptr;
24};
25
26
27/** 18/**
28 * Base widget smart data extended with gengrid instance data. 19 * Base widget smart data extended with gengrid instance data.
29 */ 20 */
@@ -119,8 +110,6 @@ struct _Elm_Gengrid_Smart_Data
119 Eina_Bool show_region : 1; 110 Eina_Bool show_region : 1;
120 Eina_Bool bring_in : 1; 111 Eina_Bool bring_in : 1;
121 Eina_Bool mouse_down : 1; /**< a flag that mouse is down on the list at the moment. this flag is set to true on mouse and reset to false on mouse up */ 112 Eina_Bool mouse_down : 1; /**< a flag that mouse is down on the list at the moment. this flag is set to true on mouse and reset to false on mouse up */
122 /* a flag for focus direction. by default it is false */
123 Eina_Bool focus_direction : 1;
124}; 113};
125 114
126struct Elm_Gen_Item_Type 115struct Elm_Gen_Item_Type
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index 7b9697058..00fbcc05c 100644
--- a/src/modules/Makefile.am
+++ b/src/modules/Makefile.am
@@ -6,5 +6,4 @@ prefs \
6test_entry \ 6test_entry \
7test_map \ 7test_map \
8access_output \ 8access_output \
9datetime_input_ctxpopup \ 9datetime_input_ctxpopup
10gengrid_focus_hook
diff --git a/src/modules/gengrid_focus_hook/Makefile.am b/src/modules/gengrid_focus_hook/Makefile.am
deleted file mode 100644
index 54d5b48dd..000000000
--- a/src/modules/gengrid_focus_hook/Makefile.am
+++ /dev/null
@@ -1,38 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-DELM_INTERNAL_API_ARGESFSDFEFC=1 \
6-I. \
7-I$(top_builddir) \
8-I$(top_srcdir) \
9-I$(top_srcdir)/src/lib \
10-I$(top_builddir)/src/lib \
11-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
12-DPACKAGE_LIB_DIR=\"$(libdir)\" \
13@ELEMENTARY_CFLAGS@ \
14@ELEMENTARY_X_CFLAGS@ \
15@ELEMENTARY_FB_CFLAGS@ \
16@ELEMENTARY_SDL_CFLAGS@ \
17@ELEMENTARY_WIN32_CFLAGS@ \
18@ELEMENTARY_WINCE_CFLAGS@ \
19@ELEMENTARY_ELOCATION_CFLAGS@ \
20@ELEMENTARY_EWEATHER_CFLAGS@ \
21@ELEMENTARY_WEB_CFLAGS@ \
22@ELEMENTARY_EMAP_CFLAGS@ \
23@ELEMENTARY_WAYLAND_CFLAGS@ \
24@ELEMENTARY_EMAP_CFLAGS@ \
25@EVIL_CFLAGS@
26
27if ELEMENTARY_WINDOWS_BUILD
28AM_CPPFLAGS += -DELEMENTARY_BUILD
29endif
30
31pkgdir = $(libdir)/elementary/modules/gengrid_focus_hook/$(MODULE_ARCH)
32pkg_LTLIBRARIES = module.la
33
34module_la_SOURCES = gengrid_focus_hook.c
35
36module_la_LIBADD = @ELEMENTARY_LIBS@ $(top_builddir)/src/lib/libelementary.la
37module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
38module_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/src/modules/gengrid_focus_hook/gengrid_focus_hook.c b/src/modules/gengrid_focus_hook/gengrid_focus_hook.c
deleted file mode 100644
index 3c1d69270..000000000
--- a/src/modules/gengrid_focus_hook/gengrid_focus_hook.c
+++ /dev/null
@@ -1,491 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#include <Elementary_Cursor.h>
6#include "elm_priv.h"
7#include "elm_widget_gengrid.h"
8
9#include <limits.h>
10
11#define GG_IT(_it) (_it->item)
12
13#define EINA_INLIST_REVERSE_FOREACH_INSIDE(list, it) \
14 for (it = NULL, it = (list ? _EINA_INLIST_CONTAINER(it, list) : NULL); it; \
15 it = (EINA_INLIST_GET(it)->prev \
16 ? _EINA_INLIST_CONTAINER(it, EINA_INLIST_GET(it)->prev) \
17 : NULL))
18
19#define EINA_LIST_REVERSE_FOREACH_INSIDE(list, l, data) \
20 for (l = list, data = eina_list_data_get(l); l; \
21 l = eina_list_prev(l), data = eina_list_data_get(l))
22
23#define WEIGHT_MAX ((double)INT_MAX / (double)1000000)
24
25/**
26 * Find the first parent of object.
27 * Parent must be type of elm_gengrid.
28 *
29 * @param base
30 *
31 * @return
32 */
33static const Evas_Object *
34_find_gengrid_parent_item(const Evas_Object *base)
35{
36 const Evas_Object *res = NULL;
37 if (base)
38 {
39 const Evas_Object *parent = NULL;
40 parent = elm_widget_parent_get(base);
41
42 while (parent)
43 {
44 if (evas_object_smart_type_check(parent, "elm_gengrid"))
45 {
46 res = parent;
47 break;
48 }
49 parent = elm_widget_parent_get(parent);
50 }
51 }
52 return res;
53}
54
55static Eina_Bool
56_can_focus(const Evas_Object *obj)
57{
58 if (obj && elm_object_focus_allow_get(obj) && elm_widget_can_focus_get(obj))
59 return EINA_TRUE;
60 return EINA_FALSE;
61}
62
63static Eina_List *
64_get_contents(const Evas_Object *obj)
65{
66 Eina_List *res = NULL;
67 if (!obj) return NULL;
68
69 if (evas_object_smart_type_check(obj, "elm_layout"))
70 {
71 Evas_Object *edje = elm_layout_edje_get(obj);
72
73 if (edje)
74 {
75 const Eina_List *l = NULL;
76 const char *key;
77 const Eina_List *contents =
78 elm_widget_stringlist_get(edje_object_data_get(edje, "contents"));
79
80 EINA_LIST_FOREACH(contents, l, key)
81 {
82 if (key)
83 {
84 const Evas_Object *child =
85 edje_object_part_swallow_get(edje, key);
86 if (child)
87 {
88 Eina_List *l1 = NULL;
89 res = eina_list_append(res, child);
90
91 l1 = _get_contents(child);
92 if (l1) res = eina_list_merge(res, l1);
93 }
94 }
95 }
96 }
97 }
98 return res;
99}
100
101static Eina_List *
102_gengrid_item_contents_get(const Elm_Gen_Item *it)
103{
104 Eina_List *res = NULL;
105 Eina_List *l = NULL;
106 Evas_Object *child = NULL;
107 EINA_LIST_FOREACH(it->content_objs, l, child)
108 {
109 if (child)
110 {
111 Eina_List *l1 = NULL;
112 res = eina_list_append(res, child);
113
114 l1 = _get_contents(child);
115 if (l1) res = eina_list_merge(res, l1);
116 }
117 }
118 return res;
119}
120
121static const Evas_Object *
122_find_focusable_object(const Elm_Gen_Item *it,
123 const Evas_Object *base,
124 Elm_Focus_Direction dir)
125{
126 const Evas_Object *obj = NULL;
127 Eina_List *l = NULL;
128 Eina_List *contents = NULL;
129
130 if (!it) return NULL;
131
132 contents = _gengrid_item_contents_get(it);
133 if (contents)
134 {
135 if (base)
136 {
137 l = eina_list_data_find_list(contents, base);
138 obj = base;
139 }
140
141 if ((dir == ELM_FOCUS_LEFT) || (dir == ELM_FOCUS_UP))
142 {
143 if (l) l = eina_list_prev(l);
144 else l = eina_list_last(contents);
145
146 while (l)
147 {
148 obj = eina_list_data_get(l);
149 if (_can_focus(obj)) break;
150 obj = NULL;
151 l = eina_list_prev(l);
152 }
153 }
154 else if ((dir == ELM_FOCUS_RIGHT) || (dir == ELM_FOCUS_DOWN))
155 {
156 if (l) l = eina_list_next(l);
157 else l = contents;
158 while (l)
159 {
160 obj = eina_list_data_get(l);
161 if (_can_focus(obj)) break;
162 obj = NULL;
163 l = eina_list_next(l);
164 }
165 }
166 eina_list_free(contents);
167 }
168 return obj;
169}
170
171
172
173static Eina_Bool
174_check_item_contains(Elm_Gen_Item *it, const Evas_Object *base)
175{
176 Eina_Bool res = EINA_FALSE;
177 Eina_List *contents = NULL;
178 contents = _gengrid_item_contents_get(it);
179
180 if (contents)
181 {
182 const Eina_List *l = NULL;
183 Evas_Object *content = NULL;
184
185 // loop contents (Evas_Object) of item
186 EINA_LIST_FOREACH(contents, l, content)
187 {
188 if (content == base)
189 {
190 res = EINA_TRUE;
191 break;
192 }
193 }
194 eina_list_free(contents);
195 }
196 return res;
197}
198
199static Elm_Gen_Item *
200_find_item_for_base(const Evas_Object *obj,
201 const Evas_Object *base)
202{
203 ELM_GENGRID_CHECK(obj) EINA_FALSE;
204 ELM_GENGRID_DATA_GET(obj, sd);
205 Elm_Gen_Item *res = NULL;
206 Elm_Gen_Item *it = (Elm_Gen_Item *)(sd->last_selected_item);
207
208 if (it && (_check_item_contains(it, base))) res = it;
209 else
210 { // try find in all
211 EINA_INLIST_FOREACH(sd->items, it)
212 {
213 if (it && _check_item_contains(it, base))
214 {
215 res = it;
216 break;
217 }
218 }
219 }
220 return res;
221}
222
223static Eina_Bool
224_gengrid_self_focus_item_get(const Evas_Object *obj, const Evas_Object *base,
225 // list of Elm_Gen_Items
226 const Eina_List *items,
227 void *(*list_data_get)(const Eina_List *l) EINA_UNUSED,
228 double degree, Evas_Object **direction,
229 double *weight)
230{
231 Evas_Coord ox, oy;
232 Evas_Coord vw, vh;
233 const Evas_Object *res_obj = NULL;
234 Elm_Focus_Direction dir = ELM_FOCUS_UP;
235 unsigned int items_count = 0;
236 unsigned int columns = 0, items_visible = 0;
237 unsigned int items_row = 0, items_col = 0, rows = 0;
238 int new_position = 0;
239 int cx = 0;
240 int cy = 0;
241 int focused_pos = 0;
242 Elm_Gen_Item *it = NULL;
243 Elm_Gen_Item *it_res = NULL;
244 Eina_List *list = NULL;
245 Eina_List *l = NULL;
246 Elm_Gen_Item *focused_item = NULL;
247 ELM_GENGRID_CHECK(obj) EINA_FALSE;
248 ELM_GENGRID_DATA_GET(obj, sd);
249
250 if ((!direction) || (!weight) || (!base) || (!items)) return EINA_FALSE;
251
252 evas_object_geometry_get(sd->pan_obj, &ox, &oy, &vw, &vh);
253
254 focused_item = _find_item_for_base(obj, base);
255 if (!focused_item) return EINA_FALSE;
256
257 if (degree == 0) dir = ELM_FOCUS_UP;
258 else if (degree == 90) dir = ELM_FOCUS_RIGHT;
259 else if (degree == 180) dir = ELM_FOCUS_DOWN;
260 else if (degree == 270) dir = ELM_FOCUS_LEFT;
261 else return EINA_FALSE;
262
263 res_obj = _find_focusable_object(focused_item, base, dir);
264 if (res_obj && (res_obj != base))
265 {
266 *direction = (Evas_Object *)res_obj;
267 *weight = WEIGHT_MAX;
268 return EINA_TRUE;
269 }
270
271 focused_pos = focused_item->position - 1;
272
273 items_count = sd->item_count -
274 eina_list_count(sd->group_items) + sd->items_lost;
275 if (sd->horizontal)
276 {
277 if (sd->item_height > 0) items_visible = vh / sd->item_height;
278 if (items_visible < 1) items_visible = 1;
279
280 columns = items_count / items_visible;
281 if (items_count % items_visible) columns++;
282
283 items_row = items_visible;
284 if (items_row > sd->item_count) items_row = sd->item_count;
285
286 cx = focused_pos / items_row;
287 cy = focused_pos % items_row;
288 }
289 else
290 {
291 if (sd->item_width > 0) items_visible = vw / sd->item_width;
292 if (items_visible < 1) items_visible = 1;
293
294 rows = items_count / items_visible;
295 if (items_count % items_visible) rows++;
296
297 items_col = items_visible;
298 if (items_col > sd->item_count) items_col = sd->item_count;
299
300 cy = focused_pos / items_col;
301 cx = focused_pos % items_col;
302 }
303
304
305 if (dir == ELM_FOCUS_UP) cy--;
306 else if (dir == ELM_FOCUS_RIGHT) cx++;
307 else if (dir == ELM_FOCUS_DOWN) cy++;
308 else if (dir == ELM_FOCUS_LEFT) cx--;
309
310 if (cx < 0 || cy < 0) return EINA_FALSE;
311
312 if (sd->horizontal)
313 {
314 if ((cy > (int)(items_row - 1)) ||
315 (cx > (int)(columns - 1))) return EINA_FALSE;
316 new_position = items_row * cx + cy;
317 }
318 else
319 {
320 if ((cx > (int)(items_col - 1)) ||
321 (cy > (int)(rows - 1))) return EINA_FALSE;
322 new_position = cx + items_col * cy;
323 }
324
325 if (new_position > (int)(items_count - 1)) return EINA_FALSE;
326
327 focused_pos++;
328 new_position++;
329
330 list = eina_list_data_find_list(items, focused_item);
331
332 if (!list) return EINA_FALSE;
333
334 if (new_position > focused_pos)
335 {
336 /// New position should be after focused
337 EINA_LIST_FOREACH(list, l, it)
338 {
339 if (it->position == new_position)
340 {
341 it_res = it;
342 break;
343 }
344 }
345 }
346 else if (new_position < focused_pos)
347 {
348 /// New position should be before focused
349 EINA_LIST_REVERSE_FOREACH_INSIDE(list, l, it)
350 {
351 if (it->position == new_position)
352 {
353 it_res = it;
354 break;
355 }
356 }
357 }
358 else return EINA_FALSE;
359
360 if (it_res)
361 {
362 res_obj = _find_focusable_object(it_res, base, dir);
363 *direction = (Evas_Object *)res_obj;
364 *weight = WEIGHT_MAX;
365 return EINA_TRUE;
366 }
367 return EINA_FALSE;
368}
369
370static Eina_Bool
371_gengrid_focus_list_direction_get(const Evas_Object *obj,
372 const Evas_Object *base,
373 // list of Elm_Gen_Items
374 const Eina_List *items,
375 void *(*list_data_get)(const Eina_List *l),
376 double degree, Evas_Object **direction,
377 double *weight)
378{
379 const Eina_List *l = NULL;
380 Evas_Object *current_best = NULL;
381 ELM_GENGRID_CHECK(obj) EINA_FALSE;
382
383 if ((!direction) || (!weight) || (!base) || (!items)) return EINA_FALSE;
384
385 l = items;
386 current_best = *direction;
387
388 // loop items Elm_Gen_Item
389 for (; l; l = eina_list_next(l))
390 {
391 Eina_List *contents = NULL;
392 Elm_Gen_Item *it = list_data_get(l);
393 contents = _gengrid_item_contents_get(it);
394 if (contents)
395 {
396 const Eina_List *l2 = NULL;
397 Evas_Object *content = NULL;
398
399 // loop contents (Evas_Object) of item
400 EINA_LIST_FOREACH(contents, l2, content)
401 {
402 // if better element than set new sd->focused and sd->selected
403 elm_widget_focus_direction_get(content, base, degree,
404 direction, weight);
405 }
406 eina_list_free(contents);
407 }
408 }
409 if (current_best != *direction) return EINA_TRUE;
410 return EINA_FALSE;
411}
412
413EAPI void
414gen_focus_direction(Eo *obj, void *_pd, va_list *list)
415{
416 Eina_List *items = NULL;
417 const Evas_Object *parent = NULL;
418 void *(*list_data_get)(const Eina_List * list);
419 Eina_List *(*list_free)(Eina_List * list);
420 Elm_Gengrid_Smart_Data *sd = _pd;
421 Eina_Bool (*list_direction_get)(const Evas_Object * obj, const Evas_Object * base,
422 const Eina_List * items, void * (*list_data_get)(const Eina_List * l),
423 double degree, Evas_Object * *direction, double * weight);
424
425 Evas_Object *base = va_arg(*list, Evas_Object *);
426 double degree = va_arg(*list, double);
427 Evas_Object **direction = va_arg(*list, Evas_Object **);
428 double *weight = va_arg(*list, double *);
429 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
430
431 if (!sd)
432 {
433 *ret = EINA_FALSE;
434 return;
435 }
436
437 *ret = EINA_FALSE;
438 list_data_get = NULL;
439 list_direction_get = NULL;
440 list_free = NULL;
441 parent = _find_gengrid_parent_item(base);
442
443 /// If focused is subobject of this gengrid then we selected next
444 /// in direction
445 if (obj == parent)
446 {
447 items = elm_gengrid_realized_items_get(obj);
448 list_data_get = NULL;
449 list_direction_get = _gengrid_self_focus_item_get;
450 list_free = eina_list_free;
451 }
452
453 if (!items)
454 {
455 items = (Eina_List *)(elm_object_focus_custom_chain_get(obj));
456 list_data_get = eina_list_data_get;
457 list_direction_get = elm_widget_focus_list_direction_get;
458 list_free = NULL;
459 }
460
461 if (!items)
462 {
463 items = elm_gengrid_realized_items_get(obj);
464 list_data_get = eina_list_data_get;
465 list_direction_get = _gengrid_focus_list_direction_get;
466 list_free = eina_list_free;
467 }
468
469 if (!items)
470 {
471 *ret = EINA_FALSE;
472 return;
473 }
474
475 *ret = list_direction_get(obj, base, items, list_data_get, degree,
476 direction, weight);
477 if (list_free) list_free(items);
478}
479
480// module api funcs needed
481EAPI int
482elm_modapi_init(void *m EINA_UNUSED)
483{
484 return 1; // succeed always
485}
486
487EAPI int
488elm_modapi_shutdown(void *m EINA_UNUSED)
489{
490 return 1; // succeed always
491}