summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-11-03 19:14:04 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commit71d9948250e6a654eafea7ee83e4700caf0d7cf3 (patch)
tree6295ce965f61eee6cd15e4534b1aa96664685519
parent86d7ec80e0a2025c643b6ae60c9575a6c2410bcc (diff)
elm: Create iteration by node with segarray
-rw-r--r--src/lib/elementary/efl_ui_list.c26
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c28
-rw-r--r--src/lib/elementary/efl_ui_list_private.h6
-rw-r--r--src/lib/elementary/efl_ui_list_segarray.c17
-rw-r--r--src/lib/elementary/efl_ui_list_segarray.h4
5 files changed, 49 insertions, 32 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 9c13eff014..b0e055e47c 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -64,7 +64,7 @@ _horiz(Efl_Orient dir)
64EOLIAN static void 64EOLIAN static void
65_efl_ui_list_pan_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_List_Pan_Data *psd) 65_efl_ui_list_pan_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_List_Pan_Data *psd)
66{ 66{
67 DBG(""); 67 //DBG("");
68 /* if (pd->recalc) return; */ 68 /* if (pd->recalc) return; */
69 69
70 /* _efl_ui_list_custom_layout(obj); */ 70 /* _efl_ui_list_custom_layout(obj); */
@@ -235,8 +235,8 @@ _long_press_cb(void *data)
235 235
236 item->long_timer = NULL; 236 item->long_timer = NULL;
237 item->longpressed = EINA_TRUE; 237 item->longpressed = EINA_TRUE;
238 if (item->layout) 238 if (item->item.layout)
239 efl_event_callback_legacy_call(item->layout, EFL_UI_EVENT_LONGPRESSED, item); 239 efl_event_callback_legacy_call(item->item.layout, EFL_UI_EVENT_LONGPRESSED, item);
240 240
241 return ECORE_CALLBACK_CANCEL; 241 return ECORE_CALLBACK_CANCEL;
242} 242}
@@ -352,7 +352,7 @@ _item_style_property_then(void * data, Efl_Event const* event)
352 if (vtype == EINA_VALUE_TYPE_STRING || vtype == EINA_VALUE_TYPE_STRINGSHARE) 352 if (vtype == EINA_VALUE_TYPE_STRING || vtype == EINA_VALUE_TYPE_STRINGSHARE)
353 eina_value_get(value, &style); 353 eina_value_get(value, &style);
354 354
355 elm_object_style_set(item->layout, style); 355 elm_object_style_set(item->item.layout, style);
356} 356}
357 357
358static void 358static void
@@ -381,7 +381,7 @@ _efl_model_properties_changed_cb(void *data, const Efl_Event *event)
381 { 381 {
382 if (prop == sprop) 382 if (prop == sprop)
383 { 383 {
384 item->future = efl_model_property_get(item->model, sprop); 384 item->future = efl_model_property_get(item->item.children, sprop);
385 efl_future_then(item->future, &_item_selected_then, &_item_property_error, NULL, item); 385 efl_future_then(item->future, &_item_selected_then, &_item_property_error, NULL, item);
386 } 386 }
387 } 387 }
@@ -467,14 +467,14 @@ _layout_unrealize(Efl_Ui_List_Data *pd, Efl_Ui_List_Item *item)
467 /* TODO:calculate new min */ 467 /* TODO:calculate new min */
468 //_item_min_calc(pd, item, 0, 0); 468 //_item_min_calc(pd, item, 0, 0);
469 469
470 evt.child = item->model; 470 evt.child = item->item.children;
471 evt.layout = item->layout; 471 evt.layout = item->item.layout;
472 evt.index = item->index; 472 evt.index = item->item.index;
473 efl_event_callback_call(item->list, EFL_UI_LIST_EVENT_ITEM_UNREALIZED, &evt); 473 efl_event_callback_call(item->list, EFL_UI_LIST_EVENT_ITEM_UNREALIZED, &evt);
474 efl_ui_view_model_set(item->layout, NULL); 474 efl_ui_view_model_set(item->item.layout, NULL);
475 475
476 evas_object_hide(item->layout); 476 evas_object_hide(item->item.layout);
477 evas_object_move(item->layout, -9999, -9999); 477 evas_object_move(item->item.layout, -9999, -9999);
478} 478}
479 479
480/* static Efl_Ui_List_Item* */ 480/* static Efl_Ui_List_Item* */
@@ -1183,7 +1183,7 @@ _efl_ui_list_efl_access_selection_selected_child_get(Eo *obj EINA_UNUSED, Efl_Ui
1183 if(child_index < (int) eina_list_count(pd->selected_items)) 1183 if(child_index < (int) eina_list_count(pd->selected_items))
1184 { 1184 {
1185 Efl_Ui_List_Item* items = eina_list_nth(pd->selected_items, child_index); 1185 Efl_Ui_List_Item* items = eina_list_nth(pd->selected_items, child_index);
1186 return items[child_index].layout; 1186 return items[child_index].item.layout;
1187 } 1187 }
1188 else 1188 else
1189 return NULL; 1189 return NULL;
@@ -1452,7 +1452,7 @@ _layout(Efl_Ui_List_Data *pd)
1452 if (!pd->model) 1452 if (!pd->model)
1453 return; 1453 return;
1454 1454
1455 Eina_Accessor* accessor = efl_ui_list_segarray_accessor_get(&pd->segarray); 1455 Eina_Accessor* accessor = efl_ui_list_segarray_node_accessor_get(&pd->segarray);
1456 1456
1457 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,
1458 efl_ui_list_segarray_count(&pd->segarray), accessor); 1458 efl_ui_list_segarray_count(&pd->segarray), accessor);
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index 03c8ec1726..6298ecdfdc 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -7,6 +7,7 @@
7#include <assert.h> 7#include <assert.h>
8 8
9#include "elm_priv.h" 9#include "elm_priv.h"
10#include "efl_ui_list_segarray.h"
10 11
11#undef DBG 12#undef DBG
12#define DBG(...) do { \ 13#define DBG(...) do { \
@@ -218,11 +219,12 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_model_set(Eo *obj EINA_UNUSED
218EOLIAN static void 219EOLIAN static void
219_efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do 220_efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
220 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd 221 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd
221 , Efl_Ui_List_Model *modeler, int first, int count, Eina_Accessor *items) 222 , Efl_Ui_List_Model *modeler, int first, int count, Eina_Accessor *nodes)
222{ 223{
223 Efl_Ui_List_LayoutItem* layout_item; 224 Efl_Ui_List_LayoutItem* layout_item;
225 Efl_Ui_List_SegArray_Node* items_node;
224 Efl_Ui_List_Precise_Layouter_Size* size; 226 Efl_Ui_List_Precise_Layouter_Size* size;
225 int i = 0; 227 int i = 0, j = 0;
226 Eina_Bool horiz = EINA_FALSE/*_horiz(pd->orient)*/, zeroweight = EINA_FALSE; 228 Eina_Bool horiz = EINA_FALSE/*_horiz(pd->orient)*/, zeroweight = EINA_FALSE;
227 Evas_Coord ow, oh, want, minw, minh, scr_x, scr_y; 229 Evas_Coord ow, oh, want, minw, minh, scr_x, scr_y;
228 int boxx, boxy, boxw, boxh, length, /*pad, */extra = 0, rounding = 0; 230 int boxx, boxy, boxw, boxh, length, /*pad, */extra = 0, rounding = 0;
@@ -231,25 +233,29 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
231 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE }; 233 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE };
232 234
233 DBG("layout_do first %d count %d", first, count); 235 DBG("layout_do first %d count %d", first, count);
234 EINA_SAFETY_ON_NULL_RETURN(items); 236 /* EINA_SAFETY_ON_NULL_RETURN(items); */
235 237
236 _initilize(obj, pd, modeler); 238 _initilize(obj, pd, modeler);
237 239
238 // cache size of new items 240 // cache size of new items
239 EINA_ACCESSOR_FOREACH(items, i, layout_item) 241 EINA_ACCESSOR_FOREACH(nodes, i, items_node)
240 { 242 {
243 DBG("node first %d", items_node->first);
244 for(j = 0; j != items_node->length; ++j)
245 {
246 layout_item = items_node->pointers[j];
247
241 size = eina_hash_find(pd->size_information, &layout_item); 248 size = eina_hash_find(pd->size_information, &layout_item);
242// DBG("size %p", size);
243 if(!size) 249 if(!size)
244 { 250 {
245 if(!layout_item->layout) 251 if(!layout_item->layout)
246 { 252 {
247// DBG("no layout, realizing"); 253 DBG("no layout, realizing");
248 efl_ui_list_model_realize(modeler, layout_item); 254 efl_ui_list_model_realize(modeler, layout_item);
249 } 255 }
250 else 256 else
251 { 257 {
252// DBG("already realized"); 258 DBG("already realized");
253 /* if(!layout_item->layout) */ 259 /* if(!layout_item->layout) */
254 /* { */ 260 /* { */
255 /* // error */ 261 /* // error */
@@ -270,6 +276,7 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
270 cb_data->size = size; 276 cb_data->size = size;
271 evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data); 277 evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data);
272 } 278 }
279 }
273 } 280 }
274 281
275 evas_object_geometry_get(modeler, &boxx, &boxy, &boxw, &boxh); 282 evas_object_geometry_get(modeler, &boxx, &boxy, &boxw, &boxh);
@@ -375,8 +382,12 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
375/* cur_pos += average_item_size * pd->realized.start; */ 382/* cur_pos += average_item_size * pd->realized.start; */
376/* // scan all items, get their properties, calculate total weight & min size */ 383/* // scan all items, get their properties, calculate total weight & min size */
377 // cache size of new items 384 // cache size of new items
378 EINA_ACCESSOR_FOREACH(items, i, layout_item) 385 /* EINA_ACCESSOR_FOREACH(items, i, layout_item) */
386 EINA_ACCESSOR_FOREACH(nodes, i, items_node)
379 { 387 {
388 for(j = 0; j != items_node->length;++j)
389 {
390 layout_item = items_node->pointers[j];
380 double cx, cy, cw, ch, x, y, w, h; 391 double cx, cy, cw, ch, x, y, w, h;
381 double align[2]; 392 double align[2];
382 int item_pad[4]; 393 int item_pad[4];
@@ -496,6 +507,7 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
496/* // printf("obj=%d currpos=%.2f moved to X=%.2f, Y=%.2f average_item_size %d\n", litem->index, cur_pos, x, y */ 507/* // printf("obj=%d currpos=%.2f moved to X=%.2f, Y=%.2f average_item_size %d\n", litem->index, cur_pos, x, y */
497/* // , eina_inarray_count(&pd->items.array) ? (/\*horz*\/ EINA_FALSE ? pd->realized.w : pd->realized.h) / eina_inarray_count(&pd->items.array) : AVERAGE_SIZE_INIT); */ 508/* // , eina_inarray_count(&pd->items.array) ? (/\*horz*\/ EINA_FALSE ? pd->realized.w : pd->realized.h) / eina_inarray_count(&pd->items.array) : AVERAGE_SIZE_INIT); */
498 } 509 }
510 }
499 } 511 }
500} 512}
501 513
diff --git a/src/lib/elementary/efl_ui_list_private.h b/src/lib/elementary/efl_ui_list_private.h
index be88bf34d1..7c4d2541ea 100644
--- a/src/lib/elementary/efl_ui_list_private.h
+++ b/src/lib/elementary/efl_ui_list_private.h
@@ -17,11 +17,9 @@ typedef struct _Efl_Ui_List_Data Efl_Ui_List_Data;
17 17
18struct _Efl_Ui_List_Item 18struct _Efl_Ui_List_Item
19{ 19{
20 Efl_Ui_List *list; 20 Efl_Ui_List_LayoutItem item;
21 Efl_Model *model;
22 Efl_Ui_Layout *layout;
23 Efl_Future *future; 21 Efl_Future *future;
24 unsigned int index; 22 Efl_Ui_List *list;
25 // Evas_Coord x, y, minw, minh, w, h; 23 // Evas_Coord x, y, minw, minh, w, h;
26 // // double h, v, wx, wy; 24 // // double h, v, wx, wy;
27 // double wx, wy; 25 // double wx, wy;
diff --git a/src/lib/elementary/efl_ui_list_segarray.c b/src/lib/elementary/efl_ui_list_segarray.c
index dcdf61026f..fced099e52 100644
--- a/src/lib/elementary/efl_ui_list_segarray.c
+++ b/src/lib/elementary/efl_ui_list_segarray.c
@@ -92,8 +92,8 @@ void efl_ui_list_segarray_setup(Efl_Ui_List_SegArray* segarray, //int member_siz
92static Efl_Ui_List_Item* _create_item(Efl_Model* model, unsigned int index) 92static Efl_Ui_List_Item* _create_item(Efl_Model* model, unsigned int index)
93{ 93{
94 Efl_Ui_List_Item* item = calloc(1, sizeof(Efl_Ui_List_Item)); 94 Efl_Ui_List_Item* item = calloc(1, sizeof(Efl_Ui_List_Item));
95 item->model = model; 95 item->item.children = model;
96 item->index = index; 96 item->item.index = index;
97 return item; 97 return item;
98} 98}
99 99
@@ -234,7 +234,7 @@ _efl_ui_list_segarray_node_accessor_get_at(Efl_Ui_List_Segarray_Node_Accessor* a
234 } 234 }
235 else 235 else
236 { 236 {
237 if(acc->current_index > idx && acc->current_node) 237 if(acc->current_index >= idx || !acc->current_node)
238 { 238 {
239 eina_iterator_free(acc->pre_iterator); 239 eina_iterator_free(acc->pre_iterator);
240 acc->pre_iterator = NULL; 240 acc->pre_iterator = NULL;
@@ -242,16 +242,19 @@ _efl_ui_list_segarray_node_accessor_get_at(Efl_Ui_List_Segarray_Node_Accessor* a
242 acc->current_index = -1; 242 acc->current_index = -1;
243 } 243 }
244 244
245 if(!acc->pre_iterator) // && acc->current_index <= idx 245 if(!acc->pre_iterator)
246 acc->pre_iterator = eina_rbtree_iterator_prefix((void*)acc->segarray->root); 246 acc->pre_iterator = eina_rbtree_iterator_infix((void*)acc->segarray->root);
247 247
248 248 for(;acc->current_index != idx;++acc->current_index)
249 for(;acc->current_index < idx;++acc->current_index) 249 {
250 DBG("for current_index: %d idx: %d", acc->current_index, idx);
250 if(!eina_iterator_next(acc->pre_iterator, (void**)&acc->current_node)) 251 if(!eina_iterator_next(acc->pre_iterator, (void**)&acc->current_node))
251 { 252 {
252 --acc->current_index; 253 --acc->current_index;
253 return EINA_FALSE; 254 return EINA_FALSE;
254 } 255 }
256 }
257 DBG("out of loop");
255 (*data) = acc->current_node; 258 (*data) = acc->current_node;
256 return EINA_TRUE; 259 return EINA_TRUE;
257 } 260 }
diff --git a/src/lib/elementary/efl_ui_list_segarray.h b/src/lib/elementary/efl_ui_list_segarray.h
index 904151499d..630593c2e5 100644
--- a/src/lib/elementary/efl_ui_list_segarray.h
+++ b/src/lib/elementary/efl_ui_list_segarray.h
@@ -3,6 +3,8 @@
3 3
4#include "efl_ui_list_segarray.h" 4#include "efl_ui_list_segarray.h"
5 5
6typedef struct _Efl_Ui_List_Item Efl_Ui_List_Item;
7
6typedef struct _Efl_Ui_List_SegArray_Node 8typedef struct _Efl_Ui_List_SegArray_Node
7{ 9{
8 EINA_RBTREE; 10 EINA_RBTREE;
@@ -27,6 +29,8 @@ typedef struct _Efl_Ui_List_SegArray
27 29
28Eina_Accessor* efl_ui_list_segarray_accessor_get(Efl_Ui_List_SegArray* segarray); 30Eina_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); 31Eina_Accessor* efl_ui_list_segarray_node_accessor_get(Efl_Ui_List_SegArray* segarray);
32Efl_Ui_List_SegArray_Node* efl_ui_list_segarray_item_node_get(Efl_Ui_List_SegArray* segarray,
33 Efl_Ui_List_Item* item);
30void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int first, Eina_Accessor* accessor); 34void efl_ui_list_segarray_insert_accessor(Efl_Ui_List_SegArray* segarray, int first, Eina_Accessor* accessor);
31int efl_ui_list_segarray_count(Efl_Ui_List_SegArray const* segarray); 35int efl_ui_list_segarray_count(Efl_Ui_List_SegArray const* segarray);
32void efl_ui_list_segarray_setup(Efl_Ui_List_SegArray* segarray, //int member_size, 36void efl_ui_list_segarray_setup(Efl_Ui_List_SegArray* segarray, //int member_size,