summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2014-08-09 15:47:59 +0200
committerdavemds <dave@gurumeditation.it>2014-08-09 15:52:32 +0200
commit4aefb91c58f3b4bf795f7b2814dd2f2eafa75305 (patch)
tree59fb58509aad1a9dab1dfd45f93041e199649679
parentc9548169bae0bae4b6fe7b538e149a0eace537c3 (diff)
Gengrid: fix position calculation
@fix To calc the position in a table you need to make the modulo of the col/row size, not the modulo on the x/y value This unbreak the elm_gengrid_item_pos_get() function that was reporting wrong values
-rw-r--r--src/lib/elm_gengrid.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
index 87e5005f0..8af918ce2 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -123,8 +123,7 @@ _item_show_region(void *data)
123 row = cvh / sd->item_height; 123 row = cvh / sd->item_height;
124 if (row <= 0) row = 1; 124 if (row <= 0) row = 1;
125 x = (it->position - 1) / row; 125 x = (it->position - 1) / row;
126 if (x == 0) y = it->position - 1; 126 y = (it->position - 1) % row;
127 else if (x > 0) y = (it->position - 1) % x;
128 if (x >= 1) 127 if (x >= 1)
129 it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width) 128 it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width)
130 + (GG_IT(it)->prev_group * sd->group_item_width) 129 + (GG_IT(it)->prev_group * sd->group_item_width)
@@ -139,10 +138,10 @@ _item_show_region(void *data)
139 else if (sd->item_width > 0) 138 else if (sd->item_width > 0)
140 { 139 {
141 col = cvw / sd->item_width; 140 col = cvw / sd->item_width;
141
142 if (col <= 0) col = 1; 142 if (col <= 0) col = 1;
143 y = (it->position - 1) / col; 143 y = (it->position - 1) / col;
144 if (y == 0) x = it->position - 1; 144 x = (it->position - 1) % col;
145 else if (y > 0) x = (it->position - 1) % y;
146 it_xpos = x * sd->item_width + minx; 145 it_xpos = x * sd->item_width + minx;
147 if (y >= 1) 146 if (y >= 1)
148 it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height) 147 it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height)