summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-11-11 20:37:25 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commite649d932beddc9913525249d53c11b1fddf0641b (patch)
tree8f2d40a7b15a2941eb6dee05697a21add231c8c9
parent0332cf008e64b07332e7a17e60b95f6c9b74803c (diff)
elm: WIP in efl_ui_list change in layouting through cache
-rw-r--r--src/lib/elementary/efl_ui_list.c4
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c281
-rw-r--r--src/lib/elementary/efl_ui_list_segarray.c4
3 files changed, 161 insertions, 128 deletions
diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c
index 2455e8e6e8..4151a36ca7 100644
--- a/src/lib/elementary/efl_ui_list.c
+++ b/src/lib/elementary/efl_ui_list.c
@@ -1474,7 +1474,7 @@ EOLIAN static Efl_Ui_List_LayoutItem *
1474_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)
1475{ 1475{
1476 Efl_Ui_List_Item_Event evt; 1476 Efl_Ui_List_Item_Event evt;
1477// DBG("model_realize"); 1477 DBG("model_realize");
1478 EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item); 1478 EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item);
1479 1479
1480 item->layout = efl_ui_factory_create(pd->factory, item->children, obj); 1480 item->layout = efl_ui_factory_create(pd->factory, item->children, obj);
@@ -1495,7 +1495,7 @@ EOLIAN static void
1495_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)
1496{ 1496{
1497 Efl_Ui_List_Item_Event evt; 1497 Efl_Ui_List_Item_Event evt;
1498// DBG("model_unrealize item:%p", item); 1498 DBG("model_unrealize item:%p", item);
1499 EINA_SAFETY_ON_NULL_RETURN(item->layout); 1499 EINA_SAFETY_ON_NULL_RETURN(item->layout);
1500 1500
1501 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 9a806ec2d8..53d5b1bba6 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -496,138 +496,171 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
496 (pd->modeler, NULL, NULL, &ow, &oh); 496 (pd->modeler, NULL, NULL, &ow, &oh);
497 497
498 elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y); 498 elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y);
499
500 DBG("scr_x: %d, scr_y: %d\n", (int)scr_x, (int)scr_y);
501
499 // scan all items, get their properties, calculate total weight & min size 502 // scan all items, get their properties, calculate total weight & min size
500 // cache size of new items 503 // cache size of new items
501 Eina_Accessor *nodes = efl_ui_list_segarray_node_accessor_get(pd->segarray); 504 Eina_Accessor *nodes = efl_ui_list_segarray_node_accessor_get(pd->segarray);
505
506 /* int sum_node_top = 0; */
507
502 EINA_ACCESSOR_FOREACH(nodes, i, items_node) 508 EINA_ACCESSOR_FOREACH(nodes, i, items_node)
503 { 509 {
510 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = items_node->layout_data;
511 if (!nodedata)
512 {
513 DBG("no data in node!");
514 continue;
515 }
504 516
505 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = items_node->layout_data; 517 /* int start_pos = ; */
506 if (!nodedata) continue; 518 /* if(start_pos < 0) */
507 519 /* start_pos = 0; */
508 if (!nodedata->realized) 520 if(scr_y < cur_pos + nodedata->min.h + boxh
509 { 521 && scr_y + boxh + boxh > cur_pos) // start in this node
510 cur_pos += nodedata->min.h; 522 {
511 continue; 523 DBG("cur_pos: %d\n", (int)cur_pos);
512 }
513 524
514 for(j = 0; j != items_node->length;++j) 525 for(j = 0; j != items_node->length && scr_y + boxh + boxh > cur_pos;++j)
515 { 526 {
516 layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[j]; 527 DBG("cur_pos item by item: %d\n", (int)cur_pos);
517 double cx, cy, cw, ch, x, y, w, h; 528 layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[j];
518 double weight_x, weight_y; 529 double cx, cy, cw, ch, x, y, w, h;
519 double align[2]; 530 double weight_x, weight_y;
520 int item_pad[4]; 531 double align[2];
521 Eina_Size2D max; 532 int item_pad[4];
522 int pad = 0; 533 Eina_Size2D max;
523 534 int pad = 0;
524 if(layout_item->min.w && layout_item->min.h) 535
525 { 536 if(layout_item->min.w && layout_item->min.h)
537 {
526// DBG("size information for item %d width %d height %d", j, layout_item->min.w, layout_item->min.h); 538// DBG("size information for item %d width %d height %d", j, layout_item->min.w, layout_item->min.h);
527 539 if(!layout_item->layout)
528 assert(layout_item->layout != NULL); 540 {
529 efl_gfx_size_hint_weight_get(layout_item->layout, &weight_x, &weight_y); 541 DBG("realizing showing item\n");
530 efl_gfx_size_hint_align_get(layout_item->layout, &align[0], &align[1]); 542 efl_ui_list_model_realize(pd->modeler, layout_item);
531 max = efl_gfx_size_hint_max_get(layout_item->layout); 543 assert(layout_item->layout != NULL);
532 efl_gfx_size_hint_margin_get(layout_item->layout, &item_pad[0], &item_pad[1], &item_pad[2], &item_pad[3]); 544 }
533 545 efl_gfx_size_hint_weight_get(layout_item->layout, &weight_x, &weight_y);
534 if (align[0] < 0) align[0] = -1; 546 efl_gfx_size_hint_align_get(layout_item->layout, &align[0], &align[1]);
535 if (align[1] < 0) align[1] = -1; 547 max = efl_gfx_size_hint_max_get(layout_item->layout);
536 if (align[0] > 1) align[0] = 1; 548 efl_gfx_size_hint_margin_get(layout_item->layout, &item_pad[0], &item_pad[1], &item_pad[2], &item_pad[3]);
537 if (align[1] > 1) align[1] = 1; 549
538 550 if (align[0] < 0) align[0] = -1;
539 if (max.w <= 0) max.w = INT_MAX; 551 if (align[1] < 0) align[1] = -1;
540 if (max.h <= 0) max.h = INT_MAX; 552 if (align[0] > 1) align[0] = 1;
541 if (max.w < layout_item->min.w) max.w = layout_item->min.w; 553 if (align[1] > 1) align[1] = 1;
542 if (max.h < layout_item->min.h) max.h = layout_item->min.h; 554
543 555 if (max.w <= 0) max.w = INT_MAX;
544 // extra rounding up (compensate cumulative error) 556 if (max.h <= 0) max.h = INT_MAX;
545 if ((i == (pd->count - 1)) && (cur_pos - floor(cur_pos) >= 0.5)) 557 if (max.w < layout_item->min.w) max.w = layout_item->min.w;
546 rounding = 1; 558 if (max.h < layout_item->min.h) max.h = layout_item->min.h;
547 559
548 if (horiz) 560 // extra rounding up (compensate cumulative error)
549 { 561 if ((i == (pd->count - 1)) && (cur_pos - floor(cur_pos) >= 0.5))
550 cx = boxx + cur_pos; 562 rounding = 1;
551 cy = boxy; 563
552 cw = layout_item->min.w + rounding + (zeroweight ? 1.0 : weight_x) * extra / weight[0]; 564 if (horiz)
553 ch = boxh; 565 {
554 cur_pos += cw + pad; 566 cx = boxx + cur_pos;
555 } 567 cy = boxy;
556 else 568 cw = layout_item->min.w + rounding + (zeroweight ? 1.0 : weight_x) * extra / weight[0];
557 { 569 ch = boxh;
558 cx = boxx; 570 cur_pos += cw + pad;
559 cy = boxy + cur_pos; 571 }
560 cw = boxw; 572 else
561 ch = layout_item->min.h + rounding + (zeroweight ? 1.0 : weight_y) * extra / weight[1]; 573 {
562 cur_pos += ch + pad; 574 cx = boxx;
563 } 575 cy = boxy + cur_pos;
564 576 cw = boxw;
565 // horizontally 577 ch = layout_item->min.h + rounding + (zeroweight ? 1.0 : weight_y) * extra / weight[1];
566 if (max.w < INT_MAX) 578 cur_pos += ch + pad;
567 { 579 }
568 w = MIN(MAX(layout_item->min.w - item_pad[0] - item_pad[1], max.w), cw); 580
569 if (align[0] < 0) 581 // horizontally
570 { 582 if (max.w < INT_MAX)
571 // bad case: fill+max are not good together 583 {
572 x = cx + ((cw - w) * box_align[0]) + item_pad[0]; 584 w = MIN(MAX(layout_item->min.w - item_pad[0] - item_pad[1], max.w), cw);
573 } 585 if (align[0] < 0)
574 else 586 {
575 x = cx + ((cw - w) * align[0]) + item_pad[0]; 587 // bad case: fill+max are not good together
576 } 588 x = cx + ((cw - w) * box_align[0]) + item_pad[0];
577 else if (align[0] < 0) 589 }
578 { 590 else
579 // fill x 591 x = cx + ((cw - w) * align[0]) + item_pad[0];
580 w = cw - item_pad[0] - item_pad[1]; 592 }
581 x = cx + item_pad[0]; 593 else if (align[0] < 0)
582 } 594 {
583 else 595 // fill x
584 { 596 w = cw - item_pad[0] - item_pad[1];
585 w = layout_item->min.w - item_pad[0] - item_pad[1]; 597 x = cx + item_pad[0];
586 x = cx + ((cw - w) * align[0]) + item_pad[0]; 598 }
587 } 599 else
588 600 {
589 // vertically 601 w = layout_item->min.w - item_pad[0] - item_pad[1];
590 if (max.h < INT_MAX) 602 x = cx + ((cw - w) * align[0]) + item_pad[0];
591 { 603 }
592 h = MIN(MAX(layout_item->min.h - item_pad[2] - item_pad[3], max.h), ch); 604
593 if (align[1] < 0) 605 // vertically
594 { 606 if (max.h < INT_MAX)
595 // bad case: fill+max are not good together 607 {
596 y = cy + ((ch - h) * box_align[1]) + item_pad[2]; 608 h = MIN(MAX(layout_item->min.h - item_pad[2] - item_pad[3], max.h), ch);
597 } 609 if (align[1] < 0)
598 else 610 {
599 y = cy + ((ch - h) * align[1]) + item_pad[2]; 611 // bad case: fill+max are not good together
600 } 612 y = cy + ((ch - h) * box_align[1]) + item_pad[2];
601 else if (align[1] < 0) 613 }
602 { 614 else
603 // fill y 615 y = cy + ((ch - h) * align[1]) + item_pad[2];
604 h = ch - item_pad[2] - item_pad[3]; 616 }
605 y = cy + item_pad[2]; 617 else if (align[1] < 0)
606 } 618 {
607 else 619 // fill y
608 { 620 h = ch - item_pad[2] - item_pad[3];
609 h = layout_item->min.h - item_pad[2] - item_pad[3]; 621 y = cy + item_pad[2];
610 y = cy + ((ch - h) * align[1]) + item_pad[2]; 622 }
611 } 623 else
612 624 {
613 if (horiz) 625 h = layout_item->min.h - item_pad[2] - item_pad[3];
614 { 626 y = cy + ((ch - h) * align[1]) + item_pad[2];
615 if (h < pd->min.h) h = pd->min.h; 627 }
616 if (h > oh) h = oh; 628
617 } 629 if (horiz)
618 else 630 {
619 { 631 if (h < pd->min.h) h = pd->min.h;
620 if (w < pd->min.w) w = pd->min.w; 632 if (h > oh) h = oh;
621 if (w > ow) w = ow; 633 }
622 } 634 else
623 635 {
624// DBG("------- x=%0.f, y=%0.f, w=%0.f, h=%0.f --- ", x, y, w, h); 636 if (w < pd->min.w) w = pd->min.w;
625 evas_object_geometry_set(layout_item->layout, (x + 0 - scr_x), (y + 0 - scr_y), w, h); 637 if (w > ow) w = ow;
626 638 }
627 /* layout_item->x = x; */ 639
628 /* layout_item->y = y; */ 640 // DBG("------- x=%0.f, y=%0.f, w=%0.f, h=%0.f --- ", x, y, w, h);
629 } /* if (size) end */ 641 evas_object_geometry_set(layout_item->layout, (x + 0 - scr_x), (y + 0 - scr_y), w, h);
630 } 642
643 // layout_item->x = x;
644 // layout_item->y = y;
645
646 } /* if (size) end */
647 }
648 }
649 else if (nodedata->realized) // unrealize
650 {
651 for(j = 0; j != items_node->length;++j)
652 {
653 layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[j];
654 if(layout_item->layout)
655 efl_ui_list_model_unrealize(pd->modeler, layout_item);
656 }
657 nodedata->realized = EINA_FALSE;
658 cur_pos += nodedata->min.h;
659 }
660 else
661 {
662 cur_pos += nodedata->min.h;
663 }
631 } /* EINA ACCESSOR FOREACH END */ 664 } /* EINA ACCESSOR FOREACH END */
632 eina_accessor_free(nodes); 665 eina_accessor_free(nodes);
633} 666}
diff --git a/src/lib/elementary/efl_ui_list_segarray.c b/src/lib/elementary/efl_ui_list_segarray.c
index fced099e52..1768815ae1 100644
--- a/src/lib/elementary/efl_ui_list_segarray.c
+++ b/src/lib/elementary/efl_ui_list_segarray.c
@@ -247,14 +247,14 @@ _efl_ui_list_segarray_node_accessor_get_at(Efl_Ui_List_Segarray_Node_Accessor* a
247 247
248 for(;acc->current_index != idx;++acc->current_index) 248 for(;acc->current_index != idx;++acc->current_index)
249 { 249 {
250 DBG("for current_index: %d idx: %d", acc->current_index, idx); 250 /* DBG("for current_index: %d idx: %d", acc->current_index, idx); */
251 if(!eina_iterator_next(acc->pre_iterator, (void**)&acc->current_node)) 251 if(!eina_iterator_next(acc->pre_iterator, (void**)&acc->current_node))
252 { 252 {
253 --acc->current_index; 253 --acc->current_index;
254 return EINA_FALSE; 254 return EINA_FALSE;
255 } 255 }
256 } 256 }
257 DBG("out of loop"); 257 /* DBG("out of loop"); */
258 (*data) = acc->current_node; 258 (*data) = acc->current_node;
259 return EINA_TRUE; 259 return EINA_TRUE;
260 } 260 }