Example #1
0
        public void EmptyStarColumnInfiniteWidthMeasure()
        {
            var grid         = CreateGridLayout(rows: "auto", columns: $"*");
            var manager      = new GridLayoutManager(grid);
            var measuredSize = manager.Measure(double.PositiveInfinity, double.PositiveInfinity);

            Assert.Equal(0, measuredSize.Width);
        }
Example #2
0
        public void EmptyStarRowInfiniteHeightMeasure()
        {
            var grid         = CreateGridLayout(rows: "*", columns: $"auto");
            var manager      = new GridLayoutManager(grid);
            var measuredSize = manager.Measure(double.PositiveInfinity, double.PositiveInfinity);

            Assert.Equal(0, measuredSize.Height);
        }
Example #3
0
        Size MeasureAndArrange(IGridLayout grid, double widthConstraint = double.PositiveInfinity, double heightConstraint = double.PositiveInfinity)
        {
            var manager      = new GridLayoutManager(grid);
            var measuredSize = manager.Measure(widthConstraint, heightConstraint);

            manager.ArrangeChildren(new Rectangle(Point.Zero, measuredSize));

            return(measuredSize);
        }
        public Size Measure(double widthConstraint, double heightConstraint)
        {
            // We have to rebuild this every time because the StackLayout contents
            // and values may have changed
            _gridLayout?.Clear();
            _gridLayout = Gridify(_stackLayout);
            _manager    = new GridLayoutManager(_gridLayout);

            return(_manager.Measure(widthConstraint, heightConstraint));
        }
Example #5
0
        public void StarColumnWithViewInfiniteWidthMeasure()
        {
            var grid  = CreateGridLayout(rows: "auto", columns: $"*");
            var view0 = CreateTestView(new Size(100, 50));

            AddChildren(grid, view0);
            SetLocation(grid, view0);

            var manager      = new GridLayoutManager(grid);
            var measuredSize = manager.Measure(double.PositiveInfinity, double.PositiveInfinity);

            Assert.Equal(100, measuredSize.Width);
            Assert.Equal(50, measuredSize.Height);
        }
Example #6
0
        public void CanSpanAbsoluteRows()
        {
            var grid  = CreateGridLayout(rows: "100,100", columns: "auto");
            var view0 = CreateTestView(new Size(100, 150));

            AddChildren(grid, view0);
            SetLocation(grid, view0, rowSpan: 2);
            var manager = new GridLayoutManager(grid);

            manager.Measure(100, 200);
            manager.ArrangeChildren(new Rectangle(0, 0, 100, 200));

            // View should be arranged to span both rows (200 points)
            AssertArranged(view0, 0, 0, 100, 200);
        }
Example #7
0
        public void MeasureTwoColumnsWithSpacing()
        {
            var grid  = CreateGridLayout(columns: "100, 100", colSpacing: 10);
            var view0 = CreateTestView(new Size(100, 100));
            var view1 = CreateTestView(new Size(100, 100));

            AddChildren(grid, view0, view1);
            SetLocation(grid, view0);
            SetLocation(grid, view1, col: 1);

            var manager = new GridLayoutManager(grid);
            var measure = manager.Measure(double.PositiveInfinity, double.PositiveInfinity);

            Assert.Equal(100 + 100 + 10, measure.Width);
        }
Example #8
0
        public void ColumnSpacingForEmptyColumns()
        {
            var grid  = CreateGridLayout(columns: "100, auto, 100", colSpacing: 10);
            var view0 = CreateTestView(new Size(100, 100));
            var view2 = CreateTestView(new Size(100, 100));

            AddChildren(grid, view0, view2);
            SetLocation(grid, view0);
            SetLocation(grid, view2, col: 2);

            var manager = new GridLayoutManager(grid);
            var measure = manager.Measure(double.PositiveInfinity, double.PositiveInfinity);

            // Because the auto column has no content, we expect it to have height zero
            // and we expect that it won't add more row spacing
            Assert.Equal(100 + 100 + 10, measure.Width);
        }
Example #9
0
        public void EmptyAutoColumnsHaveNoWidth()
        {
            var grid  = CreateGridLayout(columns: "100, auto, 100");
            var view0 = CreateTestView(new Size(100, 100));
            var view2 = CreateTestView(new Size(100, 100));

            AddChildren(grid, view0, view2);
            SetLocation(grid, view0);
            SetLocation(grid, view2, col: 2);

            var manager = new GridLayoutManager(grid);
            var measure = manager.Measure(double.PositiveInfinity, double.PositiveInfinity);

            manager.ArrangeChildren(new Rectangle(0, 0, measure.Width, measure.Height));

            // Because the auto column has no content, we expect it to have width zero
            Assert.Equal(100 + 100, measure.Width);

            // Verify the offset for the third column
            AssertArranged(view2, 100, 0, 100, 100);
        }