Exemple #1
0
        protected float ProcessChildsHAlign(ILayout childLayout, float contentWidth)
        {
            float xPos = 0;

            switch (childLayout.HorizontalAlign)
            {
            case HorizontalAlign.None:
                xPos = childLayout.X;
                break;

            case HorizontalAlign.Left:
                xPos = 0;
                break;

            case HorizontalAlign.Center:
                xPos = (contentWidth - childLayout.GetCalculatedWidth()) * 0.5f;
                break;

            case HorizontalAlign.Right:
                xPos = contentWidth - childLayout.GetCalculatedWidth();
                break;
            }
            return(xPos);
        }
Exemple #2
0
        protected virtual void CalculateChild(ILayout childLayout, float x, float y, float contentWidth, float contentHeight, float absoluteX, float absoluteY)
        {
            // check if item has a percentual width
            var calcedWidth = childLayout.HasPercentualWidth ? contentWidth * childLayout.PercentualWidth : childLayout.GetCalculatedWidth();
            // check if item hat a percentual height
            var calcedHeight = childLayout.HasPercentualHeight ? contentHeight * childLayout.PercentualHeight : childLayout.GetCalculatedHeight();

            var processingData = childLayout.GetProcessingData();

            processingData.SetAbsoluteGeometry(absoluteX, absoluteY, calcedWidth, calcedHeight);
            processingData.SetDrawingGeometry(x, y, calcedWidth, calcedHeight);
            processingData.SetClipRect(absoluteX, absoluteY, calcedWidth, calcedHeight);

            if (childLayout is IContainerLayout)
            {
                ((IContainerLayout)childLayout).CalculateChildLayouts(x, y, calcedWidth, calcedHeight, absoluteX, absoluteY);
            }
        }