From 947f7ffd376e7183f1ad8f3f103392c0da47283b Mon Sep 17 00:00:00 2001 From: Jonathan Atton Date: Wed, 14 Oct 2009 21:57:46 +0000 Subject: [PATCH] Elm genlist: add elm_genlist_item_middle_bring_in/show(item)). Elm slideshow : fix a problem with the timer SVN revision: 43087 --- legacy/elementary/AUTHORS | 1 + legacy/elementary/src/bin/test_genlist.c | 2 +- legacy/elementary/src/lib/Elementary.h.in | 2 + legacy/elementary/src/lib/elm_genlist.c | 74 +++++++++++++++++++++++ legacy/elementary/src/lib/elm_slideshow.c | 12 ++-- 5 files changed, 84 insertions(+), 7 deletions(-) diff --git a/legacy/elementary/AUTHORS b/legacy/elementary/AUTHORS index 326c104197..7c06ab839b 100644 --- a/legacy/elementary/AUTHORS +++ b/legacy/elementary/AUTHORS @@ -8,3 +8,4 @@ Swisscom - http://www.swisscom.ch/ Christopher Michael Marco Trevisan (TreviƱo) Michael Bouchaud +Jonathan Atton (Watchwolf) diff --git a/legacy/elementary/src/bin/test_genlist.c b/legacy/elementary/src/bin/test_genlist.c index 2fc6eedc48..32d256f64c 100644 --- a/legacy/elementary/src/bin/test_genlist.c +++ b/legacy/elementary/src/bin/test_genlist.c @@ -62,7 +62,7 @@ _bt50_cb(void *data, Evas_Object *obj, void *event_info) static void _bt1500_cb(void *data, Evas_Object *obj, void *event_info) { - elm_genlist_item_bring_in(data); + elm_genlist_item_middle_bring_in(data); } void diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 52e84dda3a..18098f6c5d 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -771,6 +771,8 @@ extern "C" { EAPI void elm_genlist_item_bring_in(Elm_Genlist_Item *item); EAPI void elm_genlist_item_top_show(Elm_Genlist_Item *item); EAPI void elm_genlist_item_top_bring_in(Elm_Genlist_Item *item); + EAPI void elm_genlist_item_middle_show(Elm_Genlist_Item *it); + EAPI void elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it); EAPI void elm_genlist_item_del(Elm_Genlist_Item *item); EAPI const void *elm_genlist_item_data_get(const Elm_Genlist_Item *item); EAPI void elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data); diff --git a/legacy/elementary/src/lib/elm_genlist.c b/legacy/elementary/src/lib/elm_genlist.c index 846d97b1ce..2874375649 100644 --- a/legacy/elementary/src/lib/elm_genlist.c +++ b/legacy/elementary/src/lib/elm_genlist.c @@ -2398,6 +2398,80 @@ elm_genlist_item_top_bring_in(Elm_Genlist_Item *it) it->block->w, oh); } +/** + * Show the given item at the middle + * + * This causes genlist to jump to the given item @p it and show it (by scrolling), + * if it is not fully visible. + * + * @param it The item + * + * @ingroup Genlist + */ +EAPI void +elm_genlist_item_middle_show(Elm_Genlist_Item *it) +{ + Evas_Coord ow, oh; + + if (!it) return; + if (it->delete_me) return; + if ((it->queued) || (!it->mincalcd)) + { + it->wd->show_item = it; + it->wd->bring_in = 1; + it->showme = EINA_TRUE; + return; + } + if (it->wd->show_item) + { + it->wd->show_item->showme = EINA_FALSE; + it->wd->show_item = NULL; + } + evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh); + elm_smart_scroller_child_region_show(it->wd->scr, + it->x + it->block->x, + it->y + it->block->y - oh/2 + it->h/2, + it->block->w, oh); +} + + +/** + * Bring in the given item at the middle + * + * This causes genlist to jump to the given item @p it and show it (by scrolling), + * if it is not fully visible. This may use animation to do so and take a + * period of time + * + * @param it The item + * + * @ingroup Genlist + */ +EAPI void +elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it) +{ + Evas_Coord ow, oh; + + if (!it) return; + if (it->delete_me) return; + if ((it->queued) || (!it->mincalcd)) + { + it->wd->show_item = it; + it->wd->bring_in = 1; + it->showme = EINA_TRUE; + return; + } + if (it->wd->show_item) + { + it->wd->show_item->showme = EINA_FALSE; + it->wd->show_item = NULL; + } + evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh); + elm_smart_scroller_region_bring_in(it->wd->scr, + it->x + it->block->x, + it->y + it->block->y - oh/2 + it->h/2, + it->block->w, oh); +} + /** * Delete a given item * diff --git a/legacy/elementary/src/lib/elm_slideshow.c b/legacy/elementary/src/lib/elm_slideshow.c index f38f10f674..3d4c3403b7 100644 --- a/legacy/elementary/src/lib/elm_slideshow.c +++ b/legacy/elementary/src/lib/elm_slideshow.c @@ -276,6 +276,9 @@ elm_slideshow_next(Evas_Object *obj) _end(obj, obj, NULL, NULL); + if (wd->timer) ecore_timer_del(wd->timer); + wd->timer = NULL; + if(!next->o && next->itc->func.get) { next->o = next->itc->func.get((void*)next->data, obj); @@ -290,9 +293,6 @@ elm_slideshow_next(Evas_Object *obj) wd->previous = wd->current; wd->current = next; - - if (wd->timer) ecore_timer_del(wd->timer); - wd->timer = NULL; } /** @@ -321,6 +321,9 @@ elm_slideshow_previous(Evas_Object *obj) _end(obj, obj, NULL, NULL); + if (wd->timer) ecore_timer_del(wd->timer); + wd->timer = NULL; + if(!prev->o && prev->itc->func.get) { prev->o = prev->itc->func.get((void*)prev->data, obj); @@ -334,9 +337,6 @@ elm_slideshow_previous(Evas_Object *obj) wd->previous = wd->current; wd->current = prev; - - if (wd->timer) ecore_timer_del(wd->timer); - wd->timer = NULL; } /**