group { name: "elm/list/item/default";
data.item: "selectraise" "on";
+ data.item: "focusraise" "on";
images.image: "bevel_curved_horiz_out.png" COMP;
images.image: "shadow_rounded_horiz.png" COMP;
images.image: "vgrad_med_dark.png" COMP;
group { name: "elm/list/h_item/default";
data.item: "selectraise" "on";
+ data.item: "focusraise" "on";
images.image: "bevel_curved_vert_out.png" COMP;
images.image: "shadow_rounded_vert.png" COMP;
images.image: "vgrad_med_dark.png" COMP;
elm_check_state_get(obj));
}
+static void
+_item_focused_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+ Elm_Object_Item *it = event_info;
+
+ printf("item,focused: %p\n", it);
+}
+
+static void
+_item_unfocused_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+ Elm_Object_Item *it = event_info;
+
+ printf("item,unfocused: %p\n", it);
+}
+
void test_list_focus(const char *name, const char *title, Eina_Bool horiz)
{
Evas_Object *win, *li, *bx, *bxx, *chk;
elm_list_horizontal_set(li, horiz);
elm_box_pack_end(bxx, li);
evas_object_show(li);
+ evas_object_smart_callback_add(li, "item,focused", _item_focused_cb, NULL);
+ evas_object_smart_callback_add(li, "item,unfocused", _item_unfocused_cb, NULL);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0);
*/
EAPI const char *elm_object_focus_highlight_style_get(const Evas_Object *obj);
+/**
+ * Get the focused object item
+ *
+ * This returns the focused object item.
+ *
+ * @param obj The container object
+ * @return The focused item, or @c NULL if none
+ *
+ * The focused item can be unfocused with function
+ * elm_object_item_focus_set().
+ *
+ * see @elm_object_item_focus_set()
+ * see @elm_object_item_focus_get()
+ *
+ * @ingroup Focus
+ * @since 1.10
+ */
+EAPI Elm_Object_Item *elm_object_focused_item_get(const Evas_Object *obj);
+
+/**
+ * Set the object item focused
+ *
+ * @param it The object item
+ * @param focused The focused state
+ *
+ * @see elm_object_item_focus_get()
+ *
+ * @ingroup Focus
+ * @since 1.10
+ */
+EAPI void elm_object_item_focus_set(Elm_Object_Item *it, Eina_Bool focused);
+
+/**
+ * Get whether the @p it is focused or not.
+ *
+ * @param it The object item
+ * @return @c EINA_TRUE means item is focused. @c EINA_FALSE indicates
+ * it's not. If @p obj is @c NULL, @c EINA_FALSE is returned.
+ *
+ * @see elm_object_item_focus_set()
+ *
+ * @ingroup Focus
+ * @since 1.10
+ */
+EAPI Eina_Bool elm_object_item_focus_get(const Elm_Object_Item *it);
static const char SIG_SWIPE[] = "swipe";
static const char SIG_HIGHLIGHTED[] = "highlighted";
static const char SIG_UNHIGHLIGHTED[] = "unhighlighted";
+static const char SIG_ITEM_FOCUSED[] = "item,focused";
+static const char SIG_ITEM_UNFOCUSED[] = "item,unfocused";
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
{SIG_ACTIVATED, ""},
{SIG_CLICKED_DOUBLE, ""},
{SIG_SWIPE, ""},
{SIG_HIGHLIGHTED, ""},
{SIG_UNHIGHLIGHTED, ""},
+ {SIG_ITEM_FOCUSED, ""},
+ {SIG_ITEM_UNFOCUSED, ""},
{SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
{SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
{SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
{
elm_list_item_selected_set(sd->last_selected_item, EINA_FALSE);
sd->last_selected_item = prev;
- elm_list_item_show(sd->last_selected_item);
}
else
{
elm_list_item_selected_set(prev, EINA_TRUE);
- elm_list_item_show(prev);
}
return EINA_TRUE;
}
{
elm_list_item_selected_set(sd->last_selected_item, EINA_FALSE);
sd->last_selected_item = next;
- elm_list_item_show(sd->last_selected_item);
}
else
{
elm_list_item_selected_set(next, EINA_TRUE);
- elm_list_item_show(next);
}
return EINA_TRUE;
}
_all_items_unselect(sd);
elm_list_item_selected_set(prev, EINA_TRUE);
- elm_list_item_show(prev);
return EINA_TRUE;
}
_all_items_unselect(sd);
elm_list_item_selected_set(next, EINA_TRUE);
- elm_list_item_show(next);
return EINA_TRUE;
}
static Eina_Bool
_elm_list_item_focus_set(Elm_List_Item *it, Elm_Focus_Direction dir, Eina_Bool h_mode)
{
+ ELM_LIST_DATA_GET(WIDGET(it), sd);
if (!it) return EINA_FALSE;
- if (!it->sd->focus_on_selection_enabled) return EINA_FALSE;
+ if (!sd->focus_on_selection_enabled) return EINA_FALSE;
int focus_objs = 0;
Evas_Object *focus_chain[2];
return EINA_TRUE;
}
+static Eina_Bool
+_item_focused_next(Evas_Object *obj, Elm_Focus_Direction dir)
+{
+ ELM_LIST_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
+ Elm_List_Item *it = NULL;
+
+ sd->prev_focused_item = sd->focused_item;
+ if (!sd->h_mode)
+ {
+ if ((dir == ELM_FOCUS_UP) || (dir == ELM_FOCUS_DOWN))
+ {
+ Eina_List *l = eina_list_data_find_list(sd->items, sd->focused_item);
+ if (sd->focused_item)
+ {
+ if (dir == ELM_FOCUS_DOWN)
+ it = (Elm_List_Item *)eina_list_data_get(eina_list_next(l));
+ else it = (Elm_List_Item *)eina_list_data_get(eina_list_prev(l));
+ if (!it)
+ return EINA_FALSE;
+ }
+ else
+ {
+ if (dir == ELM_FOCUS_DOWN)
+ it = (Elm_List_Item *)eina_list_data_get(sd->items);
+ else it = (Elm_List_Item *)eina_list_data_get(eina_list_last(sd->items));
+ }
+ if (elm_object_item_disabled_get((Elm_Object_Item *)it))
+ return EINA_TRUE;
+ elm_object_item_focus_set((Elm_Object_Item *)it, EINA_TRUE);
+ return EINA_TRUE;
+ }
+ else if ((dir == ELM_FOCUS_LEFT) || (dir == ELM_FOCUS_RIGHT))
+ return EINA_FALSE;
+ }
+ else
+ {
+ if ((dir == ELM_FOCUS_LEFT) || (dir == ELM_FOCUS_RIGHT))
+ {
+ Eina_List *l = eina_list_data_find_list(sd->items, sd->focused_item);
+ if (sd->focused_item)
+ {
+ if (dir == ELM_FOCUS_RIGHT)
+ it = (Elm_List_Item *)eina_list_data_get(eina_list_next(l));
+ else it = (Elm_List_Item *)eina_list_data_get(eina_list_prev(l));
+ if (!it)
+ return EINA_FALSE;
+ }
+ else
+ {
+ if (dir == ELM_FOCUS_RIGHT)
+ it = (Elm_List_Item *)eina_list_data_get(sd->items);
+ else it = (Elm_List_Item *)eina_list_data_get(eina_list_last(sd->items));
+ }
+ if (elm_object_item_disabled_get((Elm_Object_Item *)it))
+ return EINA_TRUE;
+ elm_object_item_focus_set((Elm_Object_Item *)it, EINA_TRUE);
+ return EINA_TRUE;
+ }
+ else if ((dir == ELM_FOCUS_UP) || (dir == ELM_FOCUS_DOWN))
+ return EINA_FALSE;
+ }
+ return EINA_FALSE;
+}
+
static void
_elm_list_smart_event(Eo *obj, void *_pd, va_list *list)
{
it = (Elm_List_Item *)elm_list_selected_item_get(obj);
Eina_Bool focused = _elm_list_item_focus_set(it, ELM_FOCUS_LEFT, sd->h_mode);
- if ((sd->h_mode && !focused) &&
- (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
- (_item_multi_select_up(sd)))
- || (_item_single_select_up(sd))))
+ if ((sd->h_mode && !focused))
+ {
+ if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
+ _item_multi_select_up(sd);
+ else
+ _item_single_select_up(sd);
+ }
+ if (_item_focused_next(obj, ELM_FOCUS_LEFT))
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else
- x -= step_x;
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ return;
}
else if ((!strcmp(ev->key, "Right")) ||
((!strcmp(ev->key, "KP_Right")) && !ev->string))
it = (Elm_List_Item *)elm_list_selected_item_get(obj);
Eina_Bool focused = _elm_list_item_focus_set(it, ELM_FOCUS_RIGHT, sd->h_mode);
- if ((sd->h_mode && !focused) &&
- (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
- (_item_multi_select_down(sd)))
- || (_item_single_select_down(sd))))
+ if (sd->h_mode && !focused)
+ {
+ if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
+ _item_multi_select_down(sd);
+ else
+ _item_single_select_down(sd);
+ }
+ if (_item_focused_next(obj, ELM_FOCUS_RIGHT))
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else
- x += step_x;
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ return;
}
else if ((!strcmp(ev->key, "Up")) ||
((!strcmp(ev->key, "KP_Up")) && !ev->string))
it = (Elm_List_Item *)elm_list_selected_item_get(obj);
Eina_Bool focused = _elm_list_item_focus_set(it, ELM_FOCUS_UP, sd->h_mode);
- if ((!sd->h_mode && !focused) &&
- (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
- (_item_multi_select_up(sd)))
- || (_item_single_select_up(sd))))
+ if (!sd->h_mode && !focused)
+ {
+ if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
+ _item_multi_select_up(sd);
+ else
+ _item_single_select_up(sd);
+ }
+ if (_item_focused_next(obj, ELM_FOCUS_UP))
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else
- y -= step_y;
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ return;
}
else if ((!strcmp(ev->key, "Down")) ||
((!strcmp(ev->key, "KP_Down")) && !ev->string))
it = (Elm_List_Item *)elm_list_selected_item_get(obj);
Eina_Bool focused = _elm_list_item_focus_set(it, ELM_FOCUS_DOWN, sd->h_mode);
- if ((!sd->h_mode && !focused) &&
- (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
- (_item_multi_select_down(sd)))
- || (_item_single_select_down(sd))))
+ if (!sd->h_mode && !focused)
+ {
+ if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
+ _item_multi_select_down(sd);
+ else
+ _item_single_select_down(sd);
+ }
+ if (_item_focused_next(obj, ELM_FOCUS_DOWN))
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else
- y += step_y;
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ return;
}
else if ((!strcmp(ev->key, "Home")) ||
((!strcmp(ev->key, "KP_Home")) && !ev->string))
}
static void
+_elm_list_item_focused(Elm_List_Item *it)
+{
+ ELM_LIST_DATA_GET(WIDGET(it), sd);
+ Evas_Coord x, y, w, h, sx, sy, sw, sh;
+ const char *focus_raise;
+
+ if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) ||
+ (it == (Elm_List_Item *)sd->focused_item))
+ return;
+ evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
+ evas_object_geometry_get(sd->hit_rect, &sx, &sy, &sw, &sh);
+ if ((x < sx) || (y < sy)|| ((x + w) > (sx + sw)) || ((y + h) > (sy + sh)))
+ elm_list_item_bring_in((Elm_Object_Item *)it);
+ sd->focused_item = (Elm_Object_Item *)it;
+ ((Elm_Widget_Item *)it)->focused = EINA_TRUE;
+ if (elm_widget_focus_highlight_enabled_get(WIDGET(it)))
+ {
+ edje_object_signal_emit
+ (VIEW(it), "elm,state,focused", "elm");
+ }
+ focus_raise = edje_object_data_get(VIEW(it), "focusraise");
+ if ((focus_raise) && (!strcmp(focus_raise, "on")))
+ evas_object_raise(VIEW(it));
+ evas_object_smart_callback_call
+ (WIDGET(it), SIG_ITEM_FOCUSED, it);
+}
+
+static void
+_elm_list_item_unfocused(Elm_List_Item *it)
+{
+ ELM_LIST_DATA_GET(WIDGET(it), sd);
+
+ if (!sd->focused_item) return;
+ sd->prev_focused_item = (Elm_Object_Item *)it;
+ if (sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
+ return;
+ if (elm_widget_focus_highlight_enabled_get(WIDGET(sd->focused_item)))
+ edje_object_signal_emit
+ (VIEW(sd->focused_item), "elm,state,unfocused", "elm");
+ if (it == (Elm_List_Item *)sd->focused_item)
+ sd->focused_item = NULL;
+ evas_object_smart_callback_call
+ (WIDGET(it), SIG_ITEM_UNFOCUSED, it);
+}
+
+static void
_elm_list_smart_on_focus(Eo *obj, void *_pd, va_list *list)
{
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
if (elm_widget_focus_get(obj) && sd->selected && !sd->last_selected_item)
sd->last_selected_item = eina_list_data_get(sd->selected);
+ if (elm_widget_focus_get(obj))
+ {
+ if (sd->last_focused_item)
+ _elm_list_item_focused((Elm_List_Item *)sd->last_focused_item);
+ else if (sd->last_selected_item)
+ _elm_list_item_focused((Elm_List_Item *)sd->last_selected_item);
+ else
+ _elm_list_item_focused((Elm_List_Item *)elm_list_first_item_get(obj));
+ _elm_widget_focus_highlight_start(obj);
+ }
+ else
+ {
+ sd->prev_focused_item = sd->focused_item;
+ sd->last_focused_item = sd->focused_item;
+ _elm_list_item_unfocused((Elm_List_Item *)sd->focused_item);
+ }
if (ret) *ret = EINA_TRUE;
}
if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
evas_object_smart_callback_call(obj, SIG_SELECTED, it);
- it->sd->last_selected_item = (Elm_Object_Item *)it;
+ sd->last_selected_item = (Elm_Object_Item *)it;
_elm_list_unwalk(obj, sd);
evas_object_unref(obj);
evas_object_ref(obj);
_elm_list_walk(sd);
- if (it->sd->focus_on_selection_enabled)
+ if (sd->focus_on_selection_enabled)
{
if (it->icon) elm_object_focus_set(it->icon, EINA_FALSE);
if (it->end) elm_object_focus_set(it->end, EINA_FALSE);
evas_object_ref(obj);
_elm_list_walk(sd);
+ elm_object_item_focus_set((Elm_Object_Item *)it, EINA_TRUE);
if (sd->multi &&
((sd->multi_select_mode != ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL) ||
(evas_key_modifier_is_set(ev->modifiers, "Control"))))
edje_object_signal_emit(VIEW(it), emission, source);
}
+static void
+_item_focus_set_hook(Elm_Object_Item *it, Eina_Bool focused)
+{
+ ELM_LIST_ITEM_CHECK_OR_RETURN(it);
+ Evas_Object *obj = WIDGET(it);
+ ELM_LIST_DATA_GET(obj, sd);
+
+ if (focused)
+ {
+ if (!elm_object_focus_get(obj))
+ elm_object_focus_set(obj, EINA_TRUE);
+ if (sd->focused_item)
+ _elm_list_item_unfocused((Elm_List_Item *)sd->focused_item);
+ if (it != sd->focused_item) _elm_list_item_focused((Elm_List_Item *)it);
+ }
+ else
+ _elm_list_item_unfocused((Elm_List_Item *)it);
+ _elm_widget_focus_highlight_start(obj);
+}
+
+static Eina_Bool
+_item_focus_get_hook(Elm_Object_Item *it)
+{
+ ELM_LIST_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
+ Evas_Object *obj = WIDGET(it);
+ ELM_LIST_CHECK(obj) EINA_FALSE;
+ ELM_LIST_DATA_GET(obj, sd);
+
+ if (it == sd->focused_item)
+ return EINA_TRUE;
+ return EINA_FALSE;
+}
+
static char *
_access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
{
{
Elm_List_Item *it;
- ELM_LIST_DATA_GET(obj, sd);
-
it = elm_widget_item_new(obj, Elm_List_Item);
- it->sd = sd;
it->label = eina_stringshare_add(label);
it->icon = icon;
it->end = end;
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
elm_widget_item_signal_emit_hook_set(it, _item_signal_emit_hook);
+ elm_widget_item_focus_set_hook_set(it, _item_focus_set_hook);
+ elm_widget_item_focus_get_hook_set(it, _item_focus_get_hook);
return it;
}
}
static void
+_elm_list_item_coordinates_adjust(Elm_List_Item *it,
+ Evas_Coord *x,
+ Evas_Coord *y,
+ Evas_Coord *w,
+ Evas_Coord *h)
+{
+ ELM_LIST_DATA_GET(WIDGET(it), sd);
+
+ Evas_Coord ix, iy, iw, ih, vx, vy, vw, vh;
+
+ evas_object_geometry_get(sd->hit_rect, &vx, &vy, &vw, &vh);
+ evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih);
+ *x = ix;
+ *y = iy;
+ *w = iw;
+ *h = ih;
+ if (!sd->h_mode)
+ {
+ //TODO: Enhance it later. declare a macro in elm_macros.h
+ if ((ix < vx) || (ix + iw) > (vx + vw) || (iy + ih) > (vy + vh))
+ *y = iy - ih;
+ else if (iy < vy)
+ *y = iy + ih;
+ }
+ else
+ {
+ //TODO: Enhance it later. declare a macro in elm_macros.h
+ if ((iy < vy) || (ix + iw) > (vx + vw) || (iy + ih) > (vy + vh))
+ *x = ix - iw;
+ else if (ix < vx)
+ *x = ix + iw;
+ }
+}
+
+static void
+_elm_list_focus_highlight_geometry_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+{
+ Evas_Coord *x = va_arg(*list, Evas_Coord *);
+ Evas_Coord *y = va_arg(*list, Evas_Coord *);
+ Evas_Coord *w = va_arg(*list, Evas_Coord *);
+ Evas_Coord *h = va_arg(*list, Evas_Coord *);
+ Eina_Bool *is_next = va_arg(*list, Eina_Bool *);
+
+ Elm_List_Smart_Data *sd = _pd;
+
+ if (is_next && *is_next)
+ {
+ if (sd->focused_item)
+ {
+ _elm_list_item_coordinates_adjust((Elm_List_Item *)sd->focused_item, x, y, w, h);
+ elm_widget_focus_highlight_focus_part_geometry_get(VIEW(sd->focused_item), x, y, w, h);
+ }
+ }
+ else
+ {
+ if (sd->prev_focused_item)
+ {
+ _elm_list_item_coordinates_adjust((Elm_List_Item *)sd->prev_focused_item, x, y, w, h);
+ elm_widget_focus_highlight_focus_part_geometry_get(VIEW(sd->prev_focused_item), x, y, w, h);
+ }
+ }
+}
+
+static void
+_elm_list_focused_item_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+{
+ Elm_Object_Item **ret = va_arg(*list, Elm_Object_Item **);
+ Elm_List_Smart_Data *sd = _pd;
+ if (ret) *ret = NULL;
+
+ if (!elm_object_focus_get(obj)) return;
+ if (ret) *ret = sd->focused_item;
+}
+
+static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_SUB_OBJECT_DEL), _elm_list_smart_sub_object_del),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_list_smart_focus_direction_manager_is),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_ACCESS), _elm_list_smart_access),
+ EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_HIGHLIGHT_GEOMETRY_GET), _elm_list_focus_highlight_geometry_get),
+ EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUSED_ITEM_GET), _elm_list_focused_item_get),
EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_EVAL), _elm_list_smart_sizing_eval),
return elm_widget_orientation_mode_disabled_get(obj);
}
+EAPI Elm_Object_Item *
+elm_object_focused_item_get(const Evas_Object *obj)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
+ return elm_widget_focused_item_get(obj);
+}
+
EAPI void
elm_object_item_access_info_set(Elm_Object_Item *it, const char *txt)
{
{
return elm_widget_item_track_get((Elm_Widget_Item *)it);
}
+
+EAPI void
+elm_object_item_focus_set(Elm_Object_Item *item, Eina_Bool focused)
+{
+ elm_widget_item_focus_set(item, focused);
+}
+
+EAPI Eina_Bool
+elm_object_item_focus_get(const Elm_Object_Item *item)
+{
+ return elm_widget_item_focus_get(item);
+}
eo_isa(obj, ELM_SCROLLABLE_INTERFACE);
}
+void
+_elm_widget_focus_highlight_start(const Evas_Object *obj)
+{
+ Evas_Object *top = elm_widget_top_get(obj);
+
+ if (top && eo_isa(top, ELM_OBJ_WIN_CLASS))
+ _elm_win_focus_highlight_start(top);
+}
+
+EAPI Eina_Bool
+elm_widget_focus_highlight_enabled_get(const Evas_Object *obj)
+{
+ const Evas_Object *win = elm_widget_top_get(obj);
+
+ if (win && eo_isa(win, ELM_OBJ_WIN_CLASS))
+ return elm_win_focus_highlight_enabled_get(win);
+ return EINA_FALSE;
+}
+
/**
* @internal
*
}
EAPI void
-elm_widget_focus_highlight_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
+elm_widget_focus_highlight_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h, Eina_Bool is_next)
{
ELM_WIDGET_CHECK(obj);
- eo_do(obj, elm_wdg_focus_highlight_geometry_get(x, y, w, h));
+ eo_do(obj, elm_wdg_focus_highlight_geometry_get(x, y, w, h, &is_next));
}
-static void
-_elm_widget_focus_highlight_geometry_get(Eo *obj, void *_pd, va_list *list)
+EAPI void
+elm_widget_focus_highlight_focus_part_geometry_get(const Evas_Object *obj,
+ Evas_Coord *x,
+ Evas_Coord *y,
+ Evas_Coord *w,
+ Evas_Coord *h)
{
- Evas_Coord *x = va_arg(*list, Evas_Coord *);
- Evas_Coord *y = va_arg(*list, Evas_Coord *);
- Evas_Coord *w = va_arg(*list, Evas_Coord *);
- Evas_Coord *h = va_arg(*list, Evas_Coord *);
-
Evas_Coord tx = 0, ty = 0, tw = 0, th = 0;
const char *target_hl_part = NULL;
- Evas_Object *edje_obj = NULL;
- Elm_Widget_Smart_Data *sd = _pd;
+ const Evas_Object *edje_obj = NULL;
- evas_object_geometry_get(obj, x, y, w, h);
- if (sd->resize_obj && eo_isa(sd->resize_obj, EDJE_OBJ_CLASS))
+ if (obj && eo_isa(obj, EDJE_OBJ_CLASS))
{
- edje_obj = sd->resize_obj;
+ edje_obj = obj;
if (!(target_hl_part = edje_object_data_get(edje_obj, "focus_part")))
return;
}
- else if (sd->resize_obj && eo_isa(sd->resize_obj, ELM_OBJ_LAYOUT_CLASS))
+ else if (obj && eo_isa(obj, ELM_OBJ_LAYOUT_CLASS))
{
- edje_obj = elm_layout_edje_get(sd->resize_obj);
- if (!(target_hl_part = elm_layout_data_get(sd->resize_obj, "focus_part")))
+ edje_obj = elm_layout_edje_get(obj);
+ if (!(target_hl_part = elm_layout_data_get(obj, "focus_part")))
return;
}
- else return;
+ else
+ return;
- edje_object_part_geometry_get(edje_obj, target_hl_part,
- &tx, &ty, &tw, &th);
- *x += tx;
- *y += ty;
- if (tw != *w) *w = tw;
- if (th != *h) *h = th;
+ edje_object_part_geometry_get(edje_obj, target_hl_part,
+ &tx, &ty, &tw, &th);
+ *x += tx;
+ *y += ty;
+ if (tw != *w) *w = tw;
+ if (th != *h) *h = th;
+}
+
+static void
+_elm_widget_focus_highlight_geometry_get(Eo *obj, void *_pd, va_list *list)
+{
+ Evas_Coord *x = va_arg(*list, Evas_Coord *);
+ Evas_Coord *y = va_arg(*list, Evas_Coord *);
+ Evas_Coord *w = va_arg(*list, Evas_Coord *);
+ Evas_Coord *h = va_arg(*list, Evas_Coord *);
+ Eina_Bool *is_next = va_arg(*list, Eina_Bool *);
+ (void)is_next;
+
+ Elm_Widget_Smart_Data *sd = _pd;
+
+ evas_object_geometry_get(obj, x, y, w, h);
+ elm_widget_focus_highlight_focus_part_geometry_get(sd->resize_obj, x, y, w, h);
+}
+
+EAPI Elm_Object_Item *
+elm_widget_focused_item_get(const Evas_Object *obj)
+{
+ ELM_WIDGET_CHECK(obj) NULL;
+ Elm_Object_Item *ret = NULL;
+ eo_do(obj, elm_wdg_focused_item_get(&ret));
+
+ return ret;
+}
+
+static void
+_elm_widget_focused_item_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
+{
+ Elm_Object_Item **ret = va_arg(*list, Elm_Object_Item **);
+
+ if (ret) *ret = NULL;
}
EAPI void
ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
item->style_get_func = func;
}
+
+/**
+ * @internal
+ *
+ * Set the function to set the focus on widget item.
+ *
+ * @param item a valid #Elm_Widget_Item to be notified
+ * @see elm_widget_item_focus_set_hook_set() convenience macro.
+ * @ingroup Widget
+ */
+EAPI void
+_elm_widget_item_focus_set_hook_set(Elm_Widget_Item *item, Elm_Widget_Focus_Set_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
+ item->focus_set_func = func;
+}
+
+/**
+ * @internal
+ *
+ * Set the function to set the focus on widget item.
+ *
+ * @param item a valid #Elm_Widget_Item to be notified
+ * @see elm_widget_item_focus_get_hook_set() convenience macro.
+ * @ingroup Widget
+ */
+EAPI void
+_elm_widget_item_focus_get_hook_set(Elm_Widget_Item *item,
+ Elm_Widget_Focus_Get_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
+ item->focus_get_func = func;
+}
+
/**
* @internal
*
}
EAPI void
+_elm_widget_item_focus_set(Elm_Widget_Item *item, Eina_Bool focused)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ item->focus_set_func(item, focused);
+}
+
+EAPI Eina_Bool
+_elm_widget_item_focus_get(const Elm_Widget_Item *item)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
+ return item->focus_get_func(item);
+}
+
+EAPI void
_elm_widget_item_domain_translatable_part_text_set(Elm_Widget_Item *item,
const char *part,
const char *domain,
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_CAN_FOCUS_CHILD_LIST_GET), _elm_widget_can_focus_child_list_get),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_NEWEST_FOCUS_ORDER_GET), _elm_widget_newest_focus_order_get),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_HIGHLIGHT_GEOMETRY_GET), _elm_widget_focus_highlight_geometry_get),
+ EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUSED_ITEM_GET), _elm_widget_focused_item_get),
EO_OP_FUNC_SENTINEL
};
EO_OP_DESCRIPTION(ELM_WIDGET_SUB_ID_CAN_FOCUS_CHILD_LIST_GET, "Get the list of focusable child objects."),
EO_OP_DESCRIPTION(ELM_WIDGET_SUB_ID_NEWEST_FOCUS_ORDER_GET, "Get the newest focused object and its order."),
EO_OP_DESCRIPTION(ELM_WIDGET_SUB_ID_FOCUS_HIGHLIGHT_GEOMETRY_GET, "Get the focus highlight geometry of widget."),
+ EO_OP_DESCRIPTION(ELM_WIDGET_SUB_ID_FOCUSED_ITEM_GET, "Get the focused widget item."),
EO_OP_DESCRIPTION_SENTINEL
};
typedef void (*Elm_Widget_Item_Signal_Cb)(void *data, Elm_Widget_Item *item, const char *emission, const char *source);
typedef void (*Elm_Widget_Style_Set_Cb)(void *data, const char *style);
typedef const char *(*Elm_Widget_Style_Get_Cb)(const void *data);
+typedef void (*Elm_Widget_Focus_Set_Cb)(void *data, Eina_Bool focused);
+typedef Eina_Bool (*Elm_Widget_Focus_Get_Cb)(const void *data);
#define ELM_ACCESS_DONE -1 /* sentence done - send done event here */
#define ELM_ACCESS_CANCEL -2 /* stop reading immediately */
void _elm_access_widget_item_access_order_set(Elm_Widget_Item *item, Eina_List *objs);
const Eina_List *_elm_access_widget_item_access_order_get(const Elm_Widget_Item *item);
void _elm_access_widget_item_access_order_unset(Elm_Widget_Item *item);
+void _elm_widget_focus_highlight_start(const Evas_Object *obj);
+void _elm_win_focus_highlight_start(Evas_Object *obj);
EAPI void _elm_access_clear(Elm_Access_Info *ac);
EAPI void _elm_access_text_set(Elm_Access_Info *ac, int type, const char *text);
Elm_Widget_Disable_Cb disable_func;
Elm_Widget_Style_Set_Cb style_set_func;
Elm_Widget_Style_Get_Cb style_get_func;
+ Elm_Widget_Focus_Set_Cb focus_set_func;
+ Elm_Widget_Focus_Get_Cb focus_get_func;
Evas_Object *access_obj;
const char *access_info;
Eina_List *access_order;
Eina_Bool disabled : 1;
Eina_Bool on_deletion : 1;
Eina_Bool on_translate : 1;
+ Eina_Bool focused : 1;
};
struct _Elm_Object_Item
EAPI void elm_widget_focus_steal(Evas_Object *obj);
EAPI Evas_Object *elm_widget_newest_focus_order_get(const Evas_Object *obj, unsigned int *newest_focus_order, Eina_Bool can_focus_only);
EAPI void elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode);
+EAPI Eina_Bool elm_widget_focus_highlight_enabled_get(const Evas_Object *obj);
+EAPI void elm_widget_focus_highlight_focus_part_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
EAPI const Elm_Widget_Smart_Class *elm_widget_smart_class_get(void);
/**
EAPI void elm_widget_access_info_set(Evas_Object *obj, const char *txt);
EAPI const char *elm_widget_access_info_get(const Evas_Object *obj);
EAPI void elm_widget_orientation_set(Evas_Object *obj, int rotation);
+EAPI Elm_Object_Item *elm_widget_focused_item_get(const Evas_Object *obj);
EAPI void elm_widget_orientation_mode_disabled_set(Evas_Object *obj, Eina_Bool disabled);
EAPI Eina_Bool elm_widget_orientation_mode_disabled_get(const Evas_Object *obj);
-EAPI void elm_widget_focus_highlight_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
+EAPI void elm_widget_focus_highlight_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h, Eina_Bool is_next);
EAPI Elm_Widget_Item *_elm_widget_item_new(Evas_Object *parent, size_t alloc_size);
EAPI void _elm_widget_item_free(Elm_Widget_Item *item);
EAPI Evas_Object *_elm_widget_item_widget_get(const Elm_Widget_Item *item);
EAPI void _elm_widget_item_part_text_custom_set(Elm_Widget_Item *item, const char *part, const char *label);
EAPI const char *_elm_widget_item_part_text_custom_get(Elm_Widget_Item *item, const char *part);
EAPI void _elm_widget_item_part_text_custom_update(Elm_Widget_Item *item);
-
+EAPI void _elm_widget_item_focus_set(Elm_Widget_Item *item, Eina_Bool focused);
+EAPI Eina_Bool _elm_widget_item_focus_get(const Elm_Widget_Item *item);
EAPI void _elm_widget_item_style_set(Elm_Widget_Item *item, const char *style);
EAPI const char *_elm_widget_item_style_get(Elm_Widget_Item *item);
EAPI void _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Del_Pre_Cb func);
EAPI void _elm_widget_item_style_set_hook_set(Elm_Widget_Item *item, Elm_Widget_Style_Set_Cb func);
EAPI void _elm_widget_item_style_get_hook_set(Elm_Widget_Item *item, Elm_Widget_Style_Get_Cb func);
+EAPI void _elm_widget_item_focus_get_hook_set(Elm_Widget_Item *item, Elm_Widget_Focus_Get_Cb func);
+EAPI void _elm_widget_item_focus_set_hook_set(Elm_Widget_Item *item, Elm_Widget_Focus_Set_Cb func);
EAPI void _elm_widget_item_domain_translatable_part_text_set(Elm_Widget_Item *item, const char *part, const char *domain, const char *label);
EAPI const char * _elm_widget_item_translatable_part_text_get(const Elm_Widget_Item *item, const char *part);
EAPI void _elm_widget_item_translate(Elm_Widget_Item *item);
*/
#define elm_widget_item_style_get(item) \
_elm_widget_item_style_get((Elm_Widget_Item *)item)
+
+/**
+ * Convenience function to query focus set hook.
+ * @see _elm_widget_item_focus_set_hook_set()
+ */
+#define elm_widget_item_focus_set_hook_set(item, func) \
+ _elm_widget_item_focus_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Focus_Set_Cb)func)
+
+/**
+ * Convenience function to query focus get hook.
+ * @see _elm_widget_item_focus_get_hook_set()
+ */
+#define elm_widget_item_focus_get_hook_set(item, func) \
+ _elm_widget_item_focus_get_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Focus_Get_Cb)func)
+
/**
* Convenience function to query track_cancel.
* @see _elm_widget_item_del_pre_hook_set()
#define elm_widget_item_part_text_custom_update(item) \
_elm_widget_item_part_text_custom_update((Elm_Widget_Item *)item)
+/**
+ * Convenience function to set the focus on widget item.
+ * @see _elm_widget_item_focus_set()
+ */
+#define elm_widget_item_focus_set(item, focused) \
+ _elm_widget_item_focus_set((Elm_Widget_Item *)item, focused)
+
+/**
+ * Convenience function to query focus set hook.
+ * @see _elm_widget_item_focus_get()
+ */
+#define elm_widget_item_focus_get(item) \
+ _elm_widget_item_focus_get((const Elm_Widget_Item *)item)
+
#define ELM_WIDGET_CHECK_OR_RETURN(obj, ...) \
do { \
if (!obj || !evas_object_smart_data_get(obj)) \
ELM_WIDGET_SUB_ID_CAN_FOCUS_CHILD_LIST_GET,
ELM_WIDGET_SUB_ID_NEWEST_FOCUS_ORDER_GET,
ELM_WIDGET_SUB_ID_FOCUS_HIGHLIGHT_GEOMETRY_GET,
+ ELM_WIDGET_SUB_ID_FOCUSED_ITEM_GET,
#if 0
ELM_WIDGET_SUB_ID_THEME_APPLY, /* API + virtual*/
ELM_WIDGET_SUB_ID_THEME_SPECIFIC,
* @param[in] x
* @param[in] y
* @param[in] w
- * @param[in] z
+ * @param[in] h
+ * @param[in] is_next
*
*/
-#define elm_wdg_focus_highlight_geometry_get(x, y, w, h) ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_HIGHLIGHT_GEOMETRY_GET), EO_TYPECHECK(Evas_Coord *, x), EO_TYPECHECK(Evas_Coord *, y), EO_TYPECHECK(Evas_Coord *, w), EO_TYPECHECK(Evas_Coord *, h)
-
+#define elm_wdg_focus_highlight_geometry_get(x, y, w, h, is_next) ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_HIGHLIGHT_GEOMETRY_GET), EO_TYPECHECK(Evas_Coord *, x), EO_TYPECHECK(Evas_Coord *, y), EO_TYPECHECK(Evas_Coord *, w), EO_TYPECHECK(Evas_Coord *, h), EO_TYPECHECK(Eina_Bool *, is_next)
+/**
+ * @def elm_wdg_focused_item_get
+ * @since 1.10
+ *
+ * Get the focused widget item.
+ *
+ * @param[out] ret
+ *
+ */
+#define elm_wdg_focused_item_get(ret) ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUSED_ITEM_GET), EO_TYPECHECK(Elm_Object_Item **, ret)
#endif
Eina_List *items, *selected, *to_delete;
Elm_Object_Item *last_selected_item;
+ Elm_Object_Item *focused_item; /**< a focused item by keypad arrow or mouse. This is set to NULL if widget looses focus. */
+ Elm_Object_Item *prev_focused_item; /**< a previous focused item by keypad arrow or mouse. */
+ Elm_Object_Item *last_focused_item; /**< This records the last focused item when widget looses focus. This is required to set the focus on last focused item when widgets gets focus. */
Evas_Coord minw[2], minh[2];
Elm_Object_Select_Mode select_mode;
Elm_Object_Multi_Select_Mode multi_select_mode; /**< select mode for multiple selection */
{
ELM_WIDGET_ITEM;
- Elm_List_Smart_Data *sd;
-
Ecore_Timer *swipe_timer;
Ecore_Timer *long_timer;
Evas_Object *icon, *end;
Evas_Object *target = sd->focus_highlight.cur.target;
evas_object_geometry_get(sd->obj, NULL, NULL, &w, &h);
- elm_widget_focus_highlight_geometry_get(target, &tx, &ty, &tw, &th);
- elm_widget_focus_highlight_geometry_get(previous, &px, &py, &pw, &ph);
+ elm_widget_focus_highlight_geometry_get(target, &tx, &ty, &tw, &th, EINA_TRUE);
+ elm_widget_focus_highlight_geometry_get(previous, &px, &py, &pw, &ph, EINA_FALSE);
evas_object_move(obj, tx, ty);
evas_object_resize(obj, tw, th);
evas_object_clip_unset(obj);
Evas_Coord x, y, w, h;
clip = evas_object_clip_get(target);
- elm_widget_focus_highlight_geometry_get(target, &x, &y, &w, &h);
+ elm_widget_focus_highlight_geometry_get(target, &x, &y, &w, &h, EINA_TRUE);
evas_object_move(obj, x, y);
evas_object_resize(obj, w, h);
*ret = 0;
}
+void
+_elm_win_focus_highlight_start(Evas_Object *obj)
+{
+ ELM_WIN_DATA_GET(obj, sd);
+
+ if (!elm_win_focus_highlight_enabled_get(obj)) return;
+ sd->focus_highlight.cur.visible = EINA_TRUE;
+ sd->focus_highlight.cur.in_theme = EINA_FALSE;
+ sd->focus_highlight.geometry_changed = EINA_TRUE;
+ _elm_win_focus_highlight_reconfigure(sd);
+}
+
EAPI Ecore_Window
elm_win_window_id_get(const Evas_Object *obj)
{
EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE_SET), _wm_manual_rotation_done_set),
EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE_GET), _wm_manual_rotation_done_get),
EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE), _wm_manual_rotation_done),
-
EO_OP_FUNC_SENTINEL
};
* @see elm_win_wm_rotation_manual_rotation_done
*/
#define elm_obj_win_wm_manual_rotation_done() ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE)
+
+/**
+ * @}
+ */