summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-11-09 18:20:23 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commitc3eaf3ca36faffbb75a951251b3e2d7774636b7c (patch)
tree3e620ba1f29497d602f07b2ae861f30faa0343e4
parent72e1f135924b06238464d52947e30793b7f118eb (diff)
elm: using segarray in relayout
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/efl_ui_list.c27
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c80
-rw-r--r--src/lib/elementary/efl_ui_list_relayout.eo5
4 files changed, 39 insertions, 74 deletions
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index 0f3df68246..2b0a4677eb 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -261,6 +261,7 @@ EAPI extern Elm_Version *elm_version;
261#include <elm_win.h> 261#include <elm_win.h>
262 262
263#ifdef EFL_EO_API_SUPPORT 263#ifdef EFL_EO_API_SUPPORT
264#include "efl_ui_list_segarray.h"
264# include <efl_config_global.eo.h> 265# include <efl_config_global.eo.h>
265# include <efl_ui_widget_part.eo.h> 266# include <efl_ui_widget_part.eo.h>
266# include <efl_ui_layout_part.eo.h> 267# include <efl_ui_layout_part.eo.h>
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index b99640d6a2..af0952c8bb 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -894,28 +894,12 @@ _efl_ui_list_elm_interface_scrollable_region_bring_in(Eo *obj, Efl_Ui_List_Data
894EOLIAN static void 894EOLIAN static void
895_efl_ui_list_efl_gfx_size_set(Eo *obj, Efl_Ui_List_Data *pd, Eina_Size2D size) 895_efl_ui_list_efl_gfx_size_set(Eo *obj, Efl_Ui_List_Data *pd, Eina_Size2D size)
896{ 896{
897 Evas_Coord oldw, oldh;
898 Eina_Bool load = EINA_FALSE;
899
900 DBG("w: %d h: %d", size.w, size.h); 897 DBG("w: %d h: %d", size.w, size.h);
901 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, size.w, size.h)) 898 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, size.w, size.h))
902 return; 899 return;
903 900
904 evas_object_geometry_get(obj, NULL, NULL, &oldw, &oldh);
905 efl_gfx_size_set(efl_super(obj, MY_CLASS), size);
906 evas_object_resize(pd->hit_rect, size.w, size.h); 901 evas_object_resize(pd->hit_rect, size.w, size.h);
907 902 efl_gfx_size_set(efl_super(obj, MY_CLASS), size);
908 if (_horiz(pd->orient))
909 {
910 if (size.w != oldw) load = EINA_TRUE;
911 }
912 else
913 {
914 if (size.h != oldh) load = EINA_TRUE;
915 }
916
917 /* if (load && _update_items(obj, pd)) */
918 /* return; */
919 903
920 evas_object_smart_changed(pd->obj); 904 evas_object_smart_changed(pd->obj);
921} 905}
@@ -1451,10 +1435,7 @@ _layout(Efl_Ui_List_Data *pd)
1451 if (!pd->model) 1435 if (!pd->model)
1452 return; 1436 return;
1453 1437
1454 Eina_Accessor* accessor = efl_ui_list_segarray_node_accessor_get(&pd->segarray); 1438 efl_ui_list_relayout_layout_do(pd->relayout, pd->obj, pd->segarray_first, &pd->segarray);
1455
1456 efl_ui_list_relayout_layout_do(pd->relayout, pd->obj, pd->segarray_first,
1457 efl_ui_list_segarray_count(&pd->segarray), accessor);
1458} 1439}
1459 1440
1460static void 1441static void
@@ -1493,7 +1474,7 @@ EOLIAN static Efl_Ui_List_LayoutItem *
1493_efl_ui_list_efl_ui_list_model_realize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_List_LayoutItem *item) 1474_efl_ui_list_efl_ui_list_model_realize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_List_LayoutItem *item)
1494{ 1475{
1495 Efl_Ui_List_Item_Event evt; 1476 Efl_Ui_List_Item_Event evt;
1496 DBG("model_realize"); 1477// DBG("model_realize");
1497 EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item); 1478 EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item);
1498 1479
1499 item->layout = efl_ui_factory_create(pd->factory, item->children, obj); 1480 item->layout = efl_ui_factory_create(pd->factory, item->children, obj);
@@ -1514,7 +1495,7 @@ EOLIAN static void
1514_efl_ui_list_efl_ui_list_model_unrealize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_List_LayoutItem *item) 1495_efl_ui_list_efl_ui_list_model_unrealize(Eo *obj, Efl_Ui_List_Data *pd, Efl_Ui_List_LayoutItem *item)
1515{ 1496{
1516 Efl_Ui_List_Item_Event evt; 1497 Efl_Ui_List_Item_Event evt;
1517 DBG("model_unrealize item:%p", item); 1498// DBG("model_unrealize item:%p", item);
1518 EINA_SAFETY_ON_NULL_RETURN(item->layout); 1499 EINA_SAFETY_ON_NULL_RETURN(item->layout);
1519 1500
1520 evas_object_hide(item->layout); 1501 evas_object_hide(item->layout);
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index 4ef0a20544..e1df0f1b3d 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -27,7 +27,7 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Data
27 Efl_Ui_List_Model *modeler; 27 Efl_Ui_List_Model *modeler;
28 Efl_Future *count_future; 28 Efl_Future *count_future;
29 Ecore_Job *calc_job; 29 Ecore_Job *calc_job;
30 Eina_Accessor *nodes; 30 Efl_Ui_List_SegArray *segarray;
31 int first; 31 int first;
32 unsigned int count; 32 unsigned int count;
33 unsigned int count_total; 33 unsigned int count_total;
@@ -51,7 +51,7 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Callback_Data
51 51
52 52
53static void _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *); 53static void _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *);
54static void _initilize(Eo *, Efl_Ui_List_Precise_Layouter_Data*, Efl_Ui_List_Model*); 54static void _initilize(Eo *, Efl_Ui_List_Precise_Layouter_Data*, Efl_Ui_List_Model*, Efl_Ui_List_SegArray*);
55static void _finalize(Eo *, Efl_Ui_List_Precise_Layouter_Data*); 55static void _finalize(Eo *, Efl_Ui_List_Precise_Layouter_Data*);
56 56
57static void 57static void
@@ -87,9 +87,11 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_LayoutItem* it
87 pd->min.w = min.w; 87 pd->min.w = min.w;
88 else if (pd->min.w == item->min.w) 88 else if (pd->min.w == item->min.w)
89 { 89 {
90 pd->min.w = min.w;
91 Efl_Ui_List_SegArray_Node *node; 90 Efl_Ui_List_SegArray_Node *node;
92 EINA_ACCESSOR_FOREACH(pd->nodes, i, node) 91 Eina_Accessor *nodes = efl_ui_list_segarray_node_accessor_get(pd->segarray);
92 pd->min.w = min.w;
93
94 EINA_ACCESSOR_FOREACH(nodes, i, node)
93 { 95 {
94 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = node->layout_data; 96 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = node->layout_data;
95 if (pd->min.w < nodedata->min.w) 97 if (pd->min.w < nodedata->min.w)
@@ -98,6 +100,7 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_LayoutItem* it
98 if (item->min.w == nodedata->min.w) 100 if (item->min.w == nodedata->min.w)
99 break; 101 break;
100 } 102 }
103 eina_accessor_free(nodes);
101 } 104 }
102 105
103 item->min.w = min.w; 106 item->min.w = min.w;
@@ -165,6 +168,7 @@ _on_item_size_hint_change(void *data, Evas *e EINA_UNUSED,
165 _item_min_calc(cb_data->pd, item, min, node); 168 _item_min_calc(cb_data->pd, item, min, node);
166 if (!nodedata->realized) 169 if (!nodedata->realized)
167 { 170 {
171 //DBG("item size change unrealize");
168 free(evas_object_event_callback_del(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change)); 172 free(evas_object_event_callback_del(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change));
169 efl_ui_list_model_unrealize(pd->modeler, item); 173 efl_ui_list_model_unrealize(pd->modeler, item);
170 } 174 }
@@ -182,13 +186,17 @@ _on_modeler_resize(void *data, Evas *e EINA_UNUSED,
182} 186}
183 187
184static void 188static void
185_initilize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_Model *modeler) 189_initilize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_Model *modeler, Efl_Ui_List_SegArray *segarray)
186{ 190{
187 if(pd->initialized) 191 if(pd->initialized)
188 return; 192 return;
189 193
190 pd->recalc = EINA_TRUE; 194 pd->recalc = EINA_TRUE;
191 pd->initialized = EINA_TRUE; 195 pd->initialized = EINA_TRUE;
196
197 pd->modeler = modeler;
198 pd->segarray = segarray;
199
192 evas_object_event_callback_add(modeler, EVAS_CALLBACK_RESIZE, _on_modeler_resize, pd); 200 evas_object_event_callback_add(modeler, EVAS_CALLBACK_RESIZE, _on_modeler_resize, pd);
193 efl_ui_list_model_load_range_set(modeler, 0, 0); // load all 201 efl_ui_list_model_load_range_set(modeler, 0, 0); // load all
194/* 202/*
@@ -293,18 +301,17 @@ _calc_range(Efl_Ui_List_Precise_Layouter_Data *pd)
293 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata; 301 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata;
294 int i; 302 int i;
295 303
296 DBG("calc_range");
297 elm_interface_scrollable_content_viewport_geometry_get 304 elm_interface_scrollable_content_viewport_geometry_get
298 (pd->modeler, NULL, NULL, &ow, &oh); 305 (pd->modeler, NULL, NULL, &ow, &oh);
299 elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y); 306 elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y);
300 307
308// DBG("CALC RANGE %d %d", ow, oh);
301 ch = 0; 309 ch = 0;
302 310 Eina_Accessor *nodes = efl_ui_list_segarray_node_accessor_get(pd->segarray);
303 EINA_ACCESSOR_FOREACH(pd->nodes, i, node) 311 EINA_ACCESSOR_FOREACH(nodes, i, node)
304 { 312 {
305 nodedata = node->layout_data; 313 nodedata = node->layout_data;
306 314// DBG("node %d h:%d ch:%d scr_y:%d oh:%d", node->first, nodedata->min.h, ch, scr_y, oh);
307 // DBG("node %d h:%d ch:%d scr_y:%d oh:%d", node->first, nodedata->min.h, ch, scr_y, oh);
308 if (!nodedata->min.h) 315 if (!nodedata->min.h)
309 continue; 316 continue;
310 317
@@ -315,6 +322,7 @@ _calc_range(Efl_Ui_List_Precise_Layouter_Data *pd)
315 322
316 ch += nodedata->min.h; 323 ch += nodedata->min.h;
317 } 324 }
325 eina_accessor_free(nodes);
318} 326}
319 327
320static void 328static void
@@ -328,14 +336,14 @@ _calc_size_job(void *data)
328 int i; 336 int i;
329 double start_time = ecore_time_get(); 337 double start_time = ecore_time_get();
330 338
331 DBG(" >>>>> CALC JOB <<<<<<< \n");
332 EINA_SAFETY_ON_NULL_RETURN(data); 339 EINA_SAFETY_ON_NULL_RETURN(data);
333 pd = efl_data_scope_get(obj, MY_CLASS); 340 pd = efl_data_scope_get(obj, MY_CLASS);
334 if (EINA_UNLIKELY(!pd)) return; 341 if (EINA_UNLIKELY(!pd)) return;
335 342
336 pd->recalc = EINA_FALSE; 343 pd->recalc = EINA_FALSE;
337 344
338 while (eina_accessor_data_get(pd->nodes, pd->calc_progress, (void **)&node)) 345 Eina_Accessor *nodes = efl_ui_list_segarray_node_accessor_get(pd->segarray);
346 while (eina_accessor_data_get(nodes, pd->calc_progress, (void **)&node))
339 { 347 {
340 pd->calc_progress++; 348 pd->calc_progress++;
341 if (!node->layout_data) 349 if (!node->layout_data)
@@ -344,7 +352,6 @@ _calc_size_job(void *data)
344 for (i = 0; i != node->length; ++i) 352 for (i = 0; i != node->length; ++i)
345 { 353 {
346 layout_item = (Efl_Ui_List_LayoutItem *)node->pointers[i]; 354 layout_item = (Efl_Ui_List_LayoutItem *)node->pointers[i];
347// DBG("layout_do first %d count %d", pd->first, pd->count);
348 EINA_SAFETY_ON_NULL_RETURN(layout_item); 355 EINA_SAFETY_ON_NULL_RETURN(layout_item);
349 356
350 // cache size of new items 357 // cache size of new items
@@ -352,18 +359,9 @@ _calc_size_job(void *data)
352 { 359 {
353 if (!layout_item->layout) 360 if (!layout_item->layout)
354 { 361 {
355 DBG("no layout, realizing"); 362 //DBG("no layout, realizing");
356 efl_ui_list_model_realize(pd->modeler, layout_item); 363 efl_ui_list_model_realize(pd->modeler, layout_item);
357 } 364 }
358 else
359 {
360 DBG("already realized");
361 /* if(!layout_item->layout) */
362 /* { */
363 /* // error */
364 /* continue; */
365 /* } */
366 }
367 365
368 min = efl_gfx_size_hint_combined_min_get(layout_item->layout); 366 min = efl_gfx_size_hint_combined_min_get(layout_item->layout);
369 if (min.w && min.h) 367 if (min.w && min.h)
@@ -383,13 +381,13 @@ _calc_size_job(void *data)
383 } 381 }
384 if ( (ecore_time_get() - start_time ) > 0.01 ) 382 if ( (ecore_time_get() - start_time ) > 0.01 )
385 { 383 {
386 DBG(" <><><> RECALC JOB SPLIT <><><> ");
387 ecore_job_del(pd->calc_job); 384 ecore_job_del(pd->calc_job);
388 pd->calc_job = ecore_job_add(_calc_size_job, obj); 385 pd->calc_job = ecore_job_add(_calc_size_job, obj);
389// _efl_ui_list_relayout_layout_do(pd); 386 eina_accessor_free(nodes);
390 return; 387 return;
391 } 388 }
392 } 389 }
390 eina_accessor_free(nodes);
393 pd->calc_progress = 0; 391 pd->calc_progress = 0;
394 pd->calc_job = NULL; 392 pd->calc_job = NULL;
395 393
@@ -525,7 +523,8 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
525 elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y); 523 elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y);
526 // scan all items, get their properties, calculate total weight & min size 524 // scan all items, get their properties, calculate total weight & min size
527 // cache size of new items 525 // cache size of new items
528 EINA_ACCESSOR_FOREACH(pd->nodes, i, items_node) 526 Eina_Accessor *nodes = efl_ui_list_segarray_node_accessor_get(pd->segarray);
527 EINA_ACCESSOR_FOREACH(nodes, i, items_node)
529 { 528 {
530 529
531 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = items_node->layout_data; 530 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = items_node->layout_data;
@@ -547,7 +546,7 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
547 546
548 if(layout_item->min.w && layout_item->min.h) 547 if(layout_item->min.w && layout_item->min.h)
549 { 548 {
550// DBG("size information for item %d width %d height %d", i, size->min.w, size->min.h); 549// DBG("size information for item %d width %d height %d", j, layout_item->min.w, layout_item->min.h);
551 550
552 assert(layout_item->layout != NULL); 551 assert(layout_item->layout != NULL);
553 efl_gfx_size_hint_weight_get(layout_item->layout, &weight_x, &weight_y); 552 efl_gfx_size_hint_weight_get(layout_item->layout, &weight_x, &weight_y);
@@ -645,44 +644,27 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
645 if (w > ow) w = ow; 644 if (w > ow) w = ow;
646 } 645 }
647 646
648// DBG("------- size_h:%d -- h:%.2f --- ", size->min.h, h); 647// DBG("------- x=%0.f, y=%0.f, w=%0.f, h=%0.f --- ", x, y, w, h);
649 evas_object_geometry_set(layout_item->layout, (x + 0 - scr_x), (y + 0 - scr_y), w, h); 648 evas_object_geometry_set(layout_item->layout, (x + 0 - scr_x), (y + 0 - scr_y), w, h);
650 649
651 /* layout_item->x = x; */ 650 /* layout_item->x = x; */
652 /* layout_item->y = y; */ 651 /* layout_item->y = y; */
653 } /* if (size) end */ 652 } /* if (size) end */
654 if (pd->calc_progress && i > pd->calc_progress)
655 return;
656 } 653 }
657 } /* EINA ACCESSOR FOREACH END */ 654 } /* EINA ACCESSOR FOREACH END */
658/* 655 eina_accessor_free(nodes);
659 if (!pd->calc_progress)
660 {
661 eina_accessor_free(pd->nodes);
662 pd->nodes = NULL;
663 }
664*/
665} 656}
666 657
667EOLIAN static void 658EOLIAN static void
668_efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do 659_efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
669 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd 660 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd
670 , Efl_Ui_List_Model *modeler, int first, int count, Eina_Accessor *nodes) 661 , Efl_Ui_List_Model *modeler, int first, Efl_Ui_List_SegArray *segarray)
671{ 662{
672 EINA_SAFETY_ON_NULL_RETURN(nodes); 663 _initilize(obj, pd, modeler, segarray);
673
674 _initilize(obj, pd, modeler);
675 664
676 pd->modeler = modeler;
677 pd->first = first; 665 pd->first = first;
678 pd->count = count;
679
680// if (pd->nodes)
681// eina_accessor_free(pd->nodes);
682// if (!pd->nodes)
683 pd->nodes = nodes;
684 666
685 if (pd->recalc) // || pd->count_total > pop) 667 if (pd->recalc)
686 { 668 {
687 // cache size of new items 669 // cache size of new items
688 pd->calc_progress = 0; 670 pd->calc_progress = 0;
diff --git a/src/lib/elementary/efl_ui_list_relayout.eo b/src/lib/elementary/efl_ui_list_relayout.eo
index b9d86d1c2c..94daa479d5 100644
--- a/src/lib/elementary/efl_ui_list_relayout.eo
+++ b/src/lib/elementary/efl_ui_list_relayout.eo
@@ -1,5 +1,7 @@
1import efl_ui_list_types; 1import efl_ui_list_types;
2 2
3struct @extern Efl_Ui_List_SegArray;
4
3interface Efl.Ui.List.Relayout (Efl.Interface) 5interface Efl.Ui.List.Relayout (Efl.Interface)
4{ 6{
5 methods { 7 methods {
@@ -7,8 +9,7 @@ interface Efl.Ui.List.Relayout (Efl.Interface)
7 params { 9 params {
8 modeler: Efl.Ui.List.Model; 10 modeler: Efl.Ui.List.Model;
9 first: int; 11 first: int;
10 count: int; 12 children: ptr(Efl_Ui_List_SegArray);
11 children: accessor<Efl.Ui.List.LayoutItem>;
12 } 13 }
13 } 14 }
14 @property model { 15 @property model {