X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Flib%2Felm_genlist.c;h=c71d4a8c73f5f822cc3f96135602673d07e29c63;hb=bbf5654f2779e06d2f6af273b6c344e1bbc643bf;hp=fac0cff74f6deb940f5b1110a3600b7b71a4868a;hpb=d8bc35a117109ba043f9f899467d1d36a303b2eb;p=framework%2Fuifw%2Felementary.git diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c index fac0cff..c71d4a8 100644 --- a/src/lib/elm_genlist.c +++ b/src/lib/elm_genlist.c @@ -1,7 +1,3 @@ -/* - * - * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 - */ #include #include "elm_priv.h" @@ -266,9 +262,12 @@ struct _Widget_Data Eina_Bool bring_in : 1; Eina_Bool compress : 1; Eina_Bool homogeneous : 1; + Eina_Bool clear_me : 1; + int walking; int item_width; int item_height; int max_items_per_block; + double longpress_timeout; }; struct _Item_Block @@ -509,6 +508,7 @@ static void _item_del(Elm_Genlist_Item *it) { elm_genlist_item_subitems_clear(it); + it->wd->walking -= it->walking; if (it->wd->show_item == it) it->wd->show_item = NULL; if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it); if (it->realized) _item_unrealize(it); @@ -538,13 +538,20 @@ _item_select(Elm_Genlist_Item *it) it->wd->selected = eina_list_append(it->wd->selected, it); call: it->walking++; + it->wd->walking++; if (it->func.func) it->func.func((void *)it->func.data, it->wd->obj, it); if (!it->delete_me) evas_object_smart_callback_call(it->wd->obj, "selected", it); it->walking--; - if ((it->walking == 0) && (it->delete_me)) + it->wd->walking--; + if ((it->wd->clear_me) && (it->wd->walking == 0)) + elm_genlist_clear(it->wd->obj); + else { - if (it->relcount == 0) _item_del(it); + if ((it->walking == 0) && (it->delete_me)) + { + if (it->relcount == 0) _item_del(it); + } } } @@ -583,7 +590,8 @@ _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_inf if (!it->wd->on_hold) { it->wd->on_hold = EINA_TRUE; - _item_unselect(it); + if (!it->wd->wasselected) + _item_unselect(it); } } if ((it->dragging) && (it->down)) @@ -628,7 +636,6 @@ _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_inf } if (!it->wd->wasselected) _item_unselect(it); - it->wd->wasselected = 0; if (dy < 0) { if (ady > adx) @@ -661,16 +668,16 @@ _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_inf } } -static int +static Eina_Bool _long_press(void *data) { Elm_Genlist_Item *it = data; it->long_timer = NULL; - if ((it->disabled) || (it->dragging)) return 0; + if ((it->disabled) || (it->dragging)) return ECORE_CALLBACK_CANCEL; it->wd->longpressed = EINA_TRUE; evas_object_smart_callback_call(it->wd->obj, "longpressed", it); - return 0; + return ECORE_CALLBACK_CANCEL; } static void @@ -681,6 +688,7 @@ _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_inf Evas_Coord x, y; if (ev->button != 1) return; + it->down = 1; it->dragging = 0; evas_object_geometry_get(obj, &x, &y, NULL, NULL); @@ -695,7 +703,7 @@ _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_inf evas_object_smart_callback_call(it->wd->obj, "clicked", it); if (it->long_timer) ecore_timer_del(it->long_timer); if (it->realized) - it->long_timer = ecore_timer_add(1.0, _long_press, it); + it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press, it); else it->long_timer = NULL; } @@ -1495,6 +1503,7 @@ elm_genlist_add(Evas_Object *parent) wd->obj = obj; wd->mode = ELM_LIST_SCROLL; wd->max_items_per_block = 32; + wd->longpress_timeout = 1.0; evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj); evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj); @@ -1732,7 +1741,7 @@ _queue_proecess(Widget_Data *wd, int norender) return n; } -static int +static Eina_Bool _item_idler(void *data) { Widget_Data *wd = data; @@ -1745,9 +1754,9 @@ _item_idler(void *data) if (!wd->queue) { wd->queue_idler = NULL; - return 0; + return ECORE_CALLBACK_CANCEL; } - return 1; + return ECORE_CALLBACK_RENEW; } static void @@ -1959,6 +1968,18 @@ elm_genlist_clear(Evas_Object *obj) ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; + if (wd->walking > 0) + { + Elm_Genlist_Item *it; + + wd->clear_me = 1; + EINA_INLIST_FOREACH(wd->items, it) + { + it->delete_me = 1; + } + return; + } + wd->clear_me = 0; while (wd->items) { Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items); @@ -3145,3 +3166,37 @@ elm_genlist_block_count_get(const Evas_Object *obj) if (!wd) return 0; return wd->max_items_per_block; } + +/** + * Set the timeout in seconds for the longpress event + * + * @param obj The genlist object + * @param timeout timeout in seconds + * + * @ingroup Genlist + */ +EAPI void +elm_genlist_longpress_timeout_set(const Evas_Object *obj, double timeout) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + wd->longpress_timeout = timeout; +} + +/** + * Get the timeout in seconds for the longpress event + * + * @param obj The genlist object + * @return timeout in seconds + * + * @ingroup Genlist + */ +EAPI double +elm_genlist_longpress_timeout_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) 0; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return 0; + return wd->longpress_timeout; +}