zmike pushed a commit to branch efl-1.22.

http://git.enlightenment.org/core/efl.git/commit/?id=e45b172bebf60feca4c6c6f64f5ddcab4543a806

commit e45b172bebf60feca4c6c6f64f5ddcab4543a806
Author: Mike Blumenkrantz <[email protected]>
Date:   Wed May 29 09:30:54 2019 -0400

    elm/genlist: handle genlist finding of nearest visible item when not 
realized
    
    Summary:
    FIXME--
    
    @fix
    Depends on D8995
    
    Reviewers: cedric
    
    Reviewed By: cedric
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D8996
---
 src/lib/elementary/elm_genlist.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c
index b14aebb478..e0c1e7bbb7 100644
--- a/src/lib/elementary/elm_genlist.c
+++ b/src/lib/elementary/elm_genlist.c
@@ -3351,7 +3351,7 @@ _elm_genlist_nearest_visible_item_get(Evas_Object *obj, 
Elm_Object_Item *eo_it)
    Evas_Coord ix = 0, iy = 0, iw = 0, ih = 0; // given item geometry
    Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0; // candidate item geometry
    Eina_List *item_list = NULL, *l = NULL;
-   Elm_Object_Item *eo_item = NULL;
+   Elm_Object_Item *first_item, *eo_item = NULL;
    ELM_GENLIST_DATA_GET(obj, sd);
    Eina_Bool search_next = EINA_FALSE;
 
@@ -3359,19 +3359,27 @@ _elm_genlist_nearest_visible_item_get(Evas_Object *obj, 
Elm_Object_Item *eo_it)
    ELM_GENLIST_ITEM_DATA_GET(eo_it, it);
 
    evas_object_geometry_get(sd->pan_obj, &vx, &vy, &vw, &vh);
-   evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih); // FIXME: check if 
the item is realized or not
 
-   if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih))
+   if (it->realized)
      {
-        if (!elm_object_item_disabled_get(eo_it))
-          return eo_it;
-        else
-          search_next = EINA_TRUE;
+        evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih);
+
+        if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih))
+          {
+             if (!elm_object_item_disabled_get(eo_it))
+               return eo_it;
+             else
+               search_next = EINA_TRUE;
+          }
      }
 
    item_list = elm_genlist_realized_items_get(obj);
+   /* if first realized item is before parameter item then parameter item is
+    * off viewport towards bottom: start at end of list */
+   first_item = eina_list_data_get(item_list);
+   ELM_GENLIST_ITEM_DATA_GET(first_item, first_it);
 
-   if ((iy < vy) || search_next)
+   if ((iy < vy) || search_next || (!first_it) || (first_it->position > 
it->position))
      {
         EINA_LIST_FOREACH(item_list, l, eo_item)
           {
@@ -3401,7 +3409,7 @@ _elm_genlist_nearest_visible_item_get(Evas_Object *obj, 
Elm_Object_Item *eo_it)
      }
    eina_list_free(item_list);
 
-   return eo_it;
+   return it->realized ? eo_it : NULL;
 }
 
 EOLIAN static void

-- 


Reply via email to