summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-11-08 19:09:03 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commit72e1f135924b06238464d52947e30793b7f118eb (patch)
tree0322140bab1eb6163440405a30e97eea86cbbb6d
parenta818c9c92ac4b47c7a4725fd58428324cbcc2a79 (diff)
elm: node calc item and realize/unrealize WIP
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c137
1 files changed, 110 insertions, 27 deletions
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index bd0ac68fcb..4ef0a20544 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -150,6 +150,7 @@ _on_item_size_hint_change(void *data, Evas *e EINA_UNUSED,
150{ 150{
151 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = data; 151 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = data;
152 Efl_Ui_List_SegArray_Node *node = cb_data->node; 152 Efl_Ui_List_SegArray_Node *node = cb_data->node;
153 Efl_Ui_List_Precise_Layouter_Data *pd = cb_data->pd;
153 Efl_Ui_List_LayoutItem *item; 154 Efl_Ui_List_LayoutItem *item;
154 int i; 155 int i;
155 156
@@ -160,7 +161,13 @@ _on_item_size_hint_change(void *data, Evas *e EINA_UNUSED,
160 item = (Efl_Ui_List_LayoutItem *)node->pointers[i]; 161 item = (Efl_Ui_List_LayoutItem *)node->pointers[i];
161 if (item->layout == obj) 162 if (item->layout == obj)
162 { 163 {
164 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = node->layout_data;
163 _item_min_calc(cb_data->pd, item, min, node); 165 _item_min_calc(cb_data->pd, item, min, node);
166 if (!nodedata->realized)
167 {
168 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);
170 }
164 return; 171 return;
165 } 172 }
166 } 173 }
@@ -170,8 +177,8 @@ static void
170_on_modeler_resize(void *data, Evas *e EINA_UNUSED, 177_on_modeler_resize(void *data, Evas *e EINA_UNUSED,
171 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 178 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
172{ 179{
173// Efl_Ui_List_Precise_Layouter_Data *pd = data; 180 //Efl_Ui_List_Precise_Layouter_Data *pd = data;
174// pd->recalc = EINA_TRUE; 181 //pd->recalc = EINA_TRUE;
175} 182}
176 183
177static void 184static void
@@ -223,24 +230,93 @@ _finalize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd)
223 pd->initialized = EINA_FALSE; 230 pd->initialized = EINA_FALSE;
224} 231}
225 232
226/*
227static void 233static void
228_calc_range(, Efl_Ui_List_Precise_Layouter_Data *pd, ) 234_node_realize(Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_SegArray_Node *node)
229{ 235{
230 Efl_Ui_List_Precise_Layouter_Size* size;
231 Efl_Ui_List_Precise_Layouter_Data *pd;
232 Efl_Ui_List_LayoutItem* layout_item; 236 Efl_Ui_List_LayoutItem* layout_item;
233 Eo *obj = data; 237 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data;
234 Evas_Coord ow, oh, scr_x, scr_y; 238 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = node->layout_data;
239 int i;
235 240
236 double start_time = ecore_time_get(); 241 if (nodedata->realized)
242 return;
243
244 DBG("node_realize %d", node->first);
245 nodedata->realized = EINA_TRUE;
246
247 for (i = 0; i != node->length; ++i)
248 {
249 layout_item = (Efl_Ui_List_LayoutItem *)node->pointers[i];
250 efl_ui_list_model_realize(pd->modeler, layout_item);
251
252 if (layout_item->layout)
253 {
254 cb_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Callback_Data));
255 cb_data->pd = pd;
256 cb_data->node = node;
257 evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data);
258 }
259 }
260}
261
262static void
263_node_unrealize(Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_List_SegArray_Node *node)
264{
265 Efl_Ui_List_LayoutItem* layout_item;
266 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data;
267 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = node->layout_data;
268 int i;
237 269
270 if (!nodedata->realized)
271 return;
272
273 DBG("node_unrealize %d", node->first);
274 nodedata->realized = EINA_FALSE;
275
276 for (i = 0; i != node->length; ++i)
277 {
278 layout_item = (Efl_Ui_List_LayoutItem *)node->pointers[i];
279 if (layout_item->layout)
280 {
281 cb_data = evas_object_event_callback_del(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change);
282 free(cb_data);
283 }
284 efl_ui_list_model_unrealize(pd->modeler, layout_item);
285 }
286}
287
288static void
289_calc_range(Efl_Ui_List_Precise_Layouter_Data *pd)
290{
291 Efl_Ui_List_SegArray_Node *node;
292 Evas_Coord ow, oh, scr_x, scr_y, ch;
293 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata;
294 int i;
295
296 DBG("calc_range");
238 elm_interface_scrollable_content_viewport_geometry_get 297 elm_interface_scrollable_content_viewport_geometry_get
239 (pd->modeler, NULL, NULL, &ow, &oh); 298 (pd->modeler, NULL, NULL, &ow, &oh);
240
241 elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y); 299 elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y);
300
301 ch = 0;
302
303 EINA_ACCESSOR_FOREACH(pd->nodes, i, node)
304 {
305 nodedata = node->layout_data;
306
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)
309 continue;
310
311 if ((ch >= scr_y || nodedata->min.h + ch >= scr_y) && (ch <= (scr_y + oh) || nodedata->min.h + ch <= scr_y + oh))
312 _node_realize(pd, node);
313 else
314 _node_unrealize(pd, node);
315
316 ch += nodedata->min.h;
317 }
242} 318}
243*/ 319
244static void 320static void
245_calc_size_job(void *data) 321_calc_size_job(void *data)
246{ 322{
@@ -248,6 +324,7 @@ _calc_size_job(void *data)
248 Efl_Ui_List_SegArray_Node *node; 324 Efl_Ui_List_SegArray_Node *node;
249 Efl_Ui_List_LayoutItem *layout_item; 325 Efl_Ui_List_LayoutItem *layout_item;
250 Eo *obj = data; 326 Eo *obj = data;
327 Eina_Size2D min;
251 int i; 328 int i;
252 double start_time = ecore_time_get(); 329 double start_time = ecore_time_get();
253 330
@@ -261,20 +338,18 @@ _calc_size_job(void *data)
261 while (eina_accessor_data_get(pd->nodes, pd->calc_progress, (void **)&node)) 338 while (eina_accessor_data_get(pd->nodes, pd->calc_progress, (void **)&node))
262 { 339 {
263 pd->calc_progress++; 340 pd->calc_progress++;
264 DBG("node first %d", node->first);
265 if (!node->layout_data) 341 if (!node->layout_data)
266 node->layout_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Node_Data)); 342 node->layout_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Node_Data));
267 343
268 for (i = 0; i != node->length; ++i) 344 for (i = 0; i != node->length; ++i)
269 { 345 {
270 layout_item = (Efl_Ui_List_LayoutItem *)node->pointers[i]; 346 layout_item = (Efl_Ui_List_LayoutItem *)node->pointers[i];
271 DBG("layout_do first %d count %d", pd->first, pd->count); 347// DBG("layout_do first %d count %d", pd->first, pd->count);
272 EINA_SAFETY_ON_NULL_RETURN(layout_item); 348 EINA_SAFETY_ON_NULL_RETURN(layout_item);
273 349
274 // cache size of new items 350 // cache size of new items
275 if ((layout_item->min.w == 0) && (layout_item->min.h == 0)) 351 if ((layout_item->min.w == 0) && (layout_item->min.h == 0))
276 { 352 {
277 Eina_Bool realized = EINA_FALSE;
278 if (!layout_item->layout) 353 if (!layout_item->layout)
279 { 354 {
280 DBG("no layout, realizing"); 355 DBG("no layout, realizing");
@@ -282,7 +357,6 @@ _calc_size_job(void *data)
282 } 357 }
283 else 358 else
284 { 359 {
285 realized = EINA_TRUE;
286 DBG("already realized"); 360 DBG("already realized");
287 /* if(!layout_item->layout) */ 361 /* if(!layout_item->layout) */
288 /* { */ 362 /* { */
@@ -291,22 +365,20 @@ _calc_size_job(void *data)
291 /* } */ 365 /* } */
292 } 366 }
293 367
294 Eina_Size2D min = efl_gfx_size_hint_combined_min_get(layout_item->layout); 368 min = efl_gfx_size_hint_combined_min_get(layout_item->layout);
295 if (min.w && min.h) 369 if (min.w && min.h)
296 { 370 {
297 //DBG("size was calculated"); 371 DBG("size was calculated w:%d h:%d", min.w, min.h);
298 _item_min_calc(pd, layout_item, min, node); 372 _item_min_calc(pd, layout_item, min, node);
373 efl_ui_list_model_unrealize(pd->modeler, layout_item);
299 } 374 }
300 375 else
301// if (realized)
302 { 376 {
303 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Callback_Data)); 377 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Callback_Data));
304 cb_data->pd = pd; 378 cb_data->pd = pd;
305 cb_data->node = node; 379 cb_data->node = node;
306 evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data); 380 evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data);
307 } 381 }
308// else
309// efl_ui_list_model_unrealize(pd->modeler, layout_item);
310 } 382 }
311 } 383 }
312 if ( (ecore_time_get() - start_time ) > 0.01 ) 384 if ( (ecore_time_get() - start_time ) > 0.01 )
@@ -314,7 +386,7 @@ _calc_size_job(void *data)
314 DBG(" <><><> RECALC JOB SPLIT <><><> "); 386 DBG(" <><><> RECALC JOB SPLIT <><><> ");
315 ecore_job_del(pd->calc_job); 387 ecore_job_del(pd->calc_job);
316 pd->calc_job = ecore_job_add(_calc_size_job, obj); 388 pd->calc_job = ecore_job_add(_calc_size_job, obj);
317 _efl_ui_list_relayout_layout_do(pd); 389// _efl_ui_list_relayout_layout_do(pd);
318 return; 390 return;
319 } 391 }
320 } 392 }
@@ -378,6 +450,8 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
378 unsigned int i; 450 unsigned int i;
379 int j = 0; 451 int j = 0;
380 452
453 _calc_range(pd);
454
381 evas_object_geometry_get(pd->modeler, &boxx, &boxy, &boxw, &boxh); 455 evas_object_geometry_get(pd->modeler, &boxx, &boxy, &boxw, &boxh);
382 efl_gfx_size_hint_margin_get(pd->modeler, &boxl, &boxr, &boxt, &boxb); 456 efl_gfx_size_hint_margin_get(pd->modeler, &boxl, &boxr, &boxt, &boxb);
383 457
@@ -453,6 +527,14 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
453 // cache size of new items 527 // cache size of new items
454 EINA_ACCESSOR_FOREACH(pd->nodes, i, items_node) 528 EINA_ACCESSOR_FOREACH(pd->nodes, i, items_node)
455 { 529 {
530
531 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = items_node->layout_data;
532 if (!nodedata->realized)
533 {
534 cur_pos += nodedata->min.h;
535 continue;
536 }
537
456 for(j = 0; j != items_node->length;++j) 538 for(j = 0; j != items_node->length;++j)
457 { 539 {
458 layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[j]; 540 layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[j];
@@ -573,12 +655,13 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
573 return; 655 return;
574 } 656 }
575 } /* EINA ACCESSOR FOREACH END */ 657 } /* EINA ACCESSOR FOREACH END */
576 658/*
577 if (!pd->calc_progress) 659 if (!pd->calc_progress)
578 { 660 {
579 eina_accessor_free(pd->nodes); 661 eina_accessor_free(pd->nodes);
580 pd->nodes = NULL; 662 pd->nodes = NULL;
581 } 663 }
664*/
582} 665}
583 666
584EOLIAN static void 667EOLIAN static void
@@ -586,7 +669,6 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
586 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd 669 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd
587 , Efl_Ui_List_Model *modeler, int first, int count, Eina_Accessor *nodes) 670 , Efl_Ui_List_Model *modeler, int first, int count, Eina_Accessor *nodes)
588{ 671{
589 unsigned int pop;
590 EINA_SAFETY_ON_NULL_RETURN(nodes); 672 EINA_SAFETY_ON_NULL_RETURN(nodes);
591 673
592 _initilize(obj, pd, modeler); 674 _initilize(obj, pd, modeler);
@@ -595,9 +677,10 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
595 pd->first = first; 677 pd->first = first;
596 pd->count = count; 678 pd->count = count;
597 679
598 if (pd->nodes) 680// if (pd->nodes)
599 eina_accessor_free(pd->nodes); 681// eina_accessor_free(pd->nodes);
600 pd->nodes = nodes; 682// if (!pd->nodes)
683 pd->nodes = nodes;
601 684
602 if (pd->recalc) // || pd->count_total > pop) 685 if (pd->recalc) // || pd->count_total > pop)
603 { 686 {