示例#1
0
        Rectangle ArrangeRight(Rectangle layoutSize)
        {
            if (layoutSize.Width >= FirstPaneMinSize + SecondPaneMinSize)
            {
                SplitterOffset = MathHelper.Clamp(SplitterOffset, SecondPaneMinSize, layoutSize.Width - FirstPaneMinSize);
            }

            var splitterBarWidth = splitterBar.DesiredSize.WidthInt;

            if (Collapsed && collapseAnim.IsOver)
            {
                displayFirstPane  = true;
                displaySecondPane = false;

                layoutSize.Width = Math.Max(layoutSize.Width, splitterBarWidth + FirstPaneMinSize);

                var arr = new ArrangerHorizontal(layoutSize);
                arr.Reserve(splitterBarWidth).Arrange(FirstPane, arr.AvailableWidth).Advance(arr.AvailableWidth);
                arr.Arrange(splitterBar, splitterBarWidth).AdvanceReserved(splitterBarWidth);
                return(layoutSize);
            }

            displayFirstPane  = true;
            displaySecondPane = true;

            layoutSize.Width = Math.Max(layoutSize.Width, FirstPaneMinSize + splitterBarWidth + SecondPaneMinSize);
            var animatedSplitterPos = (int)MathHelper.Clamp((1f - collapseAnim.CurrentValue) * SplitterOffset, 0, SplitterOffset);

            var arr2 = new ArrangerHorizontal(layoutSize);

            arr2.Reserve(animatedSplitterPos);
            arr2.Reserve(splitterBarWidth);
            arr2.Arrange(FirstPane, arr2.AvailableWidth).Advance(arr2.AvailableWidth);
            arr2.Arrange(splitterBar, splitterBarWidth).AdvanceReserved(splitterBarWidth);
            arr2.Arrange(SecondPane, SplitterOffset).AdvanceReserved(animatedSplitterPos);
            return(layoutSize);
        }
示例#2
0
        protected override Rectangle ArrangeOverride(Rectangle layoutSize)
        {
            if (string.IsNullOrEmpty(Label.Text))
            {
                Image.Arrange(layoutSize);
                return(Image.LayoutRect);
            }

            if (!Image.HasTexture)
            {
                Label.Arrange(layoutSize);
                return(Label.LayoutRect);
            }

            var actualWidth = DesiredSize.WidthInt;

            var center = layoutSize.Center;
            int left;
            int spaceToRight;

            switch (Label.Alignment)
            {
            case Alignment.Start:
            case Alignment.Fill:
            {
                left         = layoutSize.X;
                spaceToRight = Math.Max(0, layoutSize.Width - actualWidth);
                break;
            }

            case Alignment.Center:
            {
                left         = center.X - actualWidth / 2;
                spaceToRight = Math.Max(0, layoutSize.Width - (center.X + actualWidth / 2));
            }
            break;

            case Alignment.End:
            {
                left         = layoutSize.Right - actualWidth;
                spaceToRight = 0;
                break;
            }

            default:
            {
                throw new NotSupportedException();
            }
            }

            var arr = new ArrangerHorizontal(layoutSize);

            arr.Advance(left - layoutSize.X);
            arr.Reserve(spaceToRight);
            arr.Arrange(Image, Image.DesiredSize.WidthInt).Advance(Image.DesiredSize.WidthInt);
            arr.Advance(IconTextGap);
            arr.Arrange(Label, arr.AvailableWidth);

            var x      = Image.LayoutRect.X;
            var y      = Math.Min(Image.LayoutRect.Y, Label.LayoutRect.Y);
            var width  = Math.Max(0, Label.LayoutRect.Right - Image.LayoutRect.X);
            var height = Math.Max(0, Math.Max(Image.LayoutRect.Bottom, Label.LayoutRect.Bottom) - y);

            return(new Rectangle(x, y, width, height));
        }