public void Arrange_should_layout_children_horizontally_passing_max_height_but_limiting_area_to_not_expand_over_the_bounding_box() { var area = new Rectangle(5, 5, 30, 100); var box = new HBox(); var c1 = new Component { Width = 15, Height = 90 }; var c2 = new Component { Width = 20, Height = 110 }; var c3 = new Component { Width = 20, Height = 100 }; box.AddComponent(c1); box.AddComponent(c2); box.AddComponent(c3); box.Measure(area.Size, TestRendererContext.Instance); box.Arrange(area); c1.Layout.ShouldBe(new Rectangle(5, 5, 15, 90)); c2.Layout.ShouldBe(new Rectangle(5 + 15, 5, 15, 100)); c3.Layout.ShouldBe(new Rectangle(5 + 15 + 15, 5, 0, 100)); }
public void Arrange_should_layout_items_honoring_their_desired_size() { var area = new Rectangle(5, 5, 100, 100); var box = new HBox { Width = 100 }; var c1 = new Component { Width = 40, Height = 100 }; var c2 = new TestableComponent { Width = SizeUnit.Unlimited, Height = 100, OnMeasureCallback = _ => new Size(50, 100) }; var c3 = new Component { Width = 40, Height = 100 }; box.AddComponent(c1); box.AddComponent(c2); box.AddComponent(c3); box.Measure(area.Size, TestRendererContext.Instance); box.Arrange(area); c1.Layout.ShouldBe(new Rectangle(5, 5, 40, 100)); c2.Layout.ShouldBe(new Rectangle(45, 5, 50, 100)); c3.Layout.ShouldBe(new Rectangle(95, 5, 10, 100)); }
public void Arrange_should_distribute_remaining_width_between_components_with_unlimited_width() { var area = new Rectangle(5, 5, 100, 100); var box = new HBox { Width = 100 }; var c1 = new FixedMeasureComponent(20, 100) { Width = SizeUnit.Unlimited }; var c2 = new Component { Width = 25, Height = 100 }; var c3 = new FixedMeasureComponent(30, 100) { Width = SizeUnit.Unlimited }; box.AddComponent(c1); box.AddComponent(c2); box.AddComponent(c3); box.Measure(area.Size, TestRendererContext.Instance); box.Arrange(area); c1.Layout.ShouldBe(new Rectangle(5, 5, 20 + 12, 100)); c2.Layout.ShouldBe(new Rectangle(new Point(c1.Layout.Right, area.Top), new Size(25, 100))); c3.Layout.ShouldBe(new Rectangle(new Point(c2.Layout.Right, area.Top), new Size(30 + 13, 100))); }