summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2016-01-17 15:11:29 +0100
committerDave Andreoli <dave@gurumeditation.it>2016-01-17 15:11:29 +0100
commitfe3e4cc3eb71017ec3aaa6fa996f56b666fa9fbc (patch)
treecac3775bae7a351b7c5cceb62a9c2486472f9f9a
parentb4ae338a70b7efb682d763a0b2b90ef1570a93c6 (diff)
Gengrid: improve item_region_show code
There is no need to recalc row and col position of the item, they are already stored in the item struct. The old implementation was calculating wrong values and also was storing this wrong values in it->x and it->y, resulting in wrong results for the elm_gengrid_item_pos_get() function. so, at the end, this is a @fix for the pos_get() function. Also changed a bit the test to let the gengrid fill the window and thus testing behaviour on col/row changes. I didn't find any regression in all the gengrid tests after this, let me know if it broke something for you.
-rw-r--r--src/bin/test_gengrid.c1
-rw-r--r--src/lib/elm_gengrid.c39
2 files changed, 8 insertions, 32 deletions
diff --git a/src/bin/test_gengrid.c b/src/bin/test_gengrid.c
index 6ba3622bc..bd74e5b8d 100644
--- a/src/bin/test_gengrid.c
+++ b/src/bin/test_gengrid.c
@@ -1306,6 +1306,7 @@ test_gengrid4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
1306 elm_gengrid_item_class_free(gic); 1306 elm_gengrid_item_class_free(gic);
1307 elm_gengrid_item_show(ti[2579].item, sd->scrollto); 1307 elm_gengrid_item_show(ti[2579].item, sd->scrollto);
1308 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1308 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1309 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
1309 evas_object_size_hint_min_set(grid, 600, 400); 1310 evas_object_size_hint_min_set(grid, 600, 400);
1310 evas_object_show(grid); 1311 evas_object_show(grid);
1311 sd->grid = grid; 1312 sd->grid = grid;
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
index 7661995a2..02b1294e3 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -328,14 +328,13 @@ static void
328_item_show_region(void *data) 328_item_show_region(void *data)
329{ 329{
330 Elm_Gengrid_Data *sd = data; 330 Elm_Gengrid_Data *sd = data;
331 Evas_Coord cvw, cvh, it_xpos = 0, it_ypos = 0, col = 0, row = 0, minx = 0, miny = 0; 331 Evas_Coord cvw, cvh, it_xpos = 0, it_ypos = 0, minx = 0, miny = 0;
332 Evas_Coord vw = 0, vh = 0; 332 Evas_Coord vw = 0, vh = 0;
333 Elm_Object_Item *eo_it = NULL; 333 Elm_Object_Item *eo_it = NULL;
334 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh); 334 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
335 335
336 if ((cvw != 0) && (cvh != 0)) 336 if ((cvw != 0) && (cvh != 0))
337 { 337 {
338 int x = 0, y = 0;
339 if (sd->show_region) 338 if (sd->show_region)
340 eo_it = sd->show_it; 339 eo_it = sd->show_it;
341 else if (sd->bring_in) 340 else if (sd->bring_in)
@@ -347,45 +346,21 @@ _item_show_region(void *data)
347 eo_do(sd->pan_obj, elm_obj_pan_pos_min_get(&minx, &miny)); 346 eo_do(sd->pan_obj, elm_obj_pan_pos_min_get(&minx, &miny));
348 if (sd->horizontal && (sd->item_height > 0)) 347 if (sd->horizontal && (sd->item_height > 0))
349 { 348 {
350 row = cvh / sd->item_height; 349 if (it->x >= 1)
351 if (row <= 0) row = 1; 350 it_xpos = ((it->x - GG_IT(it)->prev_group) * sd->item_width)
352 x = (it->position - 1) / row;
353 if (elm_widget_mirrored_get(sd->obj))
354 {
355 col = sd->item_count / row;
356 if (sd->item_count % row == 0)
357 col--;
358 x = col - x;
359 }
360
361 y = (it->position - 1) % row;
362 if (x >= 1)
363 it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width)
364 + (GG_IT(it)->prev_group * sd->group_item_width) 351 + (GG_IT(it)->prev_group * sd->group_item_width)
365 + minx; 352 + minx;
366 else it_xpos = minx; 353 else it_xpos = minx;
367 miny = miny + ((cvh - (sd->item_height * row)) 354 it_ypos = it->y * sd->item_height + miny;
368 * sd->align_y);
369 it_ypos = y * sd->item_height + miny;
370 it->x = x;
371 it->y = y;
372 } 355 }
373 else if (sd->item_width > 0) 356 else if (sd->item_width > 0)
374 { 357 {
375 col = cvw / sd->item_width; 358 it_xpos = it->x * sd->item_width + minx;
376 if (col <= 0) col = 1; 359 if (it->y >= 1)
377 y = (it->position - 1) / col; 360 it_ypos = ((it->y - GG_IT(it)->prev_group) * sd->item_height)
378 x = (it->position - 1) % col;
379 it_xpos = x * sd->item_width + minx;
380 if (y >= 1)
381 it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height)
382 + (GG_IT(it)->prev_group * sd->group_item_height) 361 + (GG_IT(it)->prev_group * sd->group_item_height)
383 + miny; 362 + miny;
384 else it_ypos = miny; 363 else it_ypos = miny;
385 minx = minx + ((cvw - (sd->item_width * col))
386 * sd->align_x);
387 it->x = x;
388 it->y = y;
389 } 364 }
390 365
391 switch (sd->scroll_to_type) 366 switch (sd->scroll_to_type)