FitRect() private static method

private static FitRect ( Rect rect, ContainerWindow popupContainerWindow ) : Rect
rect UnityEngine.Rect
popupContainerWindow ContainerWindow
return UnityEngine.Rect
Esempio n. 1
0
        private static bool PopupRight(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect)
        {
            Rect  rect1 = new Rect(buttonRect.xMax, buttonRect.y, maxSize.x, maxSize.y);
            float num   = 0.0f;

            rect1.xMax   += num;
            rect1.height += PopupLocationHelper.k_SpaceFromBottom;
            Rect  rect2 = PopupLocationHelper.FitRect(rect1, popupContainerWindow);
            float a     = Mathf.Max(rect2.xMax - buttonRect.xMax - num, 0.0f);
            float width = Mathf.Min(a, maxSize.x);

            resultRect = new Rect(rect2.x, rect2.y, width, rect2.height - PopupLocationHelper.k_SpaceFromBottom);
            return((double)a >= (double)minSize.x);
        }
        private static bool PopupLeft(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect)
        {
            Rect  rect = new Rect(buttonRect.x - maxSize.x, buttonRect.y, maxSize.x, maxSize.y);
            float num  = 0f;

            rect.xMin   -= num;
            rect.height += PopupLocationHelper.k_SpaceFromBottom;
            rect         = PopupLocationHelper.FitRect(rect, popupContainerWindow);
            float num2  = Mathf.Max(buttonRect.x - rect.x - num, 0f);
            float width = Mathf.Min(num2, maxSize.x);

            resultRect = new Rect(rect.x, rect.y, width, rect.height - PopupLocationHelper.k_SpaceFromBottom);
            return(num2 >= minSize.x);
        }
        private static bool PopupBelow(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect)
        {
            Rect rect = new Rect(buttonRect.x, buttonRect.yMax, maxSize.x, maxSize.y);

            rect.height += PopupLocationHelper.k_SpaceFromBottom;
            rect         = PopupLocationHelper.FitRect(rect, popupContainerWindow);
            float num = Mathf.Max(rect.yMax - buttonRect.yMax - PopupLocationHelper.k_SpaceFromBottom, 0f);

            if (num >= minSize.y)
            {
                float height = Mathf.Min(num, maxSize.y);
                resultRect = new Rect(rect.x, buttonRect.yMax, rect.width, height);
                return(true);
            }
            resultRect = new Rect(rect.x, buttonRect.yMax, rect.width, num);
            return(false);
        }
        private static bool PopupAbove(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect)
        {
            Rect  rect = new Rect(buttonRect.x, buttonRect.y - maxSize.y, maxSize.x, maxSize.y);
            float num  = 0f;

            rect.yMin -= num;
            rect       = PopupLocationHelper.FitRect(rect, popupContainerWindow);
            float num2 = Mathf.Max(buttonRect.y - rect.y - num, 0f);

            if (num2 >= minSize.y)
            {
                float num3 = Mathf.Min(num2, maxSize.y);
                resultRect = new Rect(rect.x, buttonRect.y - num3, rect.width, num3);
                return(true);
            }
            resultRect = new Rect(rect.x, buttonRect.y - num2, rect.width, num2);
            return(false);
        }
Esempio n. 5
0
        private static bool PopupAbove(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect)
        {
            Rect  rect1 = new Rect(buttonRect.x, buttonRect.y - maxSize.y, maxSize.x, maxSize.y);
            float num1  = 0.0f;

            rect1.yMin -= num1;
            Rect  rect2 = PopupLocationHelper.FitRect(rect1, popupContainerWindow);
            float num2  = Mathf.Max(buttonRect.y - rect2.y - num1, 0.0f);

            if ((double)num2 >= (double)minSize.y)
            {
                float height = Mathf.Min(num2, maxSize.y);
                resultRect = new Rect(rect2.x, buttonRect.y - height, rect2.width, height);
                return(true);
            }
            resultRect = new Rect(rect2.x, buttonRect.y - num2, rect2.width, num2);
            return(false);
        }