Exemple #1
0
        protected virtual Vector2 CalculateWindowSize(Rect buttonRect)
        {
            var size = gui.CalculateContentSize(dataSource);

            // Add 1 pixel for each border
            size.x += kBorderThickness * 2;
            size.y += kBorderThickness * 2;
            size.x += kRightMargin;

            size.y += gui.searchHeight;

            if (showHeader)
            {
                size.y += gui.headerHeight;
            }

            size.y = Mathf.Clamp(size.y, minSize.y, maxSize.y);

            var fitRect = ContainerWindow.FitRectToScreen(new Rect(buttonRect.x, buttonRect.y, size.x, size.y), true, true);

            // If the scrollbar is visible, we want to add extra space to compansate it
            if (fitRect.height < size.y)
            {
                size.x += GUI.skin.verticalScrollbar.fixedWidth;
            }

            // Stretch to the width of the button
            if (size.x < buttonRect.width)
            {
                size.x = buttonRect.width;
            }

            return(new Vector2(size.x, size.y));
        }