internal float GetSelectionHeight(AdvancedDropdownDataSource dataSource, Rect buttonRect)
        {
            if (state.GetSelectedIndex(dataSource.mainTree) == -1)
            {
                return(0);
            }
            var height = 0f;

            for (var i = 0; i < dataSource.mainTree.children.Count(); i++)
            {
                var child   = dataSource.mainTree.children.ElementAt(i);
                var content = new GUIContent(child.name, child.icon);
                if (state.GetSelectedIndex(dataSource.mainTree) == i)
                {
                    var diff = (lineStyle.CalcHeight(content, 0) - buttonRect.height) / 2f;
                    return(height + diff);
                }
                if (child.IsSeparator())
                {
                    height += GUIHelpers.Styles.lineSeparator.CalcHeight(content, 0) + GUIHelpers.Styles.lineSeparator.margin.vertical;
                }
                else
                {
                    height += lineStyle.CalcHeight(content, 0);
                }
            }
            return(height);
        }
        public void Show(Rect rect)
        {
            if (m_WindowInstance != null)
            {
                m_WindowInstance.Close();
                m_WindowInstance = null;
            }
            if (m_DataSource == null)
            {
                m_DataSource = new CallbackDataSource(BuildRoot, BuildCustomSearch);
            }
            if (m_Gui == null)
            {
                m_Gui = new AdvancedDropdownGUI();
            }

            m_WindowInstance = ScriptableObject.CreateInstance <AdvancedDropdownWindow>();
            if (minimumSize != Vector2.zero)
            {
                m_WindowInstance.minSize = minimumSize;
            }
            if (maximumSize != Vector2.zero)
            {
                m_WindowInstance.maxSize = maximumSize;
            }
            m_WindowInstance.state         = m_State;
            m_WindowInstance.dataSource    = m_DataSource;
            m_WindowInstance.gui           = m_Gui;
            m_WindowInstance.windowClosed +=
                w => { ItemSelected(w.GetSelectedItem()); };
            m_WindowInstance.windowDestroyed += OnDestroy;
            m_WindowInstance.Init(rect);
        }
        internal Vector2 CalculateContentSize(AdvancedDropdownDataSource dataSource)
        {
            var maxWidth     = 0f;
            var maxHeight    = 0f;
            var includeArrow = false;
            var arrowWidth   = 0f;

            foreach (var child in dataSource.mainTree.children)
            {
                var content = new GUIContent(child.name, child.icon);
                var 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 += GUIHelpers.Styles.lineSeparator.CalcHeight(content, maxWidth) + GUIHelpers.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));
        }