Esempio n. 1
0
File: VBox.cs Progetto: AcK77/Ngco
        public override void Measure(Size region)
        {
            Size rowSize     = new Size(region.Width, region.Height / Children.Count);
            Rect bb          = new Rect(new Point(), new Size());
            Size contentSize = new Size();

            for (int i = 0; i < Children.Count; i++)
            {
                BaseWidget widget = Children[i];
                widget.Measure(rowSize);

                if (i == 0)
                {
                    contentSize.Width  = Math.Max(contentSize.Width, widget.BoundingBox.Size.Width);
                    contentSize.Height = contentSize.Height + widget.BoundingBox.Size.Height;
                }
                else
                {
                    contentSize.Width  = Math.Max(contentSize.Width, widget.BoundingBox.Size.Width);
                    contentSize.Height = contentSize.Height + widget.BoundingBox.Size.Height + Style.Layout.Spacing;
                }
            }

            Size paddedSize = new Size(contentSize.Width + Style.Layout.Padding.Left + Style.Layout.Padding.Right,
                                       contentSize.Height + Style.Layout.Padding.Up + Style.Layout.Padding.Down);

            BoundingBox = bb;

            SetSize(paddedSize);
            ApplyLayoutSize();
        }