summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-10-27 19:42:17 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commit236bee625afe63eaed56aed5803ecd715b1608a1 (patch)
tree4c75aa554e33793e9bfd38320a41125438cb0284
parentde3aab9aa8275a81d1cf53c6ae92a8f5a3b5d3fe (diff)
Elm: efl_ui_list model set/unset update itens
-rw-r--r--src/lib/elementary/efl_ui_list.c19
-rw-r--r--src/lib/elementary/efl_ui_list.eo1
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c54
3 files changed, 43 insertions, 31 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 31ea811347..9c13eff014 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -325,7 +325,6 @@ _count_then(void * data, Efl_Event const* event)
325 int *count = ((Efl_Future_Event_Success*)event->info)->value; 325 int *count = ((Efl_Future_Event_Success*)event->info)->value;
326 326
327 pd->item_count = *count; 327 pd->item_count = *count;
328 printf("item count %d\n", pd->item_count);
329 pd->count_future = NULL; 328 pd->count_future = NULL;
330 329
331 _layout(pd); 330 _layout(pd);
@@ -1038,6 +1037,7 @@ _efl_ui_list_efl_object_finalize(Eo *obj, Efl_Ui_List_Data *pd)
1038 if(!pd->relayout) 1037 if(!pd->relayout)
1039 { 1038 {
1040 pd->relayout = efl_add(EFL_UI_LIST_PRECISE_LAYOUTER_CLASS, obj); 1039 pd->relayout = efl_add(EFL_UI_LIST_PRECISE_LAYOUTER_CLASS, obj);
1040 efl_ui_list_relayout_model_set(pd->relayout, pd->model);
1041 } 1041 }
1042 return obj; 1042 return obj;
1043} 1043}
@@ -1093,9 +1093,6 @@ _efl_ui_list_layout_factory_set(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd, Efl_U
1093EOLIAN static void 1093EOLIAN static void
1094_efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *model) 1094_efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *model)
1095{ 1095{
1096 if (pd->relayout)
1097 efl_ui_list_relayout_model_set(pd->relayout, model);
1098
1099 if (pd->model == model) 1096 if (pd->model == model)
1100 return; 1097 return;
1101 1098
@@ -1109,7 +1106,8 @@ _efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *mod
1109 { 1106 {
1110 /* efl_event_callback_del(pd->model, EFL_MODEL_EVENT_CHILD_ADDED, _child_added_cb, obj); */ 1107 /* efl_event_callback_del(pd->model, EFL_MODEL_EVENT_CHILD_ADDED, _child_added_cb, obj); */
1111 /* efl_event_callback_del(pd->model, EFL_MODEL_EVENT_CHILD_REMOVED, _child_removed_cb, obj); */ 1108 /* efl_event_callback_del(pd->model, EFL_MODEL_EVENT_CHILD_REMOVED, _child_removed_cb, obj); */
1112 //TODO: SegArray Clear 1109 //TODO: FIXME: XXX: SegArray Clear
1110 efl_ui_list_segarray_setup(&pd->segarray, 32);
1113 efl_unref(pd->model); 1111 efl_unref(pd->model);
1114 pd->model = NULL; 1112 pd->model = NULL;
1115 pd->item_count = 0; 1113 pd->item_count = 0;
@@ -1128,6 +1126,9 @@ _efl_ui_list_efl_ui_view_model_set(Eo *obj, Efl_Ui_List_Data *pd, Efl_Model *mod
1128 efl_future_then(pd->count_future, &_count_then, &_count_error, NULL, pd); 1126 efl_future_then(pd->count_future, &_count_then, &_count_error, NULL, pd);
1129 } 1127 }
1130 1128
1129 if (pd->relayout)
1130 efl_ui_list_relayout_model_set(pd->relayout, model);
1131
1131 evas_object_smart_changed(pd->obj); 1132 evas_object_smart_changed(pd->obj);
1132} 1133}
1133 1134
@@ -1448,6 +1449,9 @@ _efl_ui_list_relayout_get(Eo *obj EINA_UNUSED, Efl_Ui_List_Data *pd EINA_UNUSED)
1448static void 1449static void
1449_layout(Efl_Ui_List_Data *pd) 1450_layout(Efl_Ui_List_Data *pd)
1450{ 1451{
1452 if (!pd->model)
1453 return;
1454
1451 Eina_Accessor* accessor = efl_ui_list_segarray_accessor_get(&pd->segarray); 1455 Eina_Accessor* accessor = efl_ui_list_segarray_accessor_get(&pd->segarray);
1452 1456
1453 efl_ui_list_relayout_layout_do(pd->relayout, pd->obj, pd->segarray_first, 1457 efl_ui_list_relayout_layout_do(pd->relayout, pd->obj, pd->segarray_first,
@@ -1464,9 +1468,9 @@ _children_slice_then(void * data, Efl_Event const* event)
1464 1468
1465 pd->segarray_first = pd->outstanding_slice.slice_start; 1469 pd->segarray_first = pd->outstanding_slice.slice_start;
1466 pd->outstanding_slice.slice_start = pd->outstanding_slice.slice_count = 0; 1470 pd->outstanding_slice.slice_start = pd->outstanding_slice.slice_count = 0;
1471 pd->slice_future = NULL;
1467} 1472}
1468 1473
1469
1470/* EFL UI LIST MODEL INTERFACE */ 1474/* EFL UI LIST MODEL INTERFACE */
1471EOLIAN static Eina_Size2D 1475EOLIAN static Eina_Size2D
1472_efl_ui_list_efl_ui_list_model_min_size_get(Eo *obj, Efl_Ui_List_Data *pd) 1476_efl_ui_list_efl_ui_list_model_min_size_get(Eo *obj, Efl_Ui_List_Data *pd)
@@ -1514,6 +1518,7 @@ _efl_ui_list_efl_ui_list_model_unrealize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_L
1514 EINA_SAFETY_ON_NULL_RETURN(item->layout); 1518 EINA_SAFETY_ON_NULL_RETURN(item->layout);
1515 1519
1516 evas_object_hide(item->layout); 1520 evas_object_hide(item->layout);
1521 evas_object_move(item->layout, -9999, -9999);
1517 1522
1518 evt.child = item->children; 1523 evt.child = item->children;
1519 evt.layout = item->layout; 1524 evt.layout = item->layout;
@@ -1528,7 +1533,7 @@ _efl_ui_list_efl_ui_list_model_unrealize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_L
1528EOLIAN static void 1533EOLIAN static void
1529_efl_ui_list_efl_ui_list_model_load_range_set(Eo* obj, Efl_Ui_List_Data* pd, int first, int count) 1534_efl_ui_list_efl_ui_list_model_load_range_set(Eo* obj, Efl_Ui_List_Data* pd, int first, int count)
1530{ 1535{
1531 // slice 1536 //FIXME?? slice cancel??
1532 if(!pd->slice_future) 1537 if(!pd->slice_future)
1533 { 1538 {
1534 pd->slice_future = efl_model_children_slice_get(pd->model, first, count); 1539 pd->slice_future = efl_model_children_slice_get(pd->model, first, count);
diff --git a/src/lib/elementary/efl_ui_list.eo b/src/lib/elementary/efl_ui_list.eo
index 749b182342..776d36717f 100644
--- a/src/lib/elementary/efl_ui_list.eo
+++ b/src/lib/elementary/efl_ui_list.eo
@@ -71,6 +71,7 @@ class Efl.Ui.List (Efl.Ui.Layout, Efl.Ui.View, Elm.Interface_Scrollable,
71 71
72 Efl.Ui.List.Model.load_range { set;} 72 Efl.Ui.List.Model.load_range { set;}
73 Efl.Ui.List.Model.realize; 73 Efl.Ui.List.Model.realize;
74 Efl.Ui.List.Model.unrealize;
74 Efl.Ui.List.Model.size { get; } 75 Efl.Ui.List.Model.size { get; }
75 Efl.Ui.List.Model.min_size { get; set; } 76 Efl.Ui.List.Model.min_size { get; set; }
76 77
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index f01eb863c0..03c8ec1726 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -24,6 +24,7 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Data
24 Eina_Hash* size_information; 24 Eina_Hash* size_information;
25 Eina_Size2D min; 25 Eina_Size2D min;
26 Efl_Model* model; 26 Efl_Model* model;
27 Efl_Ui_List_Model *modeler;
27 unsigned int count_total; 28 unsigned int count_total;
28 Efl_Future *count_future; 29 Efl_Future *count_future;
29} Efl_Ui_List_Precise_Layouter_Data; 30} Efl_Ui_List_Precise_Layouter_Data;
@@ -56,7 +57,6 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_U
56 min.w += pad[0] + pad[1]; 57 min.w += pad[0] + pad[1];
57 min.h += pad[2] + pad[3]; 58 min.h += pad[2] + pad[3];
58 59
59// DBG("size information for item %d width %d height %d", i, size->min.w, size->min.h);
60// if(_horiz(pd->orient)) 60// if(_horiz(pd->orient))
61// { 61// {
62// pdp->realized.w -= item->minw; 62// pdp->realized.w -= item->minw;
@@ -87,18 +87,20 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_U
87 pd->min.w = min.w; 87 pd->min.w = min.w;
88 else if (pd->min.w == size->min.w) 88 else if (pd->min.w == size->min.w)
89 { 89 {
90 Efl_Ui_List_Precise_Layouter_Size *size_item;
91 Eina_Iterator *size_iterator;
92
90 pd->min.w = min.w; 93 pd->min.w = min.w;
91 /*EINA_INARRAY_FOREACH(&pd->items.array, it) //find new minimal width 94 size_iterator = eina_hash_iterator_data_new(pd->size_information);
95 EINA_ITERATOR_FOREACH(size_iterator, size_item)
92 { 96 {
93 litem = *it; 97 if (pd->min.w < size_item->min.w)
94 if (!litem) continue; 98 pd->min.w = size_item->min.w;
95 if (pd->realized.w < litem->minw)
96 pd->realized.w = litem->minw;
97 99
98 if (litem != item && litem->minw == item->minw) 100 if (size->min.w == size_item->min.w)
99 break; 101 break;
100 } 102 }
101 */ 103 eina_iterator_free(size_iterator);
102 } 104 }
103// } 105// }
104 106
@@ -139,40 +141,44 @@ _initilize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_Li
139 if(pd->initialized) 141 if(pd->initialized)
140 return; 142 return;
141 143
144 pd->modeler = modeler;
142 pd->initialized = EINA_TRUE; 145 pd->initialized = EINA_TRUE;
143 efl_ui_list_model_load_range_set(modeler, 0, 0); // load all 146 efl_ui_list_model_load_range_set(modeler, 0, 0); // load all
144 pd->size_information = eina_hash_pointer_new(&free);
145 pd->min.w = 0; 147 pd->min.w = 0;
146 pd->min.h = 0; 148 pd->min.h = 0;
147} 149}
148 150
149static Eina_Bool
150_size_clear_fn(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data EINA_UNUSED, void *fdata EINA_UNUSED)
151{
152 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data;
153 Efl_Ui_List_LayoutItem* layout_item = data;
154
155 cb_data = evas_object_event_callback_del(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change);
156 free(cb_data);
157}
158
159static void 151static void
160_finalize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd) 152_finalize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd)
161{ 153{
162 pd->initialized = EINA_FALSE; 154 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data;
155 Efl_Ui_List_LayoutItem *layout_item;
156 Eina_Iterator *item_iterator;
157 void *data;
163 158
164 eina_hash_foreach(pd->size_information, _size_clear_fn, pd); 159 item_iterator = eina_hash_iterator_key_new(pd->size_information);
160 while(eina_iterator_next(item_iterator, &data))
161 {
162 layout_item = *(Efl_Ui_List_LayoutItem **)data;
163 cb_data = evas_object_event_callback_del(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change);
164 efl_ui_list_model_unrealize(pd->modeler, layout_item);
165 free(cb_data);
166 }
167 eina_iterator_free(item_iterator);
165 168
166 eina_hash_free(pd->size_information); 169 eina_hash_free_buckets(pd->size_information);
167 pd->size_information = NULL; 170 pd->modeler = NULL;
168 pd->min.w = 0; 171 pd->min.w = 0;
169 pd->min.h = 0; 172 pd->min.h = 0;
173
174 pd->initialized = EINA_FALSE;
170} 175}
171 176
172EOLIAN static Efl_Object * 177EOLIAN static Efl_Object *
173_efl_ui_list_precise_layouter_efl_object_constructor(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd) 178_efl_ui_list_precise_layouter_efl_object_constructor(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd)
174{ 179{
175 obj = efl_constructor(efl_super(obj, MY_CLASS)); 180 obj = efl_constructor(efl_super(obj, MY_CLASS));
181 pd->size_information = eina_hash_pointer_new(&free);
176 pd->initialized = EINA_FALSE; 182 pd->initialized = EINA_FALSE;
177 pd->count_future = NULL; 183 pd->count_future = NULL;
178 184
@@ -195,8 +201,8 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_model_set(Eo *obj EINA_UNUSED
195 201
196 if (pd->model) 202 if (pd->model)
197 { 203 {
198 efl_unref(pd->model);
199 _finalize(obj, pd); 204 _finalize(obj, pd);
205 efl_unref(pd->model);
200 pd->model = NULL; 206 pd->model = NULL;
201 } 207 }
202 208