genlist: Fixed broken genlist item focus support.
Now it works so much better than before. - Fixed the separate behavior between selected item and focused item. - Fixed wrong focus set when genlist is focused first time by mouse. - Fixed wrong scroll movement when the focus highlight is disabled. - Item selection sets that item focused. So when an item is selected, do not need to set the focus again. - Fixed wrong call for _elm_genlist_item_content_focus_set on deleted item.
This commit is contained in:
parent
ba36abd6d8
commit
8129ae20ec
|
@ -2490,6 +2490,8 @@ _elm_genlist_item_unfocused(Elm_Gen_Item *it)
|
||||||
(WIDGET(it), SIG_ITEM_UNFOCUSED, it);
|
(WIDGET(it), SIG_ITEM_UNFOCUSED, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NOTE: this code will be used later when the item selection on key press
|
||||||
|
becomes optional. So do not remove this.
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_item_focused_next(Evas_Object *obj, Elm_Focus_Direction dir)
|
_item_focused_next(Evas_Object *obj, Elm_Focus_Direction dir)
|
||||||
{
|
{
|
||||||
|
@ -2542,6 +2544,7 @@ _item_focused_next(Evas_Object *obj, Elm_Focus_Direction dir)
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_elm_genlist_item_content_focus_set(Elm_Gen_Item *it, Elm_Focus_Direction dir)
|
_elm_genlist_item_content_focus_set(Elm_Gen_Item *it, Elm_Focus_Direction dir)
|
||||||
|
@ -2609,6 +2612,7 @@ _elm_genlist_smart_event(Eo *obj, void *_pd, va_list *list)
|
||||||
Evas_Coord page_y = 0;
|
Evas_Coord page_y = 0;
|
||||||
Elm_Object_Item *it = NULL;
|
Elm_Object_Item *it = NULL;
|
||||||
Evas_Coord pan_max_x = 0, pan_max_y = 0;
|
Evas_Coord pan_max_x = 0, pan_max_y = 0;
|
||||||
|
Eina_Bool sel_ret = EINA_FALSE;
|
||||||
|
|
||||||
if (elm_widget_disabled_get(obj)) return;
|
if (elm_widget_disabled_get(obj)) return;
|
||||||
if (type != EVAS_CALLBACK_KEY_DOWN) return;
|
if (type != EVAS_CALLBACK_KEY_DOWN) return;
|
||||||
|
@ -2648,51 +2652,37 @@ _elm_genlist_smart_event(Eo *obj, void *_pd, va_list *list)
|
||||||
else if ((!strcmp(ev->key, "Up")) ||
|
else if ((!strcmp(ev->key, "Up")) ||
|
||||||
((!strcmp(ev->key, "KP_Up")) && (!ev->string)))
|
((!strcmp(ev->key, "KP_Up")) && (!ev->string)))
|
||||||
{
|
{
|
||||||
if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
|
if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
||||||
(_item_multi_select_up(sd)))
|
sel_ret = _item_multi_select_up(sd);
|
||||||
|| (_item_single_select_up(sd)))
|
if (!sel_ret)
|
||||||
|
sel_ret = _item_single_select_up(sd);
|
||||||
|
|
||||||
|
if (sel_ret)
|
||||||
{
|
{
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
if (ret) *ret = EINA_TRUE;
|
if (ret) *ret = EINA_TRUE;
|
||||||
}
|
return;
|
||||||
else
|
|
||||||
y -= step_y;
|
|
||||||
|
|
||||||
if (_item_focused_next(obj, ELM_FOCUS_UP))
|
|
||||||
{
|
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
||||||
if (ret) *ret = EINA_TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ret) *ret = EINA_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret) *ret = EINA_FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ((!strcmp(ev->key, "Down")) ||
|
else if ((!strcmp(ev->key, "Down")) ||
|
||||||
((!strcmp(ev->key, "KP_Down")) && (!ev->string)))
|
((!strcmp(ev->key, "KP_Down")) && (!ev->string)))
|
||||||
{
|
{
|
||||||
if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
|
if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
||||||
(_item_multi_select_down(sd)))
|
sel_ret = _item_multi_select_down(sd);
|
||||||
|| (_item_single_select_down(sd)))
|
if (!sel_ret)
|
||||||
|
sel_ret = _item_single_select_down(sd);
|
||||||
|
|
||||||
|
if (sel_ret)
|
||||||
{
|
{
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
if (ret) *ret = EINA_TRUE;
|
if (ret) *ret = EINA_TRUE;
|
||||||
}
|
return;
|
||||||
else
|
|
||||||
y += step_y;
|
|
||||||
|
|
||||||
if (_item_focused_next(obj, ELM_FOCUS_DOWN))
|
|
||||||
{
|
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
||||||
if (ret) *ret = EINA_TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ret) *ret = EINA_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret) *ret = EINA_FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ((!strcmp(ev->key, "Home")) ||
|
else if ((!strcmp(ev->key, "Home")) ||
|
||||||
|
@ -2702,7 +2692,6 @@ _elm_genlist_smart_event(Eo *obj, void *_pd, va_list *list)
|
||||||
if (it)
|
if (it)
|
||||||
{
|
{
|
||||||
elm_genlist_item_selected_set(it, EINA_TRUE);
|
elm_genlist_item_selected_set(it, EINA_TRUE);
|
||||||
elm_object_item_focus_set(it, EINA_TRUE);
|
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
if (ret) *ret = EINA_TRUE;
|
if (ret) *ret = EINA_TRUE;
|
||||||
return;
|
return;
|
||||||
|
@ -2715,7 +2704,6 @@ _elm_genlist_smart_event(Eo *obj, void *_pd, va_list *list)
|
||||||
if (it)
|
if (it)
|
||||||
{
|
{
|
||||||
elm_genlist_item_selected_set(it, EINA_TRUE);
|
elm_genlist_item_selected_set(it, EINA_TRUE);
|
||||||
elm_object_item_focus_set(it, EINA_TRUE);
|
|
||||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
if (ret) *ret = EINA_TRUE;
|
if (ret) *ret = EINA_TRUE;
|
||||||
return;
|
return;
|
||||||
|
@ -2875,6 +2863,7 @@ _elm_genlist_smart_on_focus(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
|
||||||
Eina_Bool int_ret = EINA_FALSE;
|
Eina_Bool int_ret = EINA_FALSE;
|
||||||
Elm_Genlist_Smart_Data *sd = _pd;
|
Elm_Genlist_Smart_Data *sd = _pd;
|
||||||
Elm_Object_Item *it = NULL;
|
Elm_Object_Item *it = NULL;
|
||||||
|
Eina_Bool is_sel = EINA_FALSE;
|
||||||
|
|
||||||
eo_do_super(obj, MY_CLASS, elm_obj_widget_on_focus(&int_ret));
|
eo_do_super(obj, MY_CLASS, elm_obj_widget_on_focus(&int_ret));
|
||||||
if (!int_ret) return;
|
if (!int_ret) return;
|
||||||
|
@ -2889,14 +2878,22 @@ _elm_genlist_smart_on_focus(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
|
||||||
it = sd->last_focused_item;
|
it = sd->last_focused_item;
|
||||||
else if (sd->last_selected_item)
|
else if (sd->last_selected_item)
|
||||||
it = sd->last_selected_item;
|
it = sd->last_selected_item;
|
||||||
else
|
else if (!sd->mouse_down)
|
||||||
it = elm_genlist_first_item_get(obj);
|
{
|
||||||
|
it = elm_genlist_first_item_get(obj);
|
||||||
|
is_sel = EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (it)
|
if (it)
|
||||||
{
|
{
|
||||||
it = _elm_genlist_nearest_visible_item_get(obj, it);
|
it = _elm_genlist_nearest_visible_item_get(obj, it);
|
||||||
if (it)
|
if (it)
|
||||||
elm_object_item_focus_set(it, EINA_TRUE);
|
{
|
||||||
|
if (is_sel)
|
||||||
|
elm_genlist_item_selected_set(it, EINA_TRUE);
|
||||||
|
else
|
||||||
|
elm_object_item_focus_set(it, EINA_TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -5424,9 +5421,11 @@ _item_select(Elm_Gen_Item *it)
|
||||||
sd->walking++;
|
sd->walking++;
|
||||||
if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
|
if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
|
||||||
if (it->generation == sd->generation)
|
if (it->generation == sd->generation)
|
||||||
evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
|
{
|
||||||
|
evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
|
||||||
_elm_genlist_item_content_focus_set(it, ELM_FOCUS_PREVIOUS);
|
elm_object_item_focus_set((Elm_Object_Item *)it, EINA_TRUE);
|
||||||
|
_elm_genlist_item_content_focus_set(it, ELM_FOCUS_PREVIOUS);
|
||||||
|
}
|
||||||
|
|
||||||
it->walking--;
|
it->walking--;
|
||||||
sd->walking--;
|
sd->walking--;
|
||||||
|
|
Loading…
Reference in New Issue