summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2017-08-14 16:50:34 +0900
committerThiep Ha <thiepha@gmail.com>2017-08-14 16:50:34 +0900
commit9c96a1f05eddeb5db296c53d96d3acf7b604542f (patch)
tree90a82615bc35544e7f1afb5af0035ec2fbb40868
parent87de2deb55d3effa160bcab1542b61c7deeb7e23 (diff)
aspect ratio: add support for vertical casedevs/thiep/size
- what is correct handling for max = 0?
-rw-r--r--src/bin/elementary/test_ui_box.c5
-rw-r--r--src/lib/elementary/efl_ui_box_layout.c75
2 files changed, 77 insertions, 3 deletions
diff --git a/src/bin/elementary/test_ui_box.c b/src/bin/elementary/test_ui_box.c
index 146932faad..d584e4a861 100644
--- a/src/bin/elementary/test_ui_box.c
+++ b/src/bin/elementary/test_ui_box.c
@@ -490,7 +490,8 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
490 efl_pack_padding_set(bx, 10, 10, EINA_TRUE); 490 efl_pack_padding_set(bx, 10, 10, EINA_TRUE);
491 efl_gfx_size_hint_align_set(bx, 0.5, 0.5); 491 efl_gfx_size_hint_align_set(bx, 0.5, 0.5);
492 efl_gfx_size_hint_weight_set(bx, 1, 1); 492 efl_gfx_size_hint_weight_set(bx, 1, 1);
493 efl_orientation_set(bx, EFL_ORIENT_HORIZONTAL); 493 //efl_orientation_set(bx, EFL_ORIENT_HORIZONTAL);
494 efl_orientation_set(bx, EFL_ORIENT_VERTICAL);
494 elm_object_content_set(f, bx); 495 elm_object_content_set(f, bx);
495 efl_gfx_visible_set(bx, 1); 496 efl_gfx_visible_set(bx, 1);
496 497
@@ -505,7 +506,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
505 efl_gfx_size_hint_weight_set(o, 1, 1); 506 efl_gfx_size_hint_weight_set(o, 1, 1);
506 efl_gfx_size_hint_align_set(o, -1, -1); 507 efl_gfx_size_hint_align_set(o, -1, -1);
507 //efl_gfx_size_hint_min_set(o, 200, 200); 508 //efl_gfx_size_hint_min_set(o, 200, 200);
508 efl_gfx_size_hint_max_set(o, 400, 400); 509 efl_gfx_size_hint_max_set(o, -1, 0);
509 efl_gfx_size_hint_aspect_set(o, EFL_GFX_SIZE_HINT_ASPECT_BOTH, 3, 1); 510 efl_gfx_size_hint_aspect_set(o, EFL_GFX_SIZE_HINT_ASPECT_BOTH, 3, 1);
510 efl_pack(bx, o); 511 efl_pack(bx, o);
511 efl_gfx_visible_set(o, 1); 512 efl_gfx_visible_set(o, 1);
diff --git a/src/lib/elementary/efl_ui_box_layout.c b/src/lib/elementary/efl_ui_box_layout.c
index 520a667828..4c1d37b106 100644
--- a/src/lib/elementary/efl_ui_box_layout.c
+++ b/src/lib/elementary/efl_ui_box_layout.c
@@ -552,7 +552,80 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
552 } 552 }
553 else 553 else
554 { 554 {
555 //FIXME: add handling for vertical case 555 //consider aspect, min, max, fill
556 int w1 = item->want[0];
557 int h1 = item->want[1];
558 if (weight[1] > 0)
559 h1 = item->want[1] + extra * item->weight[1] / weight[1];
560 w1 = h1 * item->aw / item->ah;
561 D("w h: %d %d, want: %d %d, extra: %d, weight: %.1f / %.1f", w1, h1, item->want[0], item->want[1], extra, item->weight[1], weight[1]);
562 if (w1 < item->want[0]) //how?
563 {
564 w1 = item->want[0];
565 h1 = w1 * item->ah / item->aw;
566 D("w h: %d %d", w1, h1);
567 }
568 if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_BOTH ||
569 item->aspect == EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
570 {
571 if (w1 > boxw)
572 {
573 w1 = boxw;
574 h1 = w1 * item->ah / item->aw;
575 }
576 }
577
578 //aspect and max
579 double mar = 0.0;
580 //if ((item->max[0] != INT_MAX) && (item->max[1] != INT_MAX))
581 //if max = 0, max is set to INT_MAX, what is correct behaviour for max = 0?
582 if (item->max[1] != 0)
583 {
584 mar = item->max[0] / (double)item->max[1];
585 D("mar: %.2f, max: %d %d", mar, item->max[0], item->max[1]);
586 if (item->ah > 0)
587 {
588 double ar = item->aw / (double)item->ah;
589 D("ar: %.2f, mar: %.2f", ar, mar);
590 if (ar < mar)
591 {
592 if (h1 > item->max[1])
593 {
594 h1 = item->max[1];
595 w1 = h1 * item->aw / item->ah;
596 }
597 D("w, h: %d %d", w1, h1);
598 }
599 else
600 {
601 if (w1 > item->max[0])
602 {
603 w1 = item->max[0];
604 h1 = w1 * item->ah / item->aw;
605 }
606 D("w, h: %d %d", w1, h1);
607 }
608 }
609 }
610 w = w1 - item->pad[0] - item->pad[1];
611 h = h1 - item->pad[2] - item->pad[3];
612 if (item->align[0] < 0)
613 {
614 x = cx + (cw - w) * 0.5 + item->pad[0];
615 }
616 else
617 {
618 x = cx + (cw - w) * item->align[0] + item->pad[0];
619 }
620 if (item->align[1] < 0)
621 {
622 y = cy + (ch - h) * 0.5 + item->pad[2];
623 }
624 else
625 {
626 y = cy + (ch - h) * item->align[1] + item->pad[2];
627 }
628 D("verical: w, h: %d %d, extra: %d", w1, h1, extra);
556 } 629 }
557 } 630 }
558 else 631 else