Gengrid: improve item_region_show code 96/89896/3
authorSangHyeon Lee <sh10233.lee@samsung.com>
Tue, 27 Sep 2016 10:13:40 +0000 (19:13 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 17 Nov 2016 08:07:49 +0000 (17:07 +0900)
This patch is forked by upstream patch
16b16b71282ee6b0115c5db3e714ec934249e771
written by Dave Andreoli

Change-Id: If4a66c71169f711f0f107f8b6985880ca42b2b0c

src/bin/test_gengrid.c
src/lib/elm_gengrid.c

index 346e1f996cb0dcd5d0309a0212a94bcf6f96c59b..8f67c9b03759a62328f6c4c6f9fab119039a85d0 100644 (file)
@@ -1223,6 +1223,7 @@ _show_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA
    else if (sd->winmode == 1)
      elm_gengrid_horizontal_set(grid, EINA_FALSE);
    evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
    elm_win_resize_object_add(win, grid);
    elm_gengrid_align_set(grid, 0.1, 0.1);
 
index cfdf0367258ef851f9401ed355b9b929ab4f6655..99e3c3f7e39701c290cdba131871954dab1b47a8 100644 (file)
@@ -333,14 +333,13 @@ static void
 _item_show_region(void *data)
 {
    Elm_Gengrid_Data *sd = data;
-   Evas_Coord cvw, cvh, it_xpos = 0, it_ypos = 0, col = 0, row = 0, minx = 0, miny = 0;
+   Evas_Coord cvw, cvh, it_xpos = 0, it_ypos = 0, minx = 0, miny = 0;
    Evas_Coord vw = 0, vh = 0;
    Elm_Object_Item *eo_it = NULL;
    evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
 
    if ((cvw != 0) && (cvh != 0))
        {
-          int x = 0, y = 0;
           if (sd->show_region)
             eo_it = sd->show_it;
           else if (sd->bring_in)
@@ -352,45 +351,21 @@ _item_show_region(void *data)
           eo_do(sd->pan_obj, elm_obj_pan_pos_min_get(&minx, &miny));
           if (sd->horizontal && (sd->item_height > 0))
             {
-               row = cvh / sd->item_height;
-               if (row <= 0) row = 1;
-               x = (it->position - 1) / row;
-               if (elm_widget_mirrored_get(sd->obj))
-                 {
-                    col = sd->item_count / row;
-                    if (sd->item_count % row == 0)
-                      col--;
-                    x = col - x;
-                 }
-
-               y = (it->position - 1) % row;
-               if (x >= 1)
-                 it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width)
+               if (it->x >= 1)
+                 it_xpos = ((it->x - GG_IT(it)->prev_group) * sd->item_width)
                     + (GG_IT(it)->prev_group * sd->group_item_width)
                     + minx;
                else it_xpos = minx;
-               miny = miny + ((cvh - (sd->item_height * row))
-                    * sd->align_y);
-               it_ypos = y * sd->item_height + miny;
-               it->x = x;
-               it->y = y;
+               it_ypos = it->y * sd->item_height + miny;
             }
           else if (sd->item_width > 0)
             {
-               col = cvw / sd->item_width;
-               if (col <= 0) col = 1;
-               y = (it->position - 1) / col;
-               x = (it->position - 1) % col;
-               it_xpos = x * sd->item_width + minx;
-               if (y >= 1)
-                 it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height)
+               it_xpos = it->x * sd->item_width + minx;
+               if (it->y >= 1)
+                 it_ypos = ((it->y - GG_IT(it)->prev_group) * sd->item_height)
                     + (GG_IT(it)->prev_group * sd->group_item_height)
                     + miny;
                else it_ypos = miny;
-               minx = minx + ((cvw - (sd->item_width * col))
-                    * sd->align_x);
-               it->x = x;
-               it->y = y;
             }
 
           switch (sd->scroll_to_type)