コード例 #1
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);
        }
コード例 #2
0
ファイル: GuiBox.cs プロジェクト: Warnestam/MonoGUI
        protected override void DoDraw(SpriteBatch spriteBatch, GuiPoint point, Rectangle clipRect)
        {
            Rectangle r = new Rectangle(
                point.X + Offset.X,
                point.Y + Offset.Y,
                RenderSize.Width,
                RenderSize.Height);

            if (BackgroundColor != Color.Transparent)
            {
                GuiPainter.DrawRectangle(spriteBatch, r, BackgroundColor, fTexture);
            }
            base.DoDraw(spriteBatch, point, clipRect);
        }
コード例 #3
0
ファイル: GuiBorder.cs プロジェクト: Warnestam/MonoGUI
        protected override void DoDraw(SpriteBatch spriteBatch, GuiPoint point, Rectangle clipRect)
        {
            int outerX0     = point.X + Offset.X;
            int outerY0     = point.Y + Offset.Y;
            int innerX0     = outerX0 + Border.Left;
            int innerY0     = outerY0 + Border.Top;
            int outerWidth  = RenderSize.Width;
            int outerHeight = RenderSize.Height;
            int innerWidth  = outerWidth - Border.Width;
            int innerHeigth = outerHeight - Border.Height;

            if (BorderColor != Color.Transparent)
            {
                Rectangle topRect    = new Rectangle(outerX0, outerY0, outerWidth - Border.Right, Border.Top);
                Rectangle bottomRect = new Rectangle(innerX0, outerY0 + innerHeigth + Border.Top, outerWidth, Border.Bottom);
                Rectangle leftRect   = new Rectangle(outerX0, innerY0, Border.Left, outerHeight);
                Rectangle rightRect  = new Rectangle(outerX0 + innerWidth + Border.Left, outerY0, Border.Right, outerHeight - Border.Bottom);
                if (Border.Top > 0)
                {
                    GuiPainter.DrawRectangle(spriteBatch, topRect, BorderColor, fTexture);
                }
                if (Border.Bottom > 0)
                {
                    GuiPainter.DrawRectangle(spriteBatch, bottomRect, BorderColor, fTexture);
                }
                if (Border.Left > 0)
                {
                    GuiPainter.DrawRectangle(spriteBatch, leftRect, BorderColor, fTexture);
                }
                if (Border.Right > 0)
                {
                    GuiPainter.DrawRectangle(spriteBatch, rightRect, BorderColor, fTexture);
                }
            }
            if (BackgroundColor != Color.Transparent)
            {
                Rectangle innerRect = new Rectangle(innerX0, innerY0, innerWidth, innerHeigth);
                GuiPainter.DrawRectangle(spriteBatch, innerRect, BackgroundColor, fTexture);
            }
            if (Content != null)
            {
                Rectangle childRect = new Rectangle(clipRect.Left + Border.Left, clipRect.Top + Border.Top, innerWidth, innerHeigth);

                Content.Draw(spriteBatch, new GuiPoint(point.X + Offset.X + Border.Left, point.Y + Offset.Y + Border.Top), childRect);
            }
            //base.DoDraw(spriteBatch, point, clipRect);
        }
コード例 #4
0
        protected override void DoDraw(SpriteBatch spriteBatch, GuiPoint point, Rectangle clipRect)
        {
            Rectangle r = new Rectangle(
                point.X + Offset.X,
                point.Y + Offset.Y,
                RenderSize.Width,
                RenderSize.Height);

            if (BackgroundColor != Color.Transparent)
            {
                GuiPainter.DrawRectangle(spriteBatch, r, BackgroundColor, fTexture);
            }
            if (Childs != null)
            {
                foreach (var child in Childs)
                {
                    GuiPoint childPoint = new GuiPoint(
                        point.X + Offset.X + child.X,
                        point.Y + Offset.Y + child.Y);
                    child.Control.Draw(spriteBatch, childPoint, clipRect);
                }
            }
        }