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:54:26 +0200
commita85581e4635352c91b986e55cc2a575aa360d075 (patch)
treec9b74e270db80f88b3fa85a76b9454b0ec1ddf01
parentc2a9cd725b8269f4d601e3ad83c0b2657c4c9d44 (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 6462ab3e9..f0a3e1fe7 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -108,8 +108,7 @@ _item_show_region(void *data)
108 row = cvh / sd->item_height; 108 row = cvh / sd->item_height;
109 if (row <= 0) row = 1; 109 if (row <= 0) row = 1;
110 x = (it->position - 1) / row; 110 x = (it->position - 1) / row;
111 if (x == 0) y = it->position - 1; 111 y = (it->position - 1) % row;
112 else if (x > 0) y = (it->position - 1) % x;
113 if (x >= 1) 112 if (x >= 1)
114 it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width) 113 it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width)
115 + (GG_IT(it)->prev_group * sd->group_item_width) 114 + (GG_IT(it)->prev_group * sd->group_item_width)
@@ -124,10 +123,10 @@ _item_show_region(void *data)
124 else if (sd->item_width > 0) 123 else if (sd->item_width > 0)
125 { 124 {
126 col = cvw / sd->item_width; 125 col = cvw / sd->item_width;
126
127 if (col <= 0) col = 1; 127 if (col <= 0) col = 1;
128 y = (it->position - 1) / col; 128 y = (it->position - 1) / col;
129 if (y == 0) x = it->position - 1; 129 x = (it->position - 1) % col;
130 else if (y > 0) x = (it->position - 1) % y;
131 it_xpos = x * sd->item_width + minx; 130 it_xpos = x * sd->item_width + minx;
132 if (y >= 1) 131 if (y >= 1)
133 it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height) 132 it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height)