forked from enlightenment/efl
list, genlist and gengrid, if no item is selected
Author: Helen Fornazier <helen.fornazier@profusion.mobi> If no item is selected, pressing up it will select the first and down will select the last item SVN revision: 53924
This commit is contained in:
parent
bc44338213
commit
ba89544efc
|
@ -245,6 +245,7 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty
|
|||
Evas_Event_Key_Down *ev = event_info;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return EINA_FALSE;
|
||||
if (!wd->items) return EINA_FALSE;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
|
||||
if (elm_widget_disabled_get(obj)) return EINA_FALSE;
|
||||
|
||||
|
@ -439,19 +440,30 @@ _item_single_select_up(Widget_Data *wd)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
|
||||
if (!prev) return EINA_FALSE;
|
||||
Elm_Gengrid_Item *prev;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
if (!wd->selected)
|
||||
{
|
||||
prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
|
||||
while ((prev) && (prev->delete_me))
|
||||
prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
|
||||
elm_gengrid_item_selected_set(prev, EINA_TRUE);
|
||||
elm_gengrid_item_show(prev);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
|
||||
|
||||
if (!prev) return EINA_FALSE;
|
||||
|
||||
for (i = 1; i < wd->nmax; i++)
|
||||
{
|
||||
Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
|
||||
if (!tmp) break;
|
||||
if (!tmp) return EINA_FALSE;
|
||||
prev = tmp;
|
||||
}
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
||||
elm_gengrid_item_selected_set(prev, EINA_TRUE);
|
||||
elm_gengrid_item_show(prev);
|
||||
return EINA_TRUE;
|
||||
|
@ -462,19 +474,30 @@ _item_single_select_down(Widget_Data *wd)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
|
||||
if (!next) return EINA_FALSE;
|
||||
Elm_Gengrid_Item *next;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
if (!wd->selected)
|
||||
{
|
||||
next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
|
||||
while ((next) && (next->delete_me))
|
||||
next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
|
||||
elm_gengrid_item_selected_set(next, EINA_TRUE);
|
||||
elm_gengrid_item_show(next);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
else next = elm_gengrid_item_next_get(wd->last_selected_item);
|
||||
|
||||
if (!next) return EINA_FALSE;
|
||||
|
||||
for (i = 1; i < wd->nmax; i++)
|
||||
{
|
||||
Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
|
||||
if (!tmp) break;
|
||||
if (!tmp) return EINA_FALSE;
|
||||
next = tmp;
|
||||
}
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
||||
elm_gengrid_item_selected_set(next, EINA_TRUE);
|
||||
elm_gengrid_item_show(next);
|
||||
return EINA_TRUE;
|
||||
|
@ -483,8 +506,15 @@ _item_single_select_down(Widget_Data *wd)
|
|||
static Eina_Bool
|
||||
_item_single_select_left(Widget_Data *wd)
|
||||
{
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
|
||||
Elm_Gengrid_Item *prev;
|
||||
if (!wd->selected)
|
||||
{
|
||||
prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
|
||||
while ((prev) && (prev->delete_me))
|
||||
prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
|
||||
}
|
||||
else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
|
||||
|
||||
if (!prev) return EINA_FALSE;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
@ -497,8 +527,15 @@ _item_single_select_left(Widget_Data *wd)
|
|||
static Eina_Bool
|
||||
_item_single_select_right(Widget_Data *wd)
|
||||
{
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
|
||||
Elm_Gengrid_Item *next;
|
||||
if (!wd->selected)
|
||||
{
|
||||
next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
|
||||
while ((next) && (next->delete_me))
|
||||
next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
|
||||
}
|
||||
else next = elm_gengrid_item_next_get(wd->last_selected_item);
|
||||
|
||||
if (!next) return EINA_FALSE;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
|
|
@ -389,6 +389,7 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty
|
|||
Evas_Event_Key_Down *ev = event_info;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return EINA_FALSE;
|
||||
if (!wd->items) return EINA_FALSE;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
|
||||
if (elm_widget_disabled_get(obj)) return EINA_FALSE;
|
||||
|
||||
|
@ -546,8 +547,15 @@ _item_multi_select_down(Widget_Data *wd)
|
|||
static Eina_Bool
|
||||
_item_single_select_up(Widget_Data *wd)
|
||||
{
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
|
||||
Elm_Genlist_Item *prev;
|
||||
if (!wd->selected)
|
||||
{
|
||||
prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
|
||||
while ((prev) && (prev->delete_me))
|
||||
prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
|
||||
}
|
||||
else prev = elm_genlist_item_prev_get(wd->last_selected_item);
|
||||
|
||||
if (!prev) return EINA_FALSE;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
@ -560,8 +568,15 @@ _item_single_select_up(Widget_Data *wd)
|
|||
static Eina_Bool
|
||||
_item_single_select_down(Widget_Data *wd)
|
||||
{
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
|
||||
Elm_Genlist_Item *next;
|
||||
if (!wd->selected)
|
||||
{
|
||||
next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
|
||||
while ((next) && (next->delete_me))
|
||||
next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
|
||||
}
|
||||
else next = elm_genlist_item_next_get(wd->last_selected_item);
|
||||
|
||||
if (!next) return EINA_FALSE;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
|
|
@ -127,6 +127,7 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty
|
|||
Evas_Event_Key_Down *ev = event_info;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return EINA_FALSE;
|
||||
if (!wd->items) return EINA_FALSE;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
|
||||
if (elm_widget_disabled_get(obj)) return EINA_FALSE;
|
||||
|
||||
|
@ -278,8 +279,11 @@ _item_multi_select_down(Widget_Data *wd)
|
|||
static Eina_Bool
|
||||
_item_single_select_up(Widget_Data *wd)
|
||||
{
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
Elm_List_Item *prev = elm_list_item_prev(wd->last_selected_item);
|
||||
Elm_List_Item *prev;
|
||||
|
||||
if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
|
||||
else prev = elm_list_item_prev(wd->last_selected_item);
|
||||
|
||||
if (!prev) return EINA_FALSE;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
@ -292,8 +296,11 @@ _item_single_select_up(Widget_Data *wd)
|
|||
static Eina_Bool
|
||||
_item_single_select_down(Widget_Data *wd)
|
||||
{
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
Elm_List_Item *next = elm_list_item_next(wd->last_selected_item);
|
||||
Elm_List_Item *next;
|
||||
|
||||
if (!wd->selected) next = eina_list_data_get(wd->items);
|
||||
else next = elm_list_item_next(wd->last_selected_item);
|
||||
|
||||
if (!next) return EINA_FALSE;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
|
Loading…
Reference in New Issue