Esempio n. 1
0
        protected override GuiSize DoArrange(GuiSize arrangeSize)
        {
            GuiMinMax mm = new GuiMinMax(this);

            arrangeSize.Width  = Math.Max(mm.minWidth, Math.Min(arrangeSize.Width, mm.maxWidth));
            arrangeSize.Height = Math.Max(mm.minHeight, Math.Min(arrangeSize.Height, mm.maxHeight));

            if (Childs != null && Childs.Count > 0)
            {
                int offsetY    = 0;
                int childLeft  = Childs.Count;
                int heightLeft = arrangeSize.Height;
                foreach (var child in Childs)
                {
                    int childHeight = child.DesiredSize.Height;
                    //if (childLeft > 1)
                    //{
                    //    childHeight = heightLeft / childLeft;
                    //}
                    //else
                    //{
                    //    childHeight = heightLeft;
                    //}
                    GuiRect childRect = new GuiRect(FinalRect.X + Margin.Left, FinalRect.Y + Margin.Top + offsetY, arrangeSize.Width, childHeight);
                    child.Arrange(childRect);
                    offsetY    += childHeight;
                    heightLeft -= childHeight;
                    childLeft--;
                }
            }

            return(arrangeSize);
        }
Esempio n. 2
0
        protected override GuiSize DoMeasure(GuiSize availableSize)
        {
            GuiSize frameworkAvailableSize = new GuiSize(availableSize.Width, availableSize.Height);

            GuiMinMax mm = new GuiMinMax(this);

            frameworkAvailableSize.Width  = Math.Max(mm.minWidth, Math.Min(frameworkAvailableSize.Width, mm.maxWidth));
            frameworkAvailableSize.Height = Math.Max(mm.minHeight, Math.Min(frameworkAvailableSize.Height, mm.maxHeight));

            GuiSize desiredSize = frameworkAvailableSize;// MeasureOverrideHelper(frameworkAvailableSize);

            if (Content != null)
            {
                Content.Measure(frameworkAvailableSize);
                desiredSize = Content.DesiredSize;
            }
            else
            {
                //desiredSize = new GuiSize(0, 0);
            }

            //  maximize desiredSize with user provided min size
            desiredSize = new GuiSize(
                Math.Max(desiredSize.Width, mm.minWidth),
                Math.Max(desiredSize.Height, mm.minHeight));

            return(desiredSize);
        }
Esempio n. 3
0
        protected override GuiSize DoMeasure(GuiSize constraint)
        {
            int maxWidth  = 0;
            int maxHeight = 0;

            if (Childs != null)
            {
                foreach (var child in Childs)
                {
                    GuiSize childConstraint = new GuiSize(
                        Math.Max(0, constraint.Width),
                        Math.Max(0, constraint.Height));

                    child.Control.Measure(childConstraint);
                    GuiSize childDesiredSize = child.Control.DesiredSize;

                    if ((childDesiredSize.Width + child.X) > maxWidth)
                    {
                        maxWidth = childDesiredSize.Width + child.X;
                    }
                    if ((childDesiredSize.Height + child.Y) > maxHeight)
                    {
                        maxHeight = childDesiredSize.Height + child.Y;
                    }
                }
            }
            return(new GuiSize(maxWidth, maxHeight));
        }
Esempio n. 4
0
        private GuiSize MeasureStack(GuiSize constraint)
        {
            GuiSize stackDesiredSize = new GuiSize();

            if (Childs != null)
            {
                GuiSize layoutSlotSize = constraint;
                foreach (var child in Childs)
                {
                    child.Control.Measure(layoutSlotSize);
                    GuiSize childDesiredSize = child.Control.DesiredSize;
                    if (Orientation == GuiStackPanelOrientation.Horizontal)
                    {
                        stackDesiredSize.Width += childDesiredSize.Width;
                        stackDesiredSize.Height = Math.Max(stackDesiredSize.Height, childDesiredSize.Height);
                        layoutSlotSize.Width   -= childDesiredSize.Width;
                    }
                    else
                    {
                        stackDesiredSize.Width   = Math.Max(stackDesiredSize.Width, childDesiredSize.Width);
                        stackDesiredSize.Height += childDesiredSize.Height;
                        layoutSlotSize.Height   -= childDesiredSize.Height;
                    }
                }
            }
            return(stackDesiredSize);
        }
Esempio n. 5
0
 protected override GuiSize DoArrange(GuiSize arrangeSize)
 {
     foreach (var child in Childs)
     {
         GuiSize childDesiredSize = child.Control.DesiredSize;
         child.Control.Arrange(childDesiredSize);
     }
     return(arrangeSize);
 }
Esempio n. 6
0
        protected override GuiSize DoArrange(GuiSize arrangeSize)
        {
            GuiMinMax mm = new GuiMinMax(this);

            arrangeSize.Width  = Math.Max(mm.minWidth, Math.Min(arrangeSize.Width, mm.maxWidth));
            arrangeSize.Height = Math.Max(mm.minHeight, Math.Min(arrangeSize.Height, mm.maxHeight));

            fDockPanel.Arrange(arrangeSize);

            return(arrangeSize);
        }
Esempio n. 7
0
        protected override GuiSize DoArrange(GuiSize arrangeSize)
        {
            int totalChildrenCount   = Childs.Count;
            int nonFillChildrenCount = totalChildrenCount - (LastChildFill ? 1 : 0);

            int accumulatedLeft   = 0;
            int accumulatedTop    = 0;
            int accumulatedRight  = 0;
            int accumulatedBottom = 0;

            for (int i = 0; i < totalChildrenCount; ++i)
            {
                GuiDockChild child            = Childs[i];
                GuiSize      childDesiredSize = child.Control.DesiredSize;
                GuiRect      rcChild          = new GuiRect(
                    accumulatedLeft,
                    accumulatedTop,
                    Math.Max(0, arrangeSize.Width - (accumulatedLeft + accumulatedRight)),
                    Math.Max(0, arrangeSize.Height - (accumulatedTop + accumulatedBottom)));

                if (i < nonFillChildrenCount)
                {
                    switch (child.Dock)
                    {
                    case GuiDock.Left:
                        accumulatedLeft += childDesiredSize.Width;
                        rcChild.Width    = childDesiredSize.Width;
                        break;

                    case GuiDock.Right:
                        accumulatedRight += childDesiredSize.Width;
                        rcChild.X         = Math.Max(0, arrangeSize.Width - accumulatedRight);
                        rcChild.Width     = childDesiredSize.Width;
                        break;

                    case GuiDock.Top:
                        accumulatedTop += childDesiredSize.Height;
                        rcChild.Height  = childDesiredSize.Height;
                        break;

                    case GuiDock.Bottom:
                        accumulatedBottom += childDesiredSize.Height;
                        rcChild.Y          = Math.Max(0, arrangeSize.Height - accumulatedBottom);
                        rcChild.Height     = childDesiredSize.Height;
                        break;
                    }
                }
                child.Control.Arrange(new GuiSize(rcChild.Width, rcChild.Height));
                child.ContainerPosition = new GuiPoint(rcChild.Left, rcChild.Top);
            }
            return(arrangeSize);
        }
Esempio n. 8
0
        protected override GuiSize DoArrange(GuiSize arrangeSize)
        {
            GuiSize  childSize          = new GuiSize(arrangeSize.Width, arrangeSize.Height);
            GuiSize  childSizeAvailable = new GuiSize(arrangeSize.Width, arrangeSize.Height);
            GuiPoint childPosition      = new GuiPoint();
            int      previousChildSize  = 0;

            if (Childs != null)
            {
                foreach (var child in Childs)
                {
                    if (Orientation == GuiStackPanelOrientation.Horizontal)
                    {
                        childPosition.X  += previousChildSize;
                        previousChildSize = child.Control.DesiredSize.Width;
                        childSize.Width   = previousChildSize;
                        childSize.Height  = Math.Max(arrangeSize.Height, child.Control.DesiredSize.Height);

                        if (childSize.Width > childSizeAvailable.Width)
                        {
                            childSize.Width = childSizeAvailable.Width;
                        }
                        if (childSize.Height > childSizeAvailable.Height)
                        {
                            childSize.Height = childSizeAvailable.Height;
                        }
                        childSizeAvailable.Width -= childSize.Width;
                    }
                    else
                    {
                        childPosition.Y  += previousChildSize;
                        previousChildSize = child.Control.DesiredSize.Height;
                        childSize.Height  = previousChildSize;
                        childSize.Width   = Math.Max(arrangeSize.Width, child.Control.DesiredSize.Width);

                        if (childSize.Width > childSizeAvailable.Width)
                        {
                            childSize.Width = childSizeAvailable.Width;
                        }
                        if (childSize.Height > childSizeAvailable.Height)
                        {
                            childSize.Height = childSizeAvailable.Height;
                        }
                        childSizeAvailable.Height -= childSize.Height;
                    }
                    child.Control.Arrange(childSize);
                    child.ContainerPosition = childPosition;
                }
            }
            return(arrangeSize);
        }
Esempio n. 9
0
        protected override GuiSize DoArrange(GuiSize arrangeSize)
        {
            GuiMinMax mm = new GuiMinMax(this);

            arrangeSize.Width  = Math.Max(mm.minWidth, Math.Min(arrangeSize.Width, mm.maxWidth));
            arrangeSize.Height = Math.Max(mm.minHeight, Math.Min(arrangeSize.Height, mm.maxHeight));

            if (Content != null)
            {
                Content.Arrange(arrangeSize);
            }

            return(arrangeSize);
        }
Esempio n. 10
0
        protected override GuiSize DoMeasure(GuiSize availableSize)
        {
            GuiSize   frameworkAvailableSize = new GuiSize(availableSize.Width, availableSize.Height);
            GuiMinMax mm = new GuiMinMax(this);

            frameworkAvailableSize.Width  = Math.Max(mm.minWidth, Math.Min(frameworkAvailableSize.Width, mm.maxWidth));
            frameworkAvailableSize.Height = Math.Max(mm.minHeight, Math.Min(frameworkAvailableSize.Height, mm.maxHeight));
            GuiSize desiredSize = new GuiSize(frameworkAvailableSize.Width, 0);;

            if (Childs != null && Childs.Count > 0)
            {
                int childLeft  = Childs.Count;
                int heightLeft = availableSize.Height;
                foreach (var child in Childs)
                {
                    int childHeight;
                    if (childLeft > 1)
                    {
                        childHeight = heightLeft / childLeft;
                    }
                    else
                    {
                        childHeight = heightLeft;
                    }
                    //GuiSize childSize = new GuiSize(frameworkAvailableSize.Width, 0);
                    GuiSize childSize = new GuiSize(availableSize.Width, childHeight);
                    child.Measure(childSize);
                    desiredSize.Height += child.DesiredSize.Height;
                    heightLeft         -= child.DesiredSize.Height;

                    childLeft--;
                }
            }


            //  maximize desiredSize with user provided min size
            desiredSize = new GuiSize(
                Math.Max(desiredSize.Width, mm.minWidth),
                Math.Max(desiredSize.Height, mm.minHeight));

            return(desiredSize);
        }
Esempio n. 11
0
        protected override GuiSize DoMeasure(GuiSize availableSize)
        {
            GuiSize frameworkAvailableSize = new GuiSize(availableSize.Width, availableSize.Height);

            GuiMinMax mm = new GuiMinMax(this);

            frameworkAvailableSize.Width  = Math.Max(mm.minWidth, Math.Min(frameworkAvailableSize.Width, mm.maxWidth));
            frameworkAvailableSize.Height = Math.Max(mm.minHeight, Math.Min(frameworkAvailableSize.Height, mm.maxHeight));

            GuiSize desiredSize = frameworkAvailableSize;// MeasureOverrideHelper(frameworkAvailableSize);


            fDockPanel.Measure(frameworkAvailableSize);

            //  maximize desiredSize with user provided min size
            desiredSize = new GuiSize(
                Math.Max(desiredSize.Width, mm.minWidth),
                Math.Max(desiredSize.Height, mm.minHeight));

            return(desiredSize);
        }
Esempio n. 12
0
        protected override GuiSize DoMeasure(GuiSize constraint)
        {
            int parentWidth       = 0;
            int parentHeight      = 0;
            int accumulatedWidth  = 0;
            int accumulatedHeight = 0;

            if (Childs != null)
            {
                foreach (var child in Childs)
                {
                    GuiSize childConstraint = new GuiSize(
                        Math.Max(0, constraint.Width - accumulatedWidth),
                        Math.Max(0, constraint.Height - accumulatedHeight));

                    child.Control.Measure(childConstraint);
                    GuiSize childDesiredSize = child.Control.DesiredSize;

                    switch (child.Dock)
                    {
                    case GuiDock.Left:
                    case GuiDock.Right:
                        parentHeight      = Math.Max(parentHeight, accumulatedHeight + childDesiredSize.Height);
                        accumulatedWidth += childDesiredSize.Width;
                        break;

                    case GuiDock.Top:
                    case GuiDock.Bottom:
                        parentWidth        = Math.Max(parentWidth, accumulatedWidth + childDesiredSize.Width);
                        accumulatedHeight += childDesiredSize.Height;
                        break;
                    }
                }
            }
            parentWidth  = Math.Max(parentWidth, accumulatedWidth);
            parentHeight = Math.Max(parentHeight, accumulatedHeight);

            return(new GuiSize(parentWidth, parentHeight));
        }
Esempio n. 13
0
        protected override GuiSize DoMeasure(GuiSize constraint)
        {
            GuiSize desiredSize = MeasureStack(constraint);

            return(desiredSize);
        }