Ejemplo n.º 1
0
        private void Wrap(View parentView)
        {
            Rectangle container    = parentView.ContentBoundBox;
            int       xDone        = container.Left - parentView.RealX;
            int       yDone        = container.Top - parentView.RealY;
            View      tallestChild = null;
            bool      nullify      = false;
            int       furthestDown = 0;

            foreach (View v in parentView.Children)
            {
                if (nullify)
                {
                    tallestChild = null;                     //this is per-column
                    nullify      = false;
                }
                v.Position.Value = Vector2.Zero;
                if (ExcludedChildren.Contains(v))
                {
                    continue;
                }

                if (tallestChild == null || v.BoundBox.Height > tallestChild.BoundBox.Height)
                {
                    tallestChild = v;
                }

                //Wrapping around has never felt so good
                if (v.BoundBox.Right + xDone > container.Right - parentView.X)
                {
                    xDone = container.Left - parentView.X;
                    int addHeight = tallestChild.BoundBox.Height + _paddingBetweenVertical;
                    if (_resizeParentToFit)
                    {
                        int neededHeight = addHeight + yDone + v.BoundBox.Height;
                        if (neededHeight > parentView.ContentBoundBox.Height)
                        {
                            int theHeight = (neededHeight - parentView.ContentBoundBox.Height);
                            parentView.Height.Value += theHeight;
                            tallestChild             = v;
                        }
                    }
                    yDone  += tallestChild.BoundBox.Height + _paddingBetweenVertical;
                    nullify = true;
                }

                v.Position.Value = new Vector2(xDone, yDone);
                xDone           += v.BoundBox.Width + _paddingBetweenHorizontal;
                if (tallestChild == v)
                {
                    furthestDown = v.AbsoluteBoundBox.Bottom - parentView.AbsoluteContentBoundBox.Top;
                }
            }
            if (_resizeParentToFit)
            {
                parentView.Height.Value = furthestDown + 1;
            }
        }
Ejemplo n.º 2
0
        private void NoWrap(View parentView)
        {
            Rectangle container = parentView.ContentBoundBox;
            int       xDone     = container.Left - parentView.RealX;

            foreach (View v in parentView.Children)
            {
                v.Position.Value = Vector2.Zero;
                if (ExcludedChildren.Contains(v))
                {
                    continue;
                }
                v.Position.Value = new Vector2(xDone, container.Top - parentView.RealY);
                xDone           += v.BoundBox.Width + _paddingBetweenHorizontal;
            }
        }
Ejemplo n.º 3
0
        private void NoWrap(View parentView)
        {
            Rectangle container = parentView.ContentBoundBox;
            int       yDone     = container.Top - parentView.RealY;

            foreach (View v in parentView.Children)
            {
                if (!v.Active)
                {
                    continue;
                }
                v.Position.Value = Vector2.Zero;
                if (ExcludedChildren.Contains(v))
                {
                    continue;
                }
                v.Position.Value = new Vector2(container.Left - parentView.RealX, yDone);
                yDone           += v.BoundBox.Height + _paddingBetweenVertical;
            }
        }
Ejemplo n.º 4
0
        private void Wrap(View parentView)
        {
            Rectangle container     = parentView.ContentBoundBox;
            int       xDone         = container.Left - parentView.RealX;
            int       yDone         = container.Top - parentView.RealY;
            View      widestChild   = null;
            bool      nullify       = false;
            int       furthestRight = 0;

            foreach (View v in parentView.Children)
            {
                if (!v.Active)
                {
                    continue;
                }
                if (nullify)
                {
                    //widestChild = null; //this is per-column
                    nullify = false;
                }
                v.Position.Value = Vector2.Zero;
                if (ExcludedChildren.Contains(v))
                {
                    continue;
                }

                if (widestChild == null)
                {
                    widestChild = v;
                }
                //Wrapping around has never felt so good
                if (v.BoundBox.Bottom + yDone > container.Bottom - parentView.Y)
                {
                    yDone = container.Top - parentView.RealY;
                    int addWidth = widestChild.BoundBox.Width + _paddingBetweenHorizontal;
                    if (_resizeParentToFit)
                    {
                        int neededWidth = addWidth + xDone + v.BoundBox.Width;
                        if (neededWidth > parentView.ContentBoundBox.Width)
                        {
                            int theWidth = (neededWidth - parentView.ContentBoundBox.Width);
                            parentView.Width.Value += theWidth;
                            widestChild             = v;
                        }
                    }
                    xDone      += addWidth;
                    nullify     = true;
                    widestChild = v;
                }
                else
                {
                    if (v.BoundBox.Width > widestChild.BoundBox.Width)
                    {
                        widestChild = v;
                    }
                }

                v.Position.Value = new Vector2(xDone, yDone);
                yDone           += v.BoundBox.Height + _paddingBetweenVertical;
                if (widestChild == v)
                {
                    furthestRight = v.AbsoluteBoundBox.Right - parentView.AbsoluteContentBoundBox.Left;
                }
            }

            if (_resizeParentToFit)
            {
                parentView.Width.Value = furthestRight + 1;
            }
        }