summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-10-30 18:25:16 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commit86d7ec80e0a2025c643b6ae60c9575a6c2410bcc (patch)
tree35161c16366710137e55695de9b3c3cd7e2a97f7
parent765cdd9e2413c6e7673a6178d3a3bee954e7096b (diff)
elm: Add group iterator to segarray
-rw-r--r--src/lib/elementary/efl_ui_list_segarray.c109
-rw-r--r--src/lib/elementary/efl_ui_list_segarray.h3
2 files changed, 97 insertions, 15 deletions
diff --git a/src/lib/elementary/efl_ui_list_segarray.c b/src/lib/elementary/efl_ui_list_segarray.c
index 71b61971bd..dcdf61026f 100644
--- a/src/lib/elementary/efl_ui_list_segarray.c
+++ b/src/lib/elementary/efl_ui_list_segarray.c
@@ -101,20 +101,6 @@ void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int fi
101{ 101{
102 int i; 102 int i;
103 Efl_Model* children; 103 Efl_Model* children;
104 Efl_Ui_List_SegArray_Node *first_node = NULL/*, *last_node = NULL*/;
105 int array_first = 0;
106
107 if(segarray->root)
108 {
109 {
110 Eina_Iterator* pre_iterator = eina_rbtree_iterator_prefix(EINA_RBTREE_GET(segarray->root));
111 if(!eina_iterator_next(pre_iterator, (void**)&first_node))
112 first_node = NULL;
113 else
114 array_first = first_node->first;
115 eina_iterator_free(pre_iterator);
116 }
117 }
118 104
119 EINA_ACCESSOR_FOREACH(accessor, i, children) 105 EINA_ACCESSOR_FOREACH(accessor, i, children)
120 { 106 {
@@ -228,3 +214,98 @@ Eina_Accessor* efl_ui_list_segarray_accessor_get(Efl_Ui_List_SegArray* segarray)
228 _efl_ui_list_segarray_accessor_setup(acc, segarray); 214 _efl_ui_list_segarray_accessor_setup(acc, segarray);
229 return &acc->vtable; 215 return &acc->vtable;
230} 216}
217
218typedef struct _Efl_Ui_List_Segarray_Node_Accessor
219{
220 Eina_Accessor vtable;
221 Efl_Ui_List_SegArray* segarray;
222 Eina_Iterator* pre_iterator;
223 Efl_Ui_List_SegArray_Node* current_node;
224 int current_index;
225} Efl_Ui_List_Segarray_Node_Accessor;
226
227static Eina_Bool
228_efl_ui_list_segarray_node_accessor_get_at(Efl_Ui_List_Segarray_Node_Accessor* acc,
229 int idx, void** data)
230{
231 if(idx == acc->current_index && acc->current_node)
232 {
233 (*data) = acc->current_node;
234 }
235 else
236 {
237 if(acc->current_index > idx && acc->current_node)
238 {
239 eina_iterator_free(acc->pre_iterator);
240 acc->pre_iterator = NULL;
241 acc->current_node = NULL;
242 acc->current_index = -1;
243 }
244
245 if(!acc->pre_iterator) // && acc->current_index <= idx
246 acc->pre_iterator = eina_rbtree_iterator_prefix((void*)acc->segarray->root);
247
248
249 for(;acc->current_index < idx;++acc->current_index)
250 if(!eina_iterator_next(acc->pre_iterator, (void**)&acc->current_node))
251 {
252 --acc->current_index;
253 return EINA_FALSE;
254 }
255 (*data) = acc->current_node;
256 return EINA_TRUE;
257 }
258 return EINA_FALSE;
259}
260
261static void*
262_efl_ui_list_segarray_node_accessor_get_container(Efl_Ui_List_Segarray_Node_Accessor* acc EINA_UNUSED)
263{
264 return NULL;
265}
266
267static void
268_efl_ui_list_segarray_node_accessor_free(Efl_Ui_List_Segarray_Node_Accessor* acc EINA_UNUSED)
269{
270 free(acc);
271}
272
273static void
274_efl_ui_list_segarray_node_accessor_lock(Efl_Ui_List_Segarray_Node_Accessor* acc EINA_UNUSED)
275{
276}
277
278static void
279_efl_ui_list_segarray_node_accessor_unlock(Efl_Ui_List_Segarray_Node_Accessor* acc EINA_UNUSED)
280{
281}
282
283static Eina_Accessor*
284_efl_ui_list_segarray_node_accessor_clone(Efl_Ui_List_Segarray_Node_Accessor* acc EINA_UNUSED)
285{
286 return &acc->vtable;
287}
288
289static void
290_efl_ui_list_segarray_node_accessor_setup(Efl_Ui_List_Segarray_Node_Accessor* acc, Efl_Ui_List_SegArray* segarray)
291{
292 EINA_MAGIC_SET(&acc->vtable, EINA_MAGIC_ACCESSOR);
293 acc->vtable.version = EINA_ACCESSOR_VERSION;
294 acc->vtable.get_at = FUNC_ACCESSOR_GET_AT(_efl_ui_list_segarray_node_accessor_get_at);
295 acc->vtable.get_container = FUNC_ACCESSOR_GET_CONTAINER(_efl_ui_list_segarray_node_accessor_get_container);
296 acc->vtable.free = FUNC_ACCESSOR_FREE(_efl_ui_list_segarray_node_accessor_free);
297 acc->vtable.lock = FUNC_ACCESSOR_LOCK(_efl_ui_list_segarray_node_accessor_lock);
298 acc->vtable.unlock = FUNC_ACCESSOR_LOCK(_efl_ui_list_segarray_node_accessor_unlock);
299 acc->vtable.clone = FUNC_ACCESSOR_CLONE(_efl_ui_list_segarray_node_accessor_clone);
300 acc->segarray = segarray;
301 acc->pre_iterator = NULL;
302 acc->current_index = -1;
303 acc->current_node = NULL;
304}
305
306Eina_Accessor* efl_ui_list_segarray_node_accessor_get(Efl_Ui_List_SegArray* segarray)
307{
308 Efl_Ui_List_Segarray_Node_Accessor* acc = calloc(1, sizeof(Efl_Ui_List_Segarray_Node_Accessor));
309 _efl_ui_list_segarray_node_accessor_setup(acc, segarray);
310 return &acc->vtable;
311}
diff --git a/src/lib/elementary/efl_ui_list_segarray.h b/src/lib/elementary/efl_ui_list_segarray.h
index c161ee3c2d..904151499d 100644
--- a/src/lib/elementary/efl_ui_list_segarray.h
+++ b/src/lib/elementary/efl_ui_list_segarray.h
@@ -11,7 +11,7 @@ typedef struct _Efl_Ui_List_SegArray_Node
11 int max; 11 int max;
12 int first; 12 int first;
13 13
14 // Eina_Position2D initial_position; 14 void* layout_data;
15 15
16 Efl_Ui_List_Item* pointers[0]; 16 Efl_Ui_List_Item* pointers[0];
17} Efl_Ui_List_SegArray_Node; 17} Efl_Ui_List_SegArray_Node;
@@ -26,6 +26,7 @@ typedef struct _Efl_Ui_List_SegArray
26} Efl_Ui_List_SegArray; 26} Efl_Ui_List_SegArray;
27 27
28Eina_Accessor* efl_ui_list_segarray_accessor_get(Efl_Ui_List_SegArray* segarray); 28Eina_Accessor* efl_ui_list_segarray_accessor_get(Efl_Ui_List_SegArray* segarray);
29Eina_Accessor* efl_ui_list_segarray_node_accessor_get(Efl_Ui_List_SegArray* segarray);
29void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int first, Eina_Accessor* accessor); 30void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int first, Eina_Accessor* accessor);
30int efl_ui_list_segarray_count(Efl_Ui_List_SegArray const* segarray); 31int efl_ui_list_segarray_count(Efl_Ui_List_SegArray const* segarray);
31void efl_ui_list_segarray_setup(Efl_Ui_List_SegArray* segarray, //int member_size, 32void efl_ui_list_segarray_setup(Efl_Ui_List_SegArray* segarray, //int member_size,