Exemplo n.º 1
0
        public void ResizeViewToContent(ItemView view, bool fitWidth, bool fitHeight)
        {
            var totalArea   = view.GetUnclippedOuterRect().Get();
            var contentArea = GetViewRenderArea(view,
                                                !fitWidth && view.GetHorzScrollbar().IsVisible(),
                                                !fitHeight && view.GetVertScrollbar().IsVisible());
            var withScrollContentArea = GetViewRenderArea(view, true, true);

            var frameSize           = totalArea.Size - contentArea.Size;
            var withScrollFrameSize = totalArea.Size - withScrollContentArea.Size;
            var contentSize         = new Sizef(view.GetRenderedMaxWidth(), view.GetRenderedTotalHeight());

            var parentSize = view.GetParentPixelSize();
            var maxSize    =
                new Sizef(parentSize.Width - CoordConverter.AsAbsolute(view.GetXPosition(), parentSize.Width),
                          parentSize.Height - CoordConverter.AsAbsolute(view.GetYPosition(), parentSize.Height));

            var requiredSize = frameSize + contentSize + new Sizef(1, 1);

            if (fitHeight && requiredSize.Height > maxSize.Height)
            {
                requiredSize.Height = maxSize.Height;
                requiredSize.Width  = Math.Min(maxSize.Width,
                                               requiredSize.Width - frameSize.Width + withScrollFrameSize.Width);
            }

            if (fitWidth && requiredSize.Width > maxSize.Width)
            {
                requiredSize.Width  = maxSize.Width;
                requiredSize.Height = Math.Min(maxSize.Height,
                                               requiredSize.Height - frameSize.Height + withScrollFrameSize.Height);
            }

            if (fitHeight)
            {
                view.SetHeight(new UDim(0, requiredSize.Height));
            }

            if (fitWidth)
            {
                view.SetWidth(new UDim(0, requiredSize.Width));
            }
        }
Exemplo n.º 2
0
 public Lunatics.Mathematics.Vector2 GetItemRenderStartPosition(ItemView view, Rectf itemsArea)
 {
     return(new Lunatics.Mathematics.Vector2(itemsArea.Left - view.GetHorzScrollbar().GetScrollPosition(),
                                             itemsArea.Top - view.GetVertScrollbar().GetScrollPosition()));
 }
Exemplo n.º 3
0
        // TOOD: public virtual ~ItemViewRenderer();

        public virtual Rectf GetViewRenderArea(ItemView itemView)
        {
            return(GetViewRenderArea(itemView, itemView.GetHorzScrollbar().IsVisible(), itemView.GetVertScrollbar().IsVisible()));
        }