}
}
}
-
- { //Panel
- Evas_Object *panel = elm_panel_add(win);
- elm_panel_orient_set(panel, ELM_PANEL_ORIENT_LEFT);
- 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_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, "Panel");
- 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);
- }
- }
- }
}
}
static Eina_Bool
-_elm_box_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_box_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
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;
if (!items) return EINA_FALSE;
}
- last_focused =
- elm_widget_focus_cycle_next_get(obj, items, list_data_get, dir, circular);
-
- return !!last_focused;
+ return elm_widget_focus_cycle_next_get(obj, items, list_data_get, dir, next);
}
static void
}
static Eina_Bool
-_elm_bubble_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_bubble_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *cur;
cur = wd->content;
/* Try Focus cycle in subitem */
- return elm_widget_focus_cycle(cur, dir, circular);
+ return elm_widget_focus_cycle(cur, dir, next);
}
static void
}
static Eina_Bool
-_elm_flip_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_flip_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
Widget_Data *wd = elm_widget_data_get(obj);
/* Try Focus cycle in subitem */
if (wd->state)
- return elm_widget_focus_cycle(wd->front.content, dir, circular);
+ return elm_widget_focus_cycle(wd->front.content, dir, next);
else
- return elm_widget_focus_cycle(wd->back.content, dir, circular);
+ return elm_widget_focus_cycle(wd->back.content, dir, next);
}
}
static Eina_Bool
-_elm_frame_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_frame_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *cur;
cur = wd->content;
/* Try Focus cycle in subitem */
- return elm_widget_focus_cycle(cur, dir, circular);
+ return elm_widget_focus_cycle(cur, dir, next);
}
static void
}
static Eina_Bool
-_elm_layout_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_layout_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
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;
if (!items) return EINA_FALSE;
}
- last_focused = elm_widget_focus_cycle_next_get(obj, items,
- list_data_get, dir,
- circular);
-
- return !!last_focused;
+ return elm_widget_focus_cycle_next_get(obj, items, list_data_get, dir,
+ next);
}
static void
}
static Eina_Bool
-_elm_pager_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_pager_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *cur;
cur = wd->top->content;
/* Try Focus cycle in subitem */
- return elm_widget_focus_cycle(cur, dir, circular);
+ return elm_widget_focus_cycle(cur, dir, next);
}
static void
}
static Eina_Bool
-_elm_panel_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_panel_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *cur;
cur = wd->content;
/* Try Focus cycle in subitem */
- if ((!wd->hidden) && elm_widget_focus_cycle(cur, dir, circular))
- return EINA_TRUE;
- /* Ignore is previous focused */
- if (elm_widget_focus_get(obj) && (!circular))
- return EINA_FALSE;
- /* Get Focus*/
- elm_widget_focus_steal(obj);
- return EINA_TRUE;
+ if (!wd->hidden)
+ return elm_widget_focus_cycle(cur, dir, next);
+
+ /* Return */
+ *next = obj;
+ return !elm_widget_focus_get(obj);
}
static void
}
static Eina_Bool
-_elm_panes_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_panes_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
Widget_Data *wd = elm_widget_data_get(obj);
double w, h;
edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
if ((wd->horizontal && ( h == 0.0 )) || ((!wd->horizontal) && ( w == 0.0 )))
- return elm_widget_focus_cycle(wd->contents.right, dir, circular);
+ return elm_widget_focus_cycle(wd->contents.right, dir, next);
Evas_Object *chain[2];
else
return EINA_FALSE;
- unsigned int i;
-
- for ( i = (unsigned int) elm_widget_focus_get(chain[1]); i < 2; i++ )
- if (elm_widget_focus_cycle(chain[i], dir, EINA_FALSE))
- return EINA_TRUE;
-
- if (!circular)
- return EINA_FALSE;
-
- if (elm_widget_focus_cycle(chain[0], dir, EINA_TRUE))
- return EINA_TRUE;
-
- return elm_widget_focus_cycle(chain[1], dir, EINA_TRUE);
+ if (elm_widget_focus_get(chain[1]))
+ {
+ Evas_Object *to_focus;
+ if (elm_widget_focus_cycle(chain[1], dir, next))
+ return EINA_TRUE;
+ elm_widget_focus_cycle(chain[0], dir, &to_focus);
+ if (to_focus)
+ *next = to_focus;
+ return EINA_FALSE;
+ }
+ else
+ {
+ Evas_Object *to_focus;
+ if (elm_widget_focus_cycle(chain[0], dir, next))
+ return EINA_TRUE;
+ if (elm_widget_focus_cycle(chain[1], dir, &to_focus))
+ {
+ *next = to_focus;
+ return EINA_TRUE;
+ }
+ if (!(*next))
+ *next = to_focus;
+ return EINA_FALSE;
+ }
}
static void
}
static Eina_Bool
-_elm_scroller_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_scroller_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *cur;
cur = wd->content;
/* Try Focus cycle in subitem */
- if (elm_widget_focus_cycle(cur, dir, circular))
- return EINA_TRUE;
- /* Abort if content is focusable */
if (elm_widget_can_focus_get(cur) || elm_widget_child_can_focus_get(cur))
- return EINA_FALSE;
- /* Ignore is previous focused */
- if (elm_widget_focus_get(obj) && (!circular))
- return EINA_FALSE;
- /* Get Focus*/
- elm_widget_focus_steal(obj);
- return EINA_TRUE;
+ return elm_widget_focus_cycle(cur, dir, next);
+
+ /* Return */
+ *next = obj;
+ return !elm_widget_focus_get(obj);
}
static void
}
static Eina_Bool
-_elm_table_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+_elm_table_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
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;
if (!items) return EINA_FALSE;
}
- last_focused = elm_widget_focus_cycle_next_get(obj, items,
- list_data_get, dir,
- circular);
+ Eina_Bool ret = elm_widget_focus_cycle_next_get(obj, items, list_data_get,
+ dir, next);
if (list_free)
items = list_free(items);
- return !!last_focused;
+ return ret;
}
static void
void (*changed_func) (Evas_Object *obj);
Eina_Bool (*focus_cycle_func) (Evas_Object *obj,
Elm_Focus_Direction dir,
- Eina_Bool circular);
+ Evas_Object **next);
void (*on_focus_func) (void *data, Evas_Object *obj);
void *on_focus_data;
void (*on_change_func) (void *data, Evas_Object *obj);
Eina_Bool highlight_ignore : 1;
Eina_Bool highlight_in_theme : 1;
Eina_Bool disabled : 1;
+
+ struct
+ {
+ Eina_List *custom_linear_chain;
+ } focus;
};
/* local subsystem functions */
}
EAPI void
-elm_widget_focus_cycle_hook_set(Evas_Object *obj, Eina_Bool (*func) (Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular))
+elm_widget_focus_cycle_hook_set(Evas_Object *obj, Eina_Bool (*func) (Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next))
{
API_ENTRY return;
sd->focus_cycle_func = func;
}
EAPI Eina_Bool
-elm_widget_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
+elm_widget_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
+ if (!next)
+ return EINA_FALSE;
+ *next = NULL;
+
API_ENTRY return EINA_FALSE;
/* Ignore if disabled */
/* Try use hook */
if (sd->focus_cycle_func)
- return sd->focus_cycle_func(obj, dir, circular);
+ return sd->focus_cycle_func(obj, dir, next);
- /* Ignore if previous focused*/
- if ((!elm_widget_can_focus_get(obj)) || (elm_widget_focus_get(obj) && (!circular)))
+ if (!elm_widget_can_focus_get(obj))
return EINA_FALSE;
- /* Get focus*/
- elm_widget_focus_steal(obj);
- return EINA_TRUE;
+ /* Return */
+ *next = obj;
+ return !elm_widget_focus_get(obj);
}
-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 Eina_Bool
+elm_widget_focus_cycle_next_get(Evas_Object *obj, Eina_List *items, void *(*list_data_get) (const Eina_List *list), Elm_Focus_Direction dir, Evas_Object **next)
{
- Eina_List *list = NULL;
- Eina_List *l = NULL;
- Evas_Object *cur = NULL;
Eina_List *(*list_next) (const Eina_List *list);
- Eina_Bool child_circular;
+
+ if (!next)
+ return EINA_FALSE;
+ *next = NULL;
if (!items)
- return NULL;
+ return EINA_FALSE;
/* Direction */
if (dir == ELM_FOCUS_PREVIOUS)
{
- list = eina_list_last(items);
+ items = eina_list_last(items);
list_next = eina_list_prev;
}
else if (dir == ELM_FOCUS_NEXT)
{
- list = items;
+ items= items;
list_next = eina_list_next;
}
else
- return NULL;
+ return EINA_FALSE;
+
+ Eina_List *l = items;
/* Recovery last focused sub item */
if (elm_widget_focus_get(obj))
- for (l = items; l; l = eina_list_next(l))
+ for (; l; l = list_next(l))
{
- cur = list_data_get(l);
+ Evas_Object *cur = list_data_get(l);
if (elm_widget_focus_get(cur))
- break;
+ {
+ break;
+ }
}
+ Eina_List *start = l;
+ Evas_Object *to_focus = NULL;
+
/* Interate sub items */
- child_circular = EINA_FALSE;
- do {
- if (!l)
- l = list;
+ /* Go to end of list */
+ for (;l; l = list_next(l))
+ {
+ Evas_Object *tmp = NULL;
+ Evas_Object *cur = list_data_get(l);
- for (;l; l = list_next(l))
+ /* Try Focus cycle in subitem */
+ if (elm_widget_focus_cycle(cur, dir, &tmp))
{
- cur = list_data_get(l);
-
- /* Try Focus cycle in subitem */
- if (elm_widget_focus_cycle(cur, dir, child_circular))
- break;
+ *next = tmp;
+ return EINA_TRUE;
}
- circular = circular && (!child_circular);
- child_circular = !child_circular;
- }
- while ((!l) && circular);
+ else if (tmp && (!to_focus))
+ to_focus = tmp;
+ }
- if (l)
- return cur;
+ l = items;
- return NULL;
+ /* Get First possible */
+ for (;l != start; l = list_next(l))
+ {
+ Evas_Object *tmp = NULL;
+ Evas_Object *cur = list_data_get(l);
+
+ /* Try Focus cycle in subitem */
+ elm_widget_focus_cycle(cur, dir, &tmp);
+ if (tmp)
+ {
+ *next = tmp;
+ return EINA_FALSE;
+ }
+ }
+
+ *next = to_focus;
+ return EINA_FALSE;
}
EAPI int
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_focus_cycle_hook_set(Evas_Object *obj, Eina_Bool (*func) (Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next));
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);
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 Eina_Bool elm_widget_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next);
+EAPI Eina_Bool elm_widget_focus_cycle_next_get(Evas_Object *obj, Eina_List *items, void *(*list_data_get) (const Eina_List *list), Elm_Focus_Direction dir, Evas_Object **next);
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);
}
static Eina_Bool
-_elm_win_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular __UNUSED__)
+_elm_win_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
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;
- circular = EINA_TRUE;
-
/* 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);
+ elm_widget_focus_cycle_next_get(obj, items, list_data_get, dir, next);
- return !!last_focused;
+ if (*next)
+ return EINA_TRUE;
+ return EINA_FALSE;
}
static Eina_Bool
Evas_Event_Key_Down *ev = event_info;
if (!strcmp(ev->keyname, "Tab"))
{
+ Evas_Object *target;
if(evas_key_modifier_is_set(ev->modifiers, "Shift"))
- elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS, EINA_TRUE);
+ elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS, &target);
else
- elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT, EINA_TRUE);
+ elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT, &target);
+ if (target)
+ elm_widget_focus_steal(target);
return EINA_TRUE;
}
}
}
static Eina_Bool
-_elm_inwin_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular __UNUSED__)
+_elm_inwin_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *cur;
cur = wd->content;
/* Try Focus cycle in subitem */
- return elm_widget_focus_cycle(cur, dir, EINA_TRUE);
+ elm_widget_focus_cycle(cur, dir, next);
+ if (*next)
+ return EINA_TRUE;
+ return EINA_FALSE;
}
static void