Esempio n. 1
0
            public HStackPanel(LayoutScope <T> scope, LayoutView <T>[] views, float spacing)
            {
                Debug.Assert(views.Length > 1);

                _scope   = scope;
                _views   = views;
                _spacing = spacing;
            }
Esempio n. 2
0
        public static LayoutView <T> Grid <T>(this LayoutScope <T> scope, GridDefinition grid, params GridLayoutView <T>[] views)
        {
            if (views.Length == 0)
            {
                return(LayoutView <T> .None);
            }

            return(new GridPanel <T>(scope, grid, views).ToLayoutView());
        }
Esempio n. 3
0
        public override void LayoutSubviews()
        {
            var scope = new LayoutScope <UIView>(LayoutAdapter.Instance);
            var root  = LayoutHandler?.Invoke(scope);

            if (root != null)
            {
                var frame = Frame;
                scope.Arrange(root.Value, (float)frame.X, (float)frame.Y, (float)frame.Width, (float)frame.Height);
            }
        }
Esempio n. 4
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            var scope   = new LayoutScope <View>(LayoutAdapter.Instance);
            var handler = LayoutHandler;

            if (handler != null)
            {
                var root = handler.Invoke(scope);
                scope.Arrange(ref root, l, t, r - l, b - t);
            }
        }
Esempio n. 5
0
        protected override Windows.Foundation.Size ArrangeOverride(Windows.Foundation.Size finalSize)
        {
            var scope = new LayoutScope <UIElement>(LayoutAdapter.Instance);
            var root  = LayoutHandler?.Invoke(scope);

            if (root != null)
            {
                scope.Arrange(root.Value, 0, 0, (float)finalSize.Width, (float)finalSize.Height);
            }

            return(base.ArrangeOverride(finalSize));
        }
Esempio n. 6
0
        public static LayoutView <T> StackVertically <T>(this LayoutScope <T> scope, LayoutView <T>[] views, float spacing = 0)
        {
            if (views.Length == 0)
            {
                return(LayoutView <T> .None);
            }
            if (views.Length == 1)
            {
                return(views[0]);
            }

            return(new VStackPanel <T>(scope, views, spacing).ToLayoutView());
        }
Esempio n. 7
0
        public static LayoutView <T> StackHorizontally <T>(this LayoutScope <T> scope, float spacing, params LayoutView <T>[] views)
        {
            if (views.Length == 0)
            {
                return(LayoutView <T> .None);
            }
            if (views.Length == 1)
            {
                return(views[0]);
            }

            return(new HStackPanel <T>(scope, views, spacing).ToLayoutView());
        }
Esempio n. 8
0
            public GridPanel(LayoutScope <T> scope, GridDefinition grid, GridLayoutView <T>[] views)
            {
                Debug.Assert(views.Length > 0);

                _scope = scope;
                _grid  = grid ?? GridDefinition.Default;
                _views = views;

                var columnCount = _grid.Columns.Count;
                var rowCount    = _grid.Rows.Count;

                _columnWidths = new float[columnCount];
                _rowHeights   = new float[rowCount];

                for (var i = 0; i < _views.Length; i++)
                {
                    if (_views[i].Column < 0)
                    {
                        _views[i].Column = 0;
                    }
                    if (_views[i].ColumnSpan <= 0)
                    {
                        _views[i].ColumnSpan = 1;
                    }
                    if (_views[i].Column + _views[i].ColumnSpan > columnCount)
                    {
                        _views[i].ColumnSpan = columnCount - _views[i].Column;
                    }
                    if (_views[i].ColumnSpan > _maxColumnSpan)
                    {
                        _maxColumnSpan = _views[i].ColumnSpan;
                    }

                    if (_views[i].Row < 0)
                    {
                        _views[i].Row = 0;
                    }
                    if (_views[i].RowSpan <= 0)
                    {
                        _views[i].RowSpan = 1;
                    }
                    if (_views[i].Row + _views[i].RowSpan > rowCount)
                    {
                        _views[i].RowSpan = rowCount - _views[i].Row;
                    }
                    if (_views[i].RowSpan > _maxRowSpan)
                    {
                        _maxRowSpan = _views[i].RowSpan;
                    }
                }
            }
Esempio n. 9
0
        protected override Windows.Foundation.Size MeasureOverride(Windows.Foundation.Size availableSize)
        {
            var scope = new LayoutScope <UIElement>(LayoutAdapter.Instance);
            var root  = LayoutHandler?.Invoke(scope);

            if (root != null)
            {
                var size = scope.Measure(root.Value, (float)availableSize.Width, (float)availableSize.Height);

                return(new Windows.Foundation.Size(size.Width, size.Height));
            }

            return(base.MeasureOverride(availableSize));
        }
Esempio n. 10
0
        public static Rectangle[] Layout(float width, float height, Func <LayoutScope <Size>, LayoutView <Size> > layoutHandler)
        {
            var adapter = new TestLayoutAdapter();

            var scope = new LayoutScope <Size>(adapter);

            var root = layoutHandler(scope);

            if ((root.View.Width != 0 && root.View.Height != 0) || root.Panel != null)
            {
                scope.Arrange(ref root, 0, 0, width, height);
            }

            return(adapter.ArrangedRectangles.ToArray());
        }
Esempio n. 11
0
 public BasicPanel(LayoutScope <T> scope, LayoutView <T>[] views)
 {
     _scope = scope;
     _views = views;
 }
Esempio n. 12
0
 public static LayoutView <T> WithViews <T>(this LayoutScope <T> scope, params LayoutView <T>[] views)
 {
     return(new BasicPanel <T>(scope, views).ToLayoutView());
 }