Focus Linear Chain for some Widgets

Containers implemented (and with test):
* Win
* Box
* Scroller
* Layout
* Panel

SVN revision: 52686
This commit is contained in:
Tiago Rezende Campos Falcao 2010-09-24 14:47:59 +00:00
parent 4743f7f5b5
commit 113ad55d2e
11 changed files with 630 additions and 4 deletions

View File

@ -405,5 +405,50 @@ collections {
}
}
}
group { name: "twolines";
parts {
part { name: "clip";
type: RECT;
description { state: "default" 0.0;
}
}
part { name: "under";
mouse_events: 0;
clip_to: "clip";
type: RECT;
description { state: "default" 0.0;
color: 0 128 200 30;
}
}
part { name: "element1";
type: SWALLOW;
clip_to: "clip";
description { state: "default" 0.0;
rel1 {
relative: 0.0 0.0;
offset: 4 4;
}
rel2 {
relative: 1.0 0.5;
offset: -5 -3;
}
}
}
part { name: "element2";
type: SWALLOW;
clip_to: "clip";
description { state: "default" 0.0;
rel1 {
relative: 0.0 0.5;
offset: 4 2;
}
rel2 {
relative: 1.0 1.0;
offset: -5 -5;
}
}
}
}
}
}

View File

@ -84,7 +84,8 @@ test_launcher.c \
test_anim.c \
test_calendar.c \
test_tooltip.c \
test_cursor.c
test_cursor.c \
test_focus.c
elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la @ELEMENTARY_EWEATHER_LIBS@
elementary_test_LDFLAGS =

View File

@ -84,6 +84,7 @@ void test_anim(void *data, Evas_Object *obj, void *event_info);
void test_tooltip(void *data, Evas_Object *obj, void *event_info);
void test_cursor(void *data, Evas_Object *obj, void *event_info);
void test_cursor2(void *data, Evas_Object *obj, void *event_info);
void test_focus(void *data, Evas_Object *obj, void *event_info);
struct elm_test
{
@ -288,6 +289,7 @@ my_win_main(char *autorun)
ADD_TEST("Tooltip", test_tooltip);
ADD_TEST("Cursor", test_cursor);
ADD_TEST("Cursor 2", test_cursor2);
ADD_TEST("Focus", test_focus);
#undef ADD_TEST
if (autorun)

View File

@ -0,0 +1,303 @@
/* Test for Focus Chain Linear*/
#include <Elementary.h>
static void
_on_key_down(void *data, Evas *e, Evas_Object *obj, void *einfo)
{
//Evas_Event_Key_Down *event = einfo;
//printf("%s %p Key %s Parent %p\n", evas_object_type_get(obj),
// obj, event->keyname, evas_object_smart_parent_get(obj));
}
static inline void
my_show(Evas_Object *obj)
{
evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
_on_key_down, NULL);
evas_object_show(obj);
}
void
test_focus(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *win;
unsigned int i, j;
win = elm_win_add(NULL, "focus", ELM_WIN_BASIC);
elm_win_title_set(win, "Focus");
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
evas_object_resize(win, 800, 600);
elm_win_autodel_set(win, EINA_TRUE);
my_show(win);
{
Evas_Object *bg;
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
my_show(bg);
}
Evas_Object *mainbx = elm_box_add(win);
elm_box_horizontal_set(mainbx, EINA_TRUE);
elm_win_resize_object_add(win, mainbx);
evas_object_size_hint_weight_set(mainbx, 0.0, 0.0);
my_show(mainbx);
{ //First Col
Evas_Object *bx = elm_box_add(win);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
elm_box_pack_end(mainbx, bx);
my_show(bx);
{
Evas_Object *lb = elm_label_add(win);
elm_label_label_set(lb,
"<b>Use Tab and Shift+Tab</b>"
);
evas_object_size_hint_weight_set(lb, 0.0, 0.0);
evas_object_size_hint_align_set(lb, EVAS_HINT_FILL,
EVAS_HINT_FILL);
elm_box_pack_end(bx, lb);
my_show(lb);
}
{
Evas_Object *tg = elm_toggle_add(win);
elm_toggle_states_labels_set(tg, "Yes", "No");
elm_box_pack_end(bx, tg);
my_show(tg);
}
{
Evas_Object *en = elm_scrolled_entry_add(win);
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
elm_scrolled_entry_entry_set(en, "This is a single line");
elm_scrolled_entry_single_line_set(en, 1);
elm_box_pack_end(bx, en);
my_show(en);
}
{
Evas_Object *bx2 = elm_box_add(win);
elm_box_horizontal_set(bx2, EINA_TRUE);
evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
elm_box_pack_end(bx, bx2);
for (i = 3; i; 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, 0.0, 0.0);
elm_box_pack_end(bx2, bt);
my_show(bt);
}
my_show(bx2);
}
{
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, 0.0, 0.0);
elm_box_pack_end(bx, bt);
my_show(bt);
}
{
Evas_Object *bt;
bt = elm_button_add(win);
elm_button_label_set(bt, "Without Highlight");
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, 0.0, 0.0);
//elm_widget_highlight_ignore_set(bt, EINA_TRUE);
elm_box_pack_end(bx, bt);
my_show(bt);
}
{
Evas_Object *bx2 = elm_box_add(win);
elm_box_horizontal_set(bx2, EINA_TRUE);
evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
elm_box_pack_end(bx, bx2);
my_show(bx2);
for (i = 2; i; i--)
{
Evas_Object *bx3 = elm_box_add(win);
evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx3, 0.0, 0.0);
elm_box_pack_end(bx2, bx3);
my_show(bx3);
for (j = 3; j; j--)
{
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, 0.0, 0.0);
elm_box_pack_end(bx3, bt);
my_show(bt);
}
}
{
Evas_Object *sc = elm_scroller_add(win);
evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(sc, EVAS_HINT_FILL,
EVAS_HINT_FILL);
elm_scroller_bounce_set(sc, 0, 1);
elm_scroller_content_min_limit(sc, 1, 0);
elm_box_pack_end(bx2, sc);
my_show(sc);
Evas_Object *bx3 = elm_box_add(win);
evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx3, 0.0, 0.0);
elm_scroller_content_set(sc, bx3);
my_show(bx3);
for (i = 5; i; 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, 0.0, 0.0);
if (i%2)
{
//elm_widget_highlight_ignore_set(bt, EINA_TRUE);
elm_button_label_set(bt, "Without Highlight");
}
elm_box_pack_end(bx3, bt);
my_show(bt);
}
}
}
}
{//Second Col
char buf[PATH_MAX];
Evas_Object *ly = elm_layout_add(win);
snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
elm_layout_file_set(ly, buf, "twolines");
evas_object_size_hint_align_set(ly, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
elm_box_pack_end(mainbx, ly);
my_show(ly);
{
Evas_Object *bx2 = elm_box_add(win);
elm_box_horizontal_set(bx2, EINA_TRUE);
evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
elm_layout_content_set(ly, "element1", bx2);
my_show(bx2);
for (i = 3; i; 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, 0.0, 0.0);
elm_box_pack_end(bx2, bt);
my_show(bt);
}
}
{
Evas_Object *bx2 = elm_box_add(win);
evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
elm_layout_content_set(ly, "element2", bx2);
my_show(bx2);
for (i = 3; i; 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, 0.0, 0.0);
elm_box_pack_end(bx2, bt);
my_show(bt);
}
}
}
//{//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);
//}
{ //Panel
Evas_Object *panel = elm_panel_add(win);
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_BOTTOM);
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_win_resize_object_add(win, panel);
my_show(panel);
elm_panel_hidden_set(panel, EINA_TRUE);
{
Evas_Object *bx2 = elm_box_add(win);
evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
elm_panel_content_set(panel, bx2);
my_show(bx2);
for (i = 3; i; 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_box_pack_end(bx2, bt);
my_show(bt);
}
}
}
}

View File

@ -85,6 +85,49 @@ _del_hook(Evas_Object *obj)
free(wd);
}
static void *
_elm_box_list_data_get(const Eina_List *list)
{
Evas_Object_Box_Option *opt = eina_list_data_get(list);
return opt->obj;
}
static Eina_Bool
_elm_box_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);
Evas_Object *last_focused;
if ((!wd) || (!wd->box))
return EINA_FALSE;
/* Focus chain */
/* TODO: Change this to use other chain */
if (1)
{
Evas_Object_Box_Data *bd = evas_object_smart_data_get(wd->box);
items = bd->children;
list_data_get = _elm_box_list_data_get;
if (!items) return EINA_FALSE;
}
else
{
items = NULL;
list_data_get = eina_list_data_get;
if (!items) return EINA_FALSE;
}
last_focused = elm_widget_focus_cycle_next_get(obj, items,
list_data_get, dir,
circular);
return !!last_focused;
}
static void
_sizing_eval(Evas_Object *obj)
{
@ -312,8 +355,9 @@ elm_box_add(Evas_Object *parent)
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_can_focus_set(obj, 0);
elm_widget_highlight_ignore_set(obj, 1);
elm_widget_focus_cycle_hook_set(obj, _elm_box_focus_cycle_hook);
elm_widget_can_focus_set(obj, EINA_FALSE);
elm_widget_highlight_ignore_set(obj, EINA_FALSE);
wd->box = evas_object_box_add(e);
/*evas_object_box_layout_set(wd->box, evas_object_box_layout_vertical,

View File

@ -69,6 +69,48 @@ _changed_hook(Evas_Object *obj)
}
}
static void *
_elm_layout_list_data_get(const Eina_List *list)
{
Subinfo *si = eina_list_data_get(list);
return si->obj;
}
static Eina_Bool
_elm_layout_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);
Evas_Object *last_focused;
if ((!wd) || (!wd->subs))
return EINA_FALSE;
/* Focus chain (This block is diferent of elm_win cycle)*/
/* TODO: Change this to use other chain */
if (1)
{
items = wd->subs;
list_data_get = _elm_layout_list_data_get;
if (!items) return EINA_FALSE;
}
else
{
items = NULL;
list_data_get = eina_list_data_get;
if (!items) return EINA_FALSE;
}
last_focused = elm_widget_focus_cycle_next_get(obj, items,
list_data_get, dir,
circular);
return !!last_focused;
}
static void
_sizing_eval(Evas_Object *obj)
{
@ -151,6 +193,8 @@ elm_layout_add(Evas_Object *parent)
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_changed_hook_set(obj, _changed_hook);
elm_widget_can_focus_set(obj, EINA_FALSE);
elm_widget_focus_cycle_hook_set(obj, _elm_layout_focus_cycle_hook);
wd->lay = edje_object_add(e);
elm_widget_resize_object_set(obj, wd->lay);

View File

@ -52,6 +52,31 @@ _theme_hook(Evas_Object *obj)
_sizing_eval(obj);
}
static Eina_Bool
_elm_panel_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
{
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->content))
return EINA_FALSE;
if (wd->hidden)
return EINA_FALSE;
/* Try Focus cycle in subitem */
if (elm_widget_focus_cycle(wd->content, dir, circular))
return EINA_TRUE;
/* Try give the focus to sub item*/
else if (elm_widget_can_focus_get(wd->content) &&
((!elm_widget_focus_get(wd->content)) || circular))
{
elm_widget_focus_steal(wd->content);
return EINA_TRUE;
}
return EINA_FALSE;
}
static void
_sizing_eval(Evas_Object *obj)
{
@ -147,7 +172,8 @@ elm_panel_add(Evas_Object *parent)
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_can_focus_set(obj, 0);
elm_widget_focus_cycle_hook_set(obj, _elm_panel_focus_cycle_hook);
elm_widget_can_focus_set(obj, EINA_FALSE);
wd->scr = elm_smart_scroller_add(evas);
elm_smart_scroller_widget_set(wd->scr, obj);

View File

@ -104,6 +104,27 @@ _theme_hook(Evas_Object *obj)
_sizing_eval(obj);
}
static Eina_Bool
_elm_scroller_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
{
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->content))
return EINA_FALSE;
/* Try Focus cycle in subitem */
if (elm_widget_focus_cycle(wd->content, dir, circular))
return EINA_TRUE;
/* Try give the focus to sub item*/
else if (elm_widget_can_focus_get(wd->content) &&
((!elm_widget_focus_get(wd->content)) || circular))
{
elm_widget_focus_steal(wd->content);
return EINA_TRUE;
}
return EINA_FALSE;
}
static void
_signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
{
@ -339,6 +360,8 @@ elm_scroller_add(Evas_Object *parent)
elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
elm_widget_focus_cycle_hook_set(obj, _elm_scroller_focus_cycle_hook);
elm_widget_can_focus_set(obj, EINA_FALSE);
wd->widget_name = eina_stringshare_add("scroller");
wd->widget_base = eina_stringshare_add("base");

View File

@ -40,6 +40,9 @@ struct _Smart_Data
Evas_Object *o, const char *emission,
const char *source));
void (*changed_func) (Evas_Object *obj);
Eina_Bool (*focus_cycle_func) (Evas_Object *obj,
Elm_Focus_Direction dir,
Eina_Bool circular);
void (*on_focus_func) (void *data, Evas_Object *obj);
void *on_focus_data;
void (*on_change_func) (void *data, Evas_Object *obj);
@ -366,6 +369,13 @@ elm_widget_theme(Evas_Object *obj)
if (sd->theme_func) sd->theme_func(obj);
}
EAPI void
elm_widget_focus_cycle_hook_set(Evas_Object *obj, Eina_Bool (*func) (Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular))
{
API_ENTRY return;
sd->focus_cycle_func = func;
}
EAPI void
elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data)
{
@ -692,6 +702,81 @@ elm_widget_parent_event_propagate(Evas_Object *obj, Evas_Callback_Type type, voi
return EINA_FALSE;
}
EAPI Eina_Bool
elm_widget_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
{
API_ENTRY return EINA_FALSE;
if (!sd->focus_cycle_func) return EINA_FALSE;
return sd->focus_cycle_func(obj, dir, circular);
}
EAPI Evas_Object *
elm_widget_focus_cycle_next_get(Evas_Object *obj, Eina_List *items, void *(*list_data_get) (const Eina_List *list), Elm_Focus_Direction dir, Eina_Bool circular)
{
Eina_List *list = NULL;
Eina_List *l = NULL;
Evas_Object *cur;
Eina_List *(*list_next) (const Eina_List *list);
Eina_Bool child_circular;
if (!items)
return NULL;
/* Direction */
if (dir == ELM_FOCUS_PREVIOUS)
{
list = eina_list_last(items);
list_next = eina_list_prev;
}
else if (dir == ELM_FOCUS_NEXT)
{
list = items;
list_next = eina_list_next;
}
else
return NULL;
/* Recovery last focused sub item */
if (elm_widget_focus_get(obj))
for (l = items; l; l = eina_list_next(l))
{
cur = list_data_get(l);
if (elm_widget_focus_get(cur))
break;
}
/* Interate sub items */
child_circular = EINA_FALSE;
do {
if (!l)
l = list;
for (;l; l = list_next(l))
{
cur = list_data_get(l);
/* Try Focus cycle in subitem */
if (elm_widget_focus_cycle(cur, dir, child_circular))
break;
/* Try give the focus to sub item*/
else if (elm_widget_can_focus_get(cur) &&
((!elm_widget_focus_get(cur)) || child_circular))
{
elm_widget_focus_steal(cur);
break;
}
}
circular = circular && (!child_circular);
child_circular = !child_circular;
}
while ((!l) && circular);
if (l)
return cur;
return NULL;
}
EAPI int
elm_widget_focus_jump(Evas_Object *obj, int forward)
{

View File

@ -189,6 +189,12 @@ typedef struct _Elm_Tooltip Elm_Tooltip;
typedef struct _Elm_Cursor Elm_Cursor;
typedef struct _Elm_Widget_Item Elm_Widget_Item; /**< base structure for all widget items that are not Elm_Widget themselves */
typedef enum _Elm_Focus_Direction
{
ELM_FOCUS_PREVIOUS,
ELM_FOCUS_NEXT
} Elm_Focus_Direction;
struct _Elm_Widget_Item
{
/* ef1 ~~ efl, el3 ~~ elm */
@ -219,6 +225,7 @@ EAPI void elm_widget_signal_emit_hook_set(Evas_Object *obj, void (*f
EAPI void elm_widget_signal_callback_add_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data));
EAPI void elm_widget_signal_callback_del_hook_set(Evas_Object *obj, void *(*func) (Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source)));
EAPI void elm_widget_theme(Evas_Object *obj);
EAPI void elm_widget_focus_cycle_hook_set(Evas_Object *obj, Eina_Bool (*func) (Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular));
EAPI void elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
EAPI void elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
@ -244,6 +251,8 @@ EAPI Evas_Object *elm_widget_top_get(const Evas_Object *obj);
EAPI Eina_Bool elm_widget_is(const Evas_Object *obj);
EAPI Evas_Object *elm_widget_parent_widget_get(const Evas_Object *obj);
EAPI Eina_Bool elm_widget_parent_event_propagate(Evas_Object *obj, Evas_Callback_Type type, void *event_info);
EAPI Eina_Bool elm_widget_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular);
EAPI Evas_Object *elm_widget_focus_cycle_next_get(Evas_Object *obj, Eina_List *items, void *(*list_data_get) (const Eina_List *list), Elm_Focus_Direction dir, Eina_Bool circular);
EAPI int elm_widget_focus_jump(Evas_Object *obj, int forward);
EAPI void elm_widget_focus_set(Evas_Object *obj, int first);
EAPI void elm_widget_focused_object_clear(Evas_Object *obj);

View File

@ -130,6 +130,48 @@ _elm_win_focus_out(Ecore_Evas *ee)
_elm_win_focus_highlight_reconfigure_job_start(win);
}
static Eina_Bool
_elm_win_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
{
Elm_Win *wd = elm_widget_data_get(obj);
Eina_List *items;
void *(*list_data_get) (const Eina_List *list);
Evas_Object *last_focused;
if ((!wd) || (!wd->subobjs))
return EINA_FALSE;
/* Focus chain */
/* TODO: Change this to use other chain */
items = wd->subobjs;
list_data_get = eina_list_data_get;
last_focused = elm_widget_focus_cycle_next_get(obj, items,
list_data_get, dir,
circular);
return !!last_focused;
}
static Eina_Bool
_elm_win_event_cb(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info)
{
if (type == EVAS_CALLBACK_KEY_DOWN)
{
Evas_Event_Key_Down *ev = event_info;
if (!strcmp(ev->keyname, "Tab"))
{
if(evas_key_modifier_is_set(ev->modifiers, "Shift"))
elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS, EINA_TRUE);
else
elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT, EINA_TRUE);
return EINA_TRUE;
}
}
return EINA_FALSE;
}
static void
_deferred_ecore_evas_free(void *data)
{
@ -880,8 +922,10 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
elm_widget_type_set(win->win_obj, "win");
ELM_SET_WIDTYPE(widtype, "win");
elm_widget_data_set(win->win_obj, win);
elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
elm_widget_focus_cycle_hook_set(win->win_obj, _elm_win_focus_cycle_hook);
evas_object_color_set(win->win_obj, 0, 0, 0, 0);
evas_object_move(win->win_obj, 0, 0);
evas_object_resize(win->win_obj, 1, 1);