public void TestImplicitConstraintsOnMinSpaceChild() { var g = new Grid(LayoutTestStyle.Create()); g.AddChildAt(new LayoutTestWidget { MeasureOverrideFunc = s => new Size(100, 50) }, 0, 0); g.AddChildAt(new LayoutTestWidget { MeasureOverrideFunc = s => new Size(200, 100) }, 1, 1); g.Measure(new Size(float.PositiveInfinity, float.PositiveInfinity)); g[0].DesiredSize.Should().Be(new Size(100, 50)); g[1].DesiredSize.Should().Be(new Size(200, 100)); g.DesiredSize.Should().Be(new Size(300, 150)); g.Arrange(new Rectangle(10, 20, 400, 300)); g[0].DesiredSize.Should().Be(new Size(100, 50)); g[1].DesiredSize.Should().Be(new Size(200, 100)); g[0].LayoutInvalid.Should().Be(false); g[1].LayoutInvalid.Should().Be(false); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 100, 50)); g[1].LayoutRect.Should().Be(new Rectangle(110, 70, 200, 100)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 300, 150)); }
public void TestImplicitConstraintsAdded() { var g = new Grid(LayoutTestStyle.Create()); g.AddChildAt(new LayoutTestWidget(), 0, 0); g.AddChildAt(new LayoutTestWidget(), 1, 1); g.Measure(new Size(float.PositiveInfinity, float.PositiveInfinity)); g.RowConstraints.Should().BeEquivalentTo(LengthConstraint.Auto, LengthConstraint.Auto); g.ColumnConstraints.Should().BeEquivalentTo(LengthConstraint.Auto, LengthConstraint.Auto); }
public void TestGridSpacing() { var g = new Grid(LayoutTestStyle.Create()); g.Spacing = 10; g.AddChildAt(LayoutTestWidget.FixedSize(100, 100), 0, 0); g.AddChildAt(LayoutTestWidget.FixedSize(200, 200), 1, 1); g.AddChildAt(LayoutTestWidget.FixedSize(200, 200), 1, 2); g.Measure(Size.Auto); g.Arrange(new Rectangle(10, 20, g.DesiredSize.WidthInt, g.DesiredSize.HeightInt)); g.LayoutRect.Size.Should().Be(new Point(g.DesiredSize.WidthInt, g.DesiredSize.HeightInt)); }
public void TestImplicitFixedMeasure() { var g = new Grid(LayoutTestStyle.Create()); g.AddChildAt(LayoutTestWidget.FixedSize(100, 100), 0, 0); g.AddChildAt(LayoutTestWidget.FixedSize(200, 200), 1, 1); g.Arrange(new Rectangle(10, 20, 0, 0)); g.DesiredSize.Should().Be(new Size(300, 300)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 300, 300)); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 100, 100)); g[1].LayoutRect.Should().Be(new Rectangle(110, 120, 200, 200)); }
public void Auto_Relative_Mixed() { var g = new Grid(LayoutTestStyle.Create()); g.ColumnConstraints.Add(LengthConstraint.Auto); g.ColumnConstraints.Add(LengthConstraint.Relative(1)); g.ColumnConstraints.Add(LengthConstraint.Relative(1)); g.AddChildAt(LayoutTestWidget.FixedSize(100, 10), 0, 0); g.AddChildAt(LayoutTestWidget.FixedSize(200, 10), 1, 0); g.AddChildAt(LayoutTestWidget.FixedSize(10, 10), 2, 0); g.Arrange(new Rectangle(10, 20, 400, 20)); g.DesiredSize.Should().Be(new Size(400, 10)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 400, 10)); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 100, 10)); g[1].LayoutRect.Should().Be(new Rectangle(110, 20, 150, 10)); g[2].LayoutRect.Should().Be(new Rectangle(260, 20, 150, 10)); }
public void TestImplicitConstraintsOnZeroSpaceChild() { var g = new Grid(LayoutTestStyle.Create()); g.AddChildAt(new LayoutTestWidget(), 0, 0); g.AddChildAt(new LayoutTestWidget(), 1, 1); g.Measure(new Size(float.PositiveInfinity, float.PositiveInfinity)); g[0].DesiredSize.Should().Be(new Size()); g[1].DesiredSize.Should().Be(new Size()); g.DesiredSize.Should().Be(new Size()); g.Arrange(new Rectangle(10, 20, 400, 300)); g[0].DesiredSize.Should().Be(new Size()); g[1].DesiredSize.Should().Be(new Size()); g[0].LayoutInvalid.Should().Be(false); g[1].LayoutInvalid.Should().Be(false); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 0, 0)); g[1].LayoutRect.Should().Be(new Rectangle(10, 20, 0, 0)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 0, 0)); }