Summary: First item of widget should be focused when focus comes to the widget for first time.
Test Plan:
elementary_test -to "Genlist Focus"
elementary_test -to "Gengrid Focus"
elementary_test -to "List Focus"
elementary_test -to "toolbar Focus"
Reviewers: seoz
Differential Revision: https://phab.enlightenment.org/D1135
value "focus_highlight_animate" uchar: 0;
value "focus_highlight_clip_disable" uchar: 0;
value "item_select_on_focus_disable" uchar: 0;
+ value "first_item_focus_on_first_focusin" uchar: 1;
value "focus_move_policy" uchar: 0;
value "toolbar_shrink_mode" int: 3;
value "fileselector_expand_enable" uchar: 0;
value "focus_highlight_animate" uchar: 0;
value "focus_highlight_clip_disable" uchar: 0;
value "item_select_on_focus_disable" uchar: 0;
+ value "first_item_focus_on_first_focusin" uchar: 1;
value "focus_move_policy" uchar: 0;
value "toolbar_shrink_mode" int: 3;
value "fileselector_expand_enable" uchar: 0;
value "focus_highlight_animate" uchar: 0;
value "focus_highlight_clip_disable" uchar: 1;
value "item_select_on_focus_disable" uchar: 0;
+ value "first_item_focus_on_first_focusin" uchar: 1;
value "focus_move_policy" uchar: 0;
value "toolbar_shrink_mode" int: 3;
value "fileselector_expand_enable" uchar: 1;
elm_config_item_select_on_focus_disabled_set(elm_check_state_get(obj));
}
+static void
+_gg_first_item_focus_on_first_focus_in_cb(void *data EINA_UNUSED, Evas_Object *obj,
+ void *event_info EINA_UNUSED)
+{
+ elm_config_first_item_focus_on_first_focusin_set(elm_check_state_get(obj));
+}
+
void
test_gengrid_focus(void *data EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
elm_box_pack_end(bx_opt, ck);
evas_object_show(ck);
+ ck = elm_check_add(bx_opt);
+ elm_object_text_set(ck, "First item focus on first focus in");
+ elm_check_state_set(ck, elm_config_first_item_focus_on_first_focusin_get());
+ evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
+ evas_object_smart_callback_add(ck, "changed",
+ _gg_first_item_focus_on_first_focus_in_cb,
+ NULL);
+ elm_box_pack_end(bx_opt, ck);
+ evas_object_show(ck);
+
// Focus Autoscroll Mode
fr = _focus_autoscroll_mode_frame_create(bx);
elm_box_pack_end(bx, fr);
elm_config_item_select_on_focus_disabled_set(elm_check_state_get(obj));
}
+static void
+_gl_first_item_focus_on_first_focus_in_cb(void *data EINA_UNUSED, Evas_Object *obj,
+ void *event_info EINA_UNUSED)
+{
+ elm_config_first_item_focus_on_first_focusin_set(elm_check_state_get(obj));
+}
static Eina_Bool
_focus_timer_cb(void *data)
{
elm_box_pack_end(bx_opt, chk);
evas_object_show(chk);
+ chk = elm_check_add(bx_opt);
+ elm_object_text_set(chk, "First item focus on first focus in");
+ elm_check_state_set(chk, elm_config_first_item_focus_on_first_focusin_get());
+ evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0);
+ evas_object_smart_callback_add(chk, "changed",
+ _gl_first_item_focus_on_first_focus_in_cb,
+ NULL);
+ elm_box_pack_end(bx_opt, chk);
+ evas_object_show(chk);
+
+
// Focus Autoscroll Mode
fr = _focus_autoscroll_mode_frame_create(bx);
elm_box_pack_end(bx, fr);
}
static void
+test_list_first_item_focus_on_first_focus_in_cb(void *data EINA_UNUSED, Evas_Object *obj,
+ void *event_info EINA_UNUSED)
+{
+ elm_config_first_item_focus_on_first_focusin_set(elm_check_state_get(obj));
+}
+
+static void
_item_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
printf("%s: %p\n", (char *)data, event_info);
elm_box_pack_end(bx_opt, chk);
evas_object_show(chk);
+ chk = elm_check_add(bx_opt);
+ elm_object_text_set(chk, "First item focus on first focus in");
+ elm_check_state_set(chk, elm_config_first_item_focus_on_first_focusin_get());
+ evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0);
+ evas_object_smart_callback_add(chk, "changed",
+ test_list_first_item_focus_on_first_focus_in_cb,
+ NULL);
+ elm_box_pack_end(bx_opt, chk);
+ evas_object_show(chk);
+
// Focus Autoscroll Mode
fr = _focus_autoscroll_mode_frame_create(bx);
elm_box_pack_end(bx, fr);
}
static void
+_test_toolbar_first_item_focus_on_first_focus_in_cb(void *data EINA_UNUSED, Evas_Object *obj,
+ void *event_info EINA_UNUSED)
+{
+ elm_config_first_item_focus_on_first_focusin_set(elm_check_state_get(obj));
+}
+
+static void
_toolbar_focus_key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED, void *event_info)
{
_test_toolbar_focus_focus_animate_check_changed,
win);
+ chk = elm_check_add(bx_opt);
+ elm_object_text_set(chk, "First item focus on first focus in");
+ elm_check_state_set(chk, elm_config_first_item_focus_on_first_focusin_get());
+ evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0);
+ elm_box_pack_end(bx_opt, chk);
+ evas_object_show(chk);
+ evas_object_smart_callback_add(chk, "changed",
+ _test_toolbar_first_item_focus_on_first_focus_in_cb,
+ win);
+
// Focus Autoscroll Mode
fr = _focus_autoscroll_mode_frame_create(bx);
elm_box_pack_end(bx, fr);
ELM_CONFIG_VAL(D, T, focus_move_policy, T_UCHAR);
ELM_CONFIG_VAL(D, T, focus_autoscroll_mode, T_UCHAR);
ELM_CONFIG_VAL(D, T, item_select_on_focus_disable, T_UCHAR);
+ ELM_CONFIG_VAL(D, T, first_item_focus_on_first_focus_in, T_UCHAR);
ELM_CONFIG_VAL(D, T, toolbar_shrink_mode, T_INT);
ELM_CONFIG_VAL(D, T, fileselector_expand_enable, T_UCHAR);
ELM_CONFIG_VAL(D, T, fileselector_double_tap_navigation_enable, T_UCHAR);
_elm_config->focus_highlight_animate = EINA_TRUE;
_elm_config->focus_highlight_clip_disable = EINA_FALSE;
_elm_config->focus_move_policy = ELM_FOCUS_MOVE_POLICY_CLICK;
+ _elm_config->first_item_focus_on_first_focus_in = EINA_FALSE;
_elm_config->item_select_on_focus_disable = EINA_TRUE;
_elm_config->toolbar_shrink_mode = 2;
_elm_config->fileselector_expand_enable = EINA_FALSE;
s = getenv("ELM_ITEM_SELECT_ON_FOCUS_DISABLE");
if (s) _elm_config->item_select_on_focus_disable = !!atoi(s);
+ s = getenv("ELM_FIRST_ITEM_FOCUS_ON_FIRST_FOCUS_IN");
+ if (s) _elm_config->first_item_focus_on_first_focus_in = !!atoi(s);
+
s = getenv("ELM_TOOLBAR_SHRINK_MODE");
if (s) _elm_config->toolbar_shrink_mode = atoi(s);
}
EAPI Eina_Bool
+elm_config_first_item_focus_on_first_focusin_get(void)
+{
+ return _elm_config->first_item_focus_on_first_focus_in;
+}
+
+EAPI void
+elm_config_first_item_focus_on_first_focusin_set(Eina_Bool enable)
+{
+ _elm_config->first_item_focus_on_first_focus_in = !!enable;
+}
+
+EAPI Eina_Bool
elm_config_scroll_bounce_enabled_get(void)
{
return _elm_config->thumbscroll_bounce_enable;
EAPI void elm_config_item_select_on_focus_disabled_set(Eina_Bool enabled);
/**
+ * Get status of first item focus on first focusin feature.
+ *
+ * @return The first item focus on first focusin status
+ *
+ * @see elm_config_first_item_focus_on_first_focusin_set
+ * @since 1.11
+ * @ingroup Focus
+ */
+EAPI Eina_Bool elm_config_first_item_focus_on_first_focusin_get(void);
+
+/**
+ * Set the first item focus on first focusin feature.
+ *
+ * @param enable first_item_focus_on_first_focusin if @c EINA_TRUE, enable otherwise
+ *
+ * @see elm_config_first_item_focus_on_first_focusin_get
+ * @since 1.11
+ * @ingroup Focus
+ */
+EAPI void elm_config_first_item_focus_on_first_focusin_set(Eina_Bool enabled);
+
+/**
* Get the system mirrored mode. This determines the default mirrored mode
* of widgets.
*
it = sd->last_focused_item;
else if (sd->last_selected_item)
it = sd->last_selected_item;
- /* TODO: make it optional on 1.11. Disable this until then
- else if (elm_widget_focus_highlight_enabled_get(obj))
+ else if (_elm_config->first_item_focus_on_first_focus_in &&
+ elm_widget_focus_highlight_enabled_get(obj))
{
it = elm_gengrid_first_item_get(obj);
is_sel = EINA_TRUE;
}
- */
if (it)
{
it = sd->last_focused_item;
else if (sd->last_selected_item)
it = sd->last_selected_item;
- /* TODO: make it optional on 1.11. Disable this until then
- else if (elm_widget_focus_highlight_enabled_get(obj))
+ else if (_elm_config->first_item_focus_on_first_focus_in &&
+ elm_widget_focus_highlight_enabled_get(obj))
{
it = elm_genlist_first_item_get(obj);
is_sel = EINA_TRUE;
}
- */
if (it)
{
it = sd->last_focused_item;
else if (sd->last_selected_item)
it = sd->last_selected_item;
- /* TODO: make it optional on 1.11
- else if (elm_widget_focus_highlight_enabled_get(obj))
+ else if (_elm_config->first_item_focus_on_first_focus_in &&
+ elm_widget_focus_highlight_enabled_get(obj))
{
- it = eina_list_data_get(sd->items);
+ it = elm_list_first_item_get(obj);
is_sel = EINA_TRUE;
}
- */
if (it)
{
unsigned char focus_highlight_clip_disable; /**< This shows disabled status of focus highlight clip feature. This value is false by default so the focus highlight is clipped. */
unsigned char focus_move_policy; /**< This show how the elementary focus is moved to another object. Focus can be moved by click or mouse_in. */
unsigned char item_select_on_focus_disable; /**< This shows the disabled status of select on focus feature. This value is false by default so that select on focus feature is enabled by default.*/
+ unsigned char first_item_focus_on_first_focus_in; /**< This sets the first item focus on first focus in feature*/
Elm_Focus_Autoscroll_Mode focus_autoscroll_mode; /**< This shows the focus auto scroll mode. By default, @c ELM_FOCUS_AUTOSCROLL_MODE_SHOW is set. */
int toolbar_shrink_mode;
unsigned char fileselector_expand_enable;
{
if (sd->last_focused_item)
it = sd->last_focused_item;
- /* TODO: make it optional on 1.11. Disable this until then
- else
- it = (Elm_Object_Item *)ELM_TOOLBAR_ITEM_FROM_INLIST(sd->items);
- */
+ else if (_elm_config->first_item_focus_on_first_focus_in &&
+ elm_widget_focus_highlight_enabled_get(obj))
+ it = elm_toolbar_first_item_get(obj);
+
if (it)
{
it = _elm_toolbar_nearest_visible_item_get(obj, it);