From 8fb7daa582ce05fe0a0e28039b12dcb62b5d363f Mon Sep 17 00:00:00 2001 From: Rafael Fonseca Date: Tue, 23 Nov 2010 20:30:48 +0000 Subject: [PATCH] Fix item alignment in Gengrid. When the item was bigger than the grid it was not being correctly positioned. SVN revision: 54906 --- legacy/elementary/src/lib/elm_gengrid.c | 36 +++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/legacy/elementary/src/lib/elm_gengrid.c b/legacy/elementary/src/lib/elm_gengrid.c index 082e5c6cfd..b6cab669f0 100644 --- a/legacy/elementary/src/lib/elm_gengrid.c +++ b/legacy/elementary/src/lib/elm_gengrid.c @@ -1022,8 +1022,6 @@ _item_place(Elm_Gengrid_Item *item, Evas_Coord cx, Evas_Coord cy) item->x = cx; item->y = cy; evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh); - evas_output_viewport_get(evas_object_evas_get(item->wd->self), - &cvx, &cvy, &cvw, &cvh); /* Preload rows/columns at each side of the Gengrid */ cvx = ox - PRELOAD * item->wd->item_width; @@ -1047,11 +1045,9 @@ _item_place(Elm_Gengrid_Item *item, Evas_Coord cx, Evas_Coord cy) if (item->wd->count % items_visible) columns++; - if (item->wd->minw < vw) - { - tcw = item->wd->item_width * columns; - alignw = (vw - tcw) * item->wd->align_x; - } + tcw = item->wd->item_width * columns; + alignw = (vw - tcw) * item->wd->align_x; + items_row = items_visible; if (items_row > item->wd->count) items_row = item->wd->count; @@ -1071,11 +1067,9 @@ _item_place(Elm_Gengrid_Item *item, Evas_Coord cx, Evas_Coord cy) if (item->wd->count % items_visible) rows++; - if (item->wd->minh < vh) - { - tch = item->wd->item_height * rows; - alignh = (vh - tch) * item->wd->align_y; - } + tch = item->wd->item_height * rows; + alignh = (vh - tch) * item->wd->align_y; + items_col = items_visible; if (items_col > item->wd->count) items_col = item->wd->count; @@ -1289,6 +1283,20 @@ _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0; } +static void +_pan_min_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) +{ + Pan *sd = evas_object_smart_data_get(obj); + Evas_Coord mx, my; + + if (!sd) return; + _pan_max_get(obj, &mx, &my); + if (x) + *x = -mx * sd->wd->align_x; + if (y) + *y = -my * sd->wd->align_y; +} + static void _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) { @@ -1469,8 +1477,8 @@ elm_gengrid_add(Evas_Object *parent) } elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart, - _pan_set, _pan_get, - _pan_max_get, _pan_child_size_get); + _pan_set, _pan_get, _pan_max_get, + _pan_min_get, _pan_child_size_get); return obj; }