Esempio n. 1
0
        protected internal virtual void RecalculateSelf()
        {
            float baseX;
            float baseY;
            float baseWidth;
            float baseHeight;

            if (Parent == null)
            {
                baseX      = 0;
                baseY      = 0;
                baseWidth  = Main.screenWidth;
                baseHeight = Main.screenHeight;
            }
            else
            {
                baseX      = Parent.InnerX;
                baseY      = Parent.InnerY;
                baseWidth  = Parent.InnerWidth;
                baseHeight = Parent.InnerHeight;
            }
            InnerWidth        = Width.CalculateValue(baseWidth);
            InnerHeight       = Height.CalculateValue(baseHeight);
            PadWidth          = InnerWidth + Padding.Left + Padding.Right;
            PadHeight         = InnerHeight + Padding.Top + Padding.Bottom;
            OuterWidth        = PadWidth + Margin.Left + Margin.Right;
            OuterHeight       = PadHeight + Margin.Top + Margin.Bottom;
            CalculatedXOffset = XOffset.CalculateValue(baseWidth);
            OuterX            = baseX + CalculatedXOffset;
            if (HorizontalAlign != 0f)
            {
                OuterX += (baseWidth - OuterWidth) * HorizontalAlign;
            }
            CalculatedYOffset = YOffset.CalculateValue(baseHeight);
            OuterY            = baseY + CalculatedYOffset;
            if (VerticalAlign != 0f)
            {
                OuterY += (baseHeight - OuterHeight) * VerticalAlign;
            }
            if (Parent is UIContainer container)
            {
                OuterY -= container.ScrollValue;
            }
            PadX   = OuterX + Margin.Left;
            PadY   = OuterY + Margin.Top;
            InnerX = PadX + Padding.Left;
            InnerY = PadY + Padding.Top;
        }