genlist : fix item lost highlight at the end of scroll 44/207644/5
authorSangHyeon Jade Lee <sh10233.lee@samsung.com>
Mon, 10 Jun 2019 11:36:36 +0000 (20:36 +0900)
committerSangHyeon Jade Lee <sh10233.lee@samsung.com>
Mon, 10 Jun 2019 11:43:35 +0000 (20:43 +0900)
adjusted item can be last item or NULL,
as the position is out of boundary,
but they are not centered item, so highlight could be disappear.
limiting the adjusted item for the previous one of last item
solve the issue.

Change-Id: Id032bb63b00c4d025653c34ce59246fa7661ae2c
Signed-off-by: SangHyeon Jade Lee <sh10233.lee@samsung.com>
src/lib/elementary_tizen/elm_genlist.c

index af3fb6f..d85ad48 100644 (file)
@@ -405,16 +405,15 @@ _elm_genlist_pos_adjust_xy_item_get(const Evas_Object *obj,
      {
         Eina_List *l = NULL;
         Elm_Gen_Item *it;
-        if (!ELM_RECTS_INTERSECT(itb->x - sd->pan_x,
-                                 itb->y - sd->pan_y,
+        if (!ELM_RECTS_INTERSECT(itb->x, itb->y,
                                  sd->minw, itb->minh, x, y, 1, 1))
           continue;
         EINA_LIST_FOREACH(itb->items, l, it)
           {
              Evas_Coord itx, ity, itw, ith;
 
-             itx = itb->x + it->x - sd->pan_x;
-             ity = itb->y + it->y - sd->pan_y;
+             itx = itb->x + it->x;
+             ity = itb->y + it->y;
 
              itw = (GL_IT(it)->w ? GL_IT(it)->w : sd->minw);
              ith = GL_IT(it)->minh;
@@ -433,9 +432,10 @@ _adjust_item_align(Elm_Gen_Item *it)
    if (!it) return NULL;
    int loop_count = 0;
    int direction;
+   Elm_Genlist_Data *sd = GL_IT(it)->wsd;
    Elm_Gen_Item *adjust_item = it;
+   Elm_Gen_Item *last = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
    Elm_Object_Item *eo_item = NULL;
-   Elm_Genlist_Data *sd = GL_IT(it)->wsd;
 
    ELM_WIDGET_DATA_GET_OR_RETURN(WIDGET(adjust_item), wd, NULL);
 
@@ -468,7 +468,13 @@ _adjust_item_align(Elm_Gen_Item *it)
         ++loop_count;
      }
 
-   if (adjust_item) return adjust_item;
+   if (adjust_item)
+     {
+        //Adjusted item must be aligned center position, so last item cannot be adjusted item.
+        if (adjust_item == last)
+          adjust_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(adjust_item)->prev);
+        return adjust_item;
+     }
 
    adjust_item = it;
    while (adjust_item && loop_count < 10)
@@ -499,6 +505,10 @@ _adjust_item_align(Elm_Gen_Item *it)
    if (!adjust_item)
      adjust_item = it;
 
+   //Adjusted item must be aligned center position, so last item cannot be adjusted item.
+   if (adjust_item == last)
+     adjust_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(adjust_item)->prev);
+
    return adjust_item;
 }
 
@@ -517,12 +527,21 @@ _elm_genlist_pan_elm_pan_pos_adjust(Eo *obj EINA_UNUSED, Elm_Genlist_Pan_Data *p
    Evas_Coord cx = 0, cy = 0;
    Evas_Coord it_y, it_h;
    Evas_Coord yy = *y;
+   Evas_Coord miny = 0, maxy = 0;
+
+   elm_pan_pos_min_get(sd->pan_obj, NULL, &miny);
+   elm_pan_pos_max_get(sd->pan_obj, NULL, &maxy);
 
    elm_interface_scrollable_content_viewport_geometry_get(sd->obj, NULL, NULL, &vw, &vh);
+
+   yy = sd->pan_y - yy;
+   if (yy > maxy) yy = maxy;
+   if (yy < miny) yy = miny;
+
    if (!strcmp(wd->scroll_item_valign, "center"))
      {
         cx = (vw / 2);
-        cy = (vh / 2) - yy;
+        cy = yy + (vh / 2);
      }
 
    sd->adjusted_item = _elm_genlist_pos_adjust_xy_item_get(sd->obj, cx, cy);
@@ -541,7 +560,6 @@ _elm_genlist_pan_elm_pan_pos_adjust(Eo *obj EINA_UNUSED, Elm_Genlist_Pan_Data *p
    sd->adjusted_item = _adjust_item_align(sd->adjusted_item);
    if (!sd->adjusted_item) return;
 
-   cy += psd->wsd->pan_y;
    it_y = sd->adjusted_item->y + GL_IT(sd->adjusted_item)->block->y;
    it_h = GL_IT(sd->adjusted_item)->h;