summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangHyeon Lee <dltkdgus1764@gmail.com>2015-06-25 16:35:44 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-06-25 17:24:08 +0200
commit80c8cfb7a244d770102b9411f84cfc8e84192190 (patch)
treee35a48675a9c0b2c959f5f746e3feb503831d85d
parent3373d6f12ac0eefbee34b1f0ecbd368e60ce6d65 (diff)
elm_gengrid: fix the bug that gengrid item index(position) is updated wrong value in item_update
Summary: elm_gengrid_item_update perform item_unrealize/item_realize/item_place itself. But when gengrid items are added and not calculated yet, caller want to get item's index after execute elm_gengrid_item_update, return value is wrong because item_place update it's position in not-updated item's x and y. to prevent this, if item position is already updated, do not updates position in item place. additionally, I fixed gengrid item prepend wrong posiiton update. gengrid item position start from 1 not 0, so item_position_update also must be started from 1. @fix Test Plan: To test this scenario, need to fix src/bin/test_gengrid.c first. 1. add below codes in bottom of _after_bt_clicked(line 703). ``` Elm_Object_Item *it = elm_gengrid_item_next_get(id->item); printf("before update efl item[%p], index [%d]\n",id->item,elm_gengrid_item_index_get(it)); elm_gengrid_item_update(it); printf("after update efl item[%p], index [%d]\n",id->item,elm_gengrid_item_index_get(it)); ``` 2. execute elementary_test and go to gengrid2 test. 3. add 3 items and select 2nd item then add new item by insert after. 4. you can see index is changed wrong value after item_update executed. after add fallback code in item_update, index is returned same value even after item_update execusion. Reviewers: raster, Hermet, seoz, jaehwan Subscribers: anand.km, eagleeye, singh.amitesh Differential Revision: https://phab.enlightenment.org/D2616 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/elm_gengrid.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
index c996b63ed..70f30ec7f 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -1507,7 +1507,7 @@ _item_place(Elm_Gen_Item *it,
1507 tch = items_row * wsd->item_height; 1507 tch = items_row * wsd->item_height;
1508 alignh = (vh - tch) * wsd->align_y; 1508 alignh = (vh - tch) * wsd->align_y;
1509 item_pos = items_row * cx + cy + 1; 1509 item_pos = items_row * cx + cy + 1;
1510 if (item_pos != it->position) 1510 if (item_pos != it->position && !it->position_update)
1511 { 1511 {
1512 it->position = item_pos; 1512 it->position = item_pos;
1513 it->position_update = EINA_TRUE; 1513 it->position_update = EINA_TRUE;
@@ -1540,7 +1540,7 @@ _item_place(Elm_Gen_Item *it,
1540 tcw = items_col * wsd->item_width; 1540 tcw = items_col * wsd->item_width;
1541 alignw = (vw - tcw) * wsd->align_x; 1541 alignw = (vw - tcw) * wsd->align_x;
1542 item_pos = cx + items_col * cy + 1; 1542 item_pos = cx + items_col * cy + 1;
1543 if (item_pos != it->position) 1543 if (item_pos != it->position && !it->position_update)
1544 { 1544 {
1545 it->position = item_pos; 1545 it->position = item_pos;
1546 it->position_update = EINA_TRUE; 1546 it->position_update = EINA_TRUE;
@@ -1604,7 +1604,10 @@ _item_place(Elm_Gen_Item *it,
1604 { 1604 {
1605 _item_realize(it); 1605 _item_realize(it);
1606 if (!was_realized) 1606 if (!was_realized)
1607 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, EO_OBJ(it)); 1607 {
1608 _elm_gengrid_item_index_update(it);
1609 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, EO_OBJ(it));
1610 }
1608 if (it->parent) 1611 if (it->parent)
1609 { 1612 {
1610 if (wsd->horizontal) 1613 if (wsd->horizontal)
@@ -1798,7 +1801,10 @@ _group_item_place(Elm_Gengrid_Pan_Data *psd)
1798 { 1801 {
1799 _item_realize(it); 1802 _item_realize(it);
1800 if (!was_realized) 1803 if (!was_realized)
1801 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, EO_OBJ(it)); 1804 {
1805 _elm_gengrid_item_index_update(it);
1806 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, EO_OBJ(it));
1807 }
1802 evas_object_move 1808 evas_object_move
1803 (VIEW(it), GG_IT(it)->gx, 1809 (VIEW(it), GG_IT(it)->gx,
1804 GG_IT(it)->gy); 1810 GG_IT(it)->gy);
@@ -4285,7 +4291,7 @@ _elm_gengrid_item_prepend(Eo *obj, Elm_Gengrid_Data *sd, const Elm_Gengrid_Item_
4285 if (!it) return NULL; 4291 if (!it) return NULL;
4286 4292
4287 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(it)); 4293 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(it));
4288 _item_position_update(sd->items, 0); 4294 _item_position_update(sd->items, 1);
4289 4295
4290 if (it->group) 4296 if (it->group)
4291 sd->group_items = eina_list_append(sd->group_items, it); 4297 sd->group_items = eina_list_append(sd->group_items, it);
@@ -4421,6 +4427,8 @@ _elm_gengrid_item_update(Eo *eo_item EINA_UNUSED, Elm_Gen_Item *it)
4421 _elm_gengrid_item_unrealize(it, EINA_TRUE); 4427 _elm_gengrid_item_unrealize(it, EINA_TRUE);
4422 _item_realize(it); 4428 _item_realize(it);
4423 _item_place(it, it->x, it->y); 4429 _item_place(it, it->x, it->y);
4430
4431 _elm_gengrid_item_index_update(it);
4424} 4432}
4425 4433
4426EOLIAN static void 4434EOLIAN static void