From 90020eb613347c0f0695e4d377e782ffa90e2571 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 29 May 2012 10:25:55 +0000 Subject: [PATCH] genlist prepends no longer cause selected items to be autoscrolled out of the viewport SVN revision: 71500 --- ChangeLog | 4 ++++ src/lib/elm_genlist.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 94be09f..3813d23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -115,3 +115,7 @@ * Made elm_object_focus_set() fall back to evbas_object_focus_set() if the object is not an elm widget. +2012-05-29 Mike Blumenkrantz + + * Prepending items to a genlist no longer causes the selected item to + scroll out of the viewport diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c index 48fab79..15a2e8e 100644 --- a/src/lib/elm_genlist.c +++ b/src/lib/elm_genlist.c @@ -4116,6 +4116,18 @@ _item_process_post(Widget_Data *wd, Elm_Gen_Item *it, Eina_Bool qadd) } } if (showme) it->item->block->showme = EINA_TRUE; + /* when prepending, move the scroller along with the first selected item to + * create the illusion that we're watching the selected item + * this prevents the selected item being scrolled off the viewport + */ + if (wd->selected && it->item->before) + { + int y, h; + it = wd->selected->data; + elm_smart_scroller_child_pos_get(wd->scr, NULL, &y); + evas_object_geometry_get(wd->pan_smart, NULL, NULL, NULL, &h); + elm_smart_scroller_child_region_show(wd->scr, it->x + it->item->block->x, y + it->item->h, it->item->block->w, h); + } } static int -- 2.7.4