diff options
author | SangHyeon Lee <dltkdgus1764@gmail.com> | 2015-06-25 16:35:44 +0200 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-06-25 17:24:08 +0200 |
commit | 80c8cfb7a244d770102b9411f84cfc8e84192190 (patch) | |
tree | e35a48675a9c0b2c959f5f746e3feb503831d85d | |
parent | 3373d6f12ac0eefbee34b1f0ecbd368e60ce6d65 (diff) | |
download | elementary-80c8cfb7a244d770102b9411f84cfc8e84192190.tar.gz |
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.c | 18 |
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, tch = items_row * wsd->item_height; alignh = (vh - tch) * wsd->align_y; item_pos = items_row * cx + cy + 1; - if (item_pos != it->position) + if (item_pos != it->position && !it->position_update) { it->position = item_pos; it->position_update = EINA_TRUE; @@ -1540,7 +1540,7 @@ _item_place(Elm_Gen_Item *it, tcw = items_col * wsd->item_width; alignw = (vw - tcw) * wsd->align_x; item_pos = cx + items_col * cy + 1; - if (item_pos != it->position) + if (item_pos != it->position && !it->position_update) { it->position = item_pos; it->position_update = EINA_TRUE; @@ -1604,7 +1604,10 @@ _item_place(Elm_Gen_Item *it, { _item_realize(it); if (!was_realized) - evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, EO_OBJ(it)); + { + _elm_gengrid_item_index_update(it); + evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, EO_OBJ(it)); + } if (it->parent) { if (wsd->horizontal) @@ -1798,7 +1801,10 @@ _group_item_place(Elm_Gengrid_Pan_Data *psd) { _item_realize(it); if (!was_realized) - evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, EO_OBJ(it)); + { + _elm_gengrid_item_index_update(it); + evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, EO_OBJ(it)); + } evas_object_move (VIEW(it), GG_IT(it)->gx, GG_IT(it)->gy); @@ -4285,7 +4291,7 @@ _elm_gengrid_item_prepend(Eo *obj, Elm_Gengrid_Data *sd, const Elm_Gengrid_Item_ if (!it) return NULL; sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(it)); - _item_position_update(sd->items, 0); + _item_position_update(sd->items, 1); if (it->group) 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) _elm_gengrid_item_unrealize(it, EINA_TRUE); _item_realize(it); _item_place(it, it->x, it->y); + + _elm_gengrid_item_index_update(it); } EOLIAN static void |