Example #1
0
        internal Vector2 CalculateContentSize(AdvancedDropdownDataSource dataSource)
        {
            float maxWidth     = 0;
            float maxHeight    = 0;
            bool  includeArrow = false;
            float arrowWidth   = 0;

            foreach (AdvancedDropdownItem child in dataSource.MainTree.Children)
            {
                GUIContent content = new GUIContent(child.Name, child.Icon);
                Vector2    a       = LineStyle.CalcSize(content);
                a.x += IconSize.x + 1;

                if (maxWidth < a.x)
                {
                    maxWidth      = a.x + 1;
                    includeArrow |= child.Children.Any();
                }

                if (child.IsSeparator())
                {
                    maxHeight += Styles.lineSeparator.CalcHeight(content, maxWidth) + Styles.lineSeparator.margin.vertical;
                }
                else
                {
                    maxHeight += LineStyle.CalcHeight(content, maxWidth);
                }

                if (arrowWidth == 0)
                {
                    LineStyle.CalcMinMaxWidth(Styles.arrowRightContent, out arrowWidth, out arrowWidth);
                }
            }

            if (includeArrow)
            {
                maxWidth += arrowWidth;
            }

            return(new Vector2(maxWidth, maxHeight));
        }