From: Enlightenment S. <no-...@en...> - 2010-09-27 21:13:43
|
Log: Focus Cycle Chain to Table Author: tiago Date: 2010-09-27 14:13:36 -0700 (Mon, 27 Sep 2010) New Revision: 52815 Modified: trunk/TMP/st/elementary/src/bin/test_focus.c trunk/TMP/st/elementary/src/lib/elm_table.c Modified: trunk/TMP/st/elementary/src/bin/test_focus.c =================================================================== --- trunk/TMP/st/elementary/src/bin/test_focus.c 2010-09-27 21:13:32 UTC (rev 52814) +++ trunk/TMP/st/elementary/src/bin/test_focus.c 2010-09-27 21:13:36 UTC (rev 52815) @@ -257,18 +257,24 @@ } } - //{//Third Col - // Evas_Object *fs = elm_fileselector_add(win); - // elm_fileselector_is_save_set(fs, EINA_TRUE); - // elm_fileselector_expandable_set(fs, EINA_TRUE); - // evas_object_size_hint_align_set(fs, 200, 600); - // elm_fileselector_path_set(fs, getenv("HOME")); - // evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, - // EVAS_HINT_EXPAND); - // evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL); - // elm_box_pack_end(mainbx, fs); - // my_show(fs); - //} + {//Third Col + Evas_Object *tb = elm_table_add(win); + evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_box_pack_end(mainbx, tb); + my_show(tb); + for (j = 0; j < 3; j++) + for (i = 0; i < 3; i++) + { + Evas_Object *bt; + bt = elm_button_add(win); + elm_button_label_set(bt, "Button"); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_table_pack(tb, bt, i, j, 1, 1); + my_show(bt); + } + } { //Panel Evas_Object *panel = elm_panel_add(win); Modified: trunk/TMP/st/elementary/src/lib/elm_table.c =================================================================== --- trunk/TMP/st/elementary/src/lib/elm_table.c 2010-09-27 21:13:32 UTC (rev 52814) +++ trunk/TMP/st/elementary/src/lib/elm_table.c 2010-09-27 21:13:36 UTC (rev 52815) @@ -40,6 +40,47 @@ free(wd); } +static Eina_Bool +_elm_table_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular) +{ + Widget_Data *wd = elm_widget_data_get(obj); + Eina_List *items; + void *(*list_data_get) (const Eina_List *list); + Eina_List *(*list_free) (Eina_List *list); + Evas_Object *last_focused; + + if ((!wd) || (!wd->tbl)) + return EINA_FALSE; + + /* Focus chain */ + /* TODO: Change this to use other chain */ + if (1) + { + items = evas_object_table_children_get(wd->tbl); + list_data_get = eina_list_data_get; + list_free = eina_list_free; + + if (!items) return EINA_FALSE; + } + else + { + items = NULL; + list_data_get = eina_list_data_get; + list_free = NULL; + + if (!items) return EINA_FALSE; + } + + last_focused = elm_widget_focus_cycle_next_get(obj, items, + list_data_get, dir, + circular); + + if (list_free) + items = list_free(items); + + return !!last_focused; +} + static void _sizing_eval(Evas_Object *obj) { @@ -103,6 +144,9 @@ elm_widget_data_set(obj, wd); elm_widget_del_hook_set(obj, _del_hook); elm_widget_del_pre_hook_set(obj, _del_pre_hook); + elm_widget_focus_cycle_hook_set(obj, _elm_table_focus_cycle_hook); + elm_widget_can_focus_set(obj, EINA_FALSE); + elm_widget_highlight_ignore_set(obj, EINA_FALSE); wd->tbl = evas_object_table_add(e); evas_object_event_callback_add(wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS, |