コード例 #1
0
    public TreeViewItemEditor AddItem(string header, bool isExpanded, bool isChecked)
    {
        TreeViewItemEditor itemEditor = new TreeViewItemEditor(ParentControlEditor, this)
        {
            Header = header, IsExpanded = isExpanded, IsCheckBox = true, IsChecked = isChecked
        };

        Items.Add(itemEditor);
        return(itemEditor);
    }
コード例 #2
0
    public TreeViewItemEditor(TreeViewControlEditor parentControlEditor, TreeViewItemEditor parent)
    {
        ParentControlEditor = parentControlEditor;
        Parent = parent;

        if (null == parentControlEditor)
        {
            return;
        }
    }
コード例 #3
0
    public TreeViewItemEditor AddItem(string header)
    {
        TreeViewItemEditor itemEditor = new TreeViewItemEditor(ParentControlEditor, this)
        {
            Header = header
        };

        Items.Add(itemEditor);
        return(itemEditor);
    }
コード例 #4
0
    public TreeViewItemEditor(TreeViewControlEditor parentControlEditor, TreeViewItemEditor parent)
    {
        ParentControlEditor = parentControlEditor;
        Parent = parent;

        if (null == parentControlEditor)
        {
            return;
        }
    }
コード例 #5
0
    public override void OnInspectorGUI()
    {
        if (Application.isPlaying)
        {
            GUILayout.Label("Please avoid editing these fields while playing");
        }

        if (null == target &&
            !(target is TreeViewControlEditor))
        {
            Debug.LogError("Not a TreeViewControl");
            return;
        }

        TreeViewControlEditor item = (TreeViewControlEditor)target;

        if (null == item)
        {
            Debug.LogError("TreeViewControl is null");
            return;
        }

        bool needsRepainted = false;

        if (null != Event.current &&
            m_mousePos != Event.current.mousePosition)
        {
            needsRepainted = true;
        }

        if (item.SelectedItemEditor != _mLastSelectedItemEditor)
        {
            _mLastSelectedItemEditor = item.SelectedItemEditor;
            needsRepainted           = true;
        }

        if (null != item.SelectedItemEditor &&
            string.IsNullOrEmpty(item.SelectedItemEditor.Header))
        {
            item.SelectedItemEditor.Header = "Root item";
            needsRepainted = true;
        }

        if (GUILayout.Button("Select Root TreeViewItem"))
        {
            item.SelectedItemEditor    = item.RootItemEditor;
            Selection.activeGameObject = item.gameObject;
            needsRepainted             = true;
        }

        if (null != item.SelectedItemEditor &&
            GUILayout.Button("Add Child TreeView Item"))
        {
            item.SelectedItemEditor.AddItem("Default text");
            needsRepainted = true;
        }

        if (null != item.SelectedItemEditor &&
            item.SelectedItemEditor != item.RootItemEditor &&
            null != item.SelectedItemEditor.Parent &&
            GUILayout.Button("Remove TreeView Item"))
        {
            TreeViewItemEditor oldItemEditor = item.SelectedItemEditor;
            item.SelectedItemEditor.Parent.Items.Remove(oldItemEditor);
            item.SelectedItemEditor = null;
            needsRepainted          = true;
        }

        if (null != item.SelectedItemEditor &&
            null != item.SelectedItemEditor.Parent &&
            item.SelectedItemEditor != item.RootItemEditor &&
            item.SelectedItemEditor.Parent.Items.IndexOf(item.SelectedItemEditor) > 0 &&
            GUILayout.Button("Move Up"))
        {
            TreeViewItemEditor oldItemEditor = item.SelectedItemEditor;
            item.SelectedItemEditor = null;
            int index = oldItemEditor.Parent.Items.IndexOf(oldItemEditor);
            oldItemEditor.Parent.Items.Remove(oldItemEditor);
            oldItemEditor.Parent.Items.Insert(index - 1, oldItemEditor);
            item.SelectedItemEditor = oldItemEditor;
            needsRepainted          = true;
        }

        if (null != item.SelectedItemEditor &&
            null != item.SelectedItemEditor.Parent &&
            item.SelectedItemEditor != item.RootItemEditor &&
            (item.SelectedItemEditor.Parent.Items.IndexOf(item.SelectedItemEditor) + 1) < item.SelectedItemEditor.Parent.Items.Count &&
            GUILayout.Button("Move Down"))
        {
            TreeViewItemEditor oldItemEditor = item.SelectedItemEditor;
            item.SelectedItemEditor = null;
            int index = oldItemEditor.Parent.Items.IndexOf(oldItemEditor);
            oldItemEditor.Parent.Items.Remove(oldItemEditor);
            oldItemEditor.Parent.Items.Insert(index + 1, oldItemEditor);
            item.SelectedItemEditor = oldItemEditor;
            needsRepainted          = true;
        }

        if (null != item.SelectedItemEditor &&
            null != item.SelectedItemEditor.Parent &&
            null != item.SelectedItemEditor.Parent.Parent &&
            item.SelectedItemEditor != item.RootItemEditor &&
            item.SelectedItemEditor.Parent != item.RootItemEditor &&
            GUILayout.Button("Promote TreeView Item"))
        {
            TreeViewItemEditor oldItemEditor = item.SelectedItemEditor;
            item.SelectedItemEditor = null;
            oldItemEditor.Parent.Items.Remove(oldItemEditor);
            oldItemEditor.Parent.Parent.Items.Insert(0, oldItemEditor);
            oldItemEditor.Parent    = oldItemEditor.Parent.Parent;
            item.SelectedItemEditor = oldItemEditor;
            needsRepainted          = true;
        }

        EditorGUILayout.Separator();

        if (null != item.SelectedItemEditor)
        {
            EditorGUILayout.LabelField("Parent:", (item.SelectedItemEditor.Parent == null) ? "(null)" : "(valid)");
            EditorGUILayout.LabelField("Parent Control:", (item.SelectedItemEditor.ParentControlEditor == null) ? "(null)" : "(valid)");
        }

        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("***** Selected Item:", "(editable fields) *******");
        if (null != item.SelectedItemEditor)
        {
            if (!string.IsNullOrEmpty(item.SelectedItemEditor.Header))
            {
                string header = EditorGUILayout.TextField("Header:", item.SelectedItemEditor.Header);
                if (!item.SelectedItemEditor.Header.Equals(header))
                {
                    item.SelectedItemEditor.Header = header;
                    needsRepainted = true;
                }
            }
            bool isExpanded = EditorGUILayout.Toggle("IsExpanded:", item.SelectedItemEditor.IsExpanded);
            if (isExpanded != item.SelectedItemEditor.IsExpanded)
            {
                item.SelectedItemEditor.IsExpanded = isExpanded;
                needsRepainted = true;
            }
            bool isCheckBox = EditorGUILayout.Toggle("IsCheckBox:", item.SelectedItemEditor.IsCheckBox);
            if (isCheckBox != item.SelectedItemEditor.IsCheckBox)
            {
                item.SelectedItemEditor.IsCheckBox = isCheckBox;
                needsRepainted = true;
            }
            bool isChecked = EditorGUILayout.Toggle("IsChecked:", item.SelectedItemEditor.IsChecked);
            if (isChecked != item.SelectedItemEditor.IsChecked)
            {
                item.SelectedItemEditor.IsChecked = isChecked;
                needsRepainted = true;
            }
        }

        if (needsRepainted)
        {
            Repaint();
            SceneView.RepaintAll();
        }

        base.OnInspectorGUI();

        if (item.DisplayInInspector)
        {
            EditorGUILayout.Separator();
            item.DisplayTreeView(TreeViewControlEditor.DisplayTypes.NONE);
            EditorGUILayout.Separator();
        }
    }
コード例 #6
0
 void Start()
 {
     SelectedItemEditor = null;
 }
コード例 #7
0
    /// <summary>
    /// Find the button texture/text by enum
    /// </summary>
    /// <param name="item"></param>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <param name="width"></param>
    /// <param name="height"></param>
    /// <returns></returns>
    public bool Button(TreeViewItemEditor.TextureIcons item)
    {
        switch (item)
        {
            case TreeViewItemEditor.TextureIcons.BLANK:
                if (null == m_textureGuide ||
                    m_forceButtonText)
                {
                    GUILayout.Label("", GUILayout.MaxWidth(4));
                }
                else
                {
                    GUILayout.Label(m_textureBlank, GUILayout.MaxWidth(4), GUILayout.MaxHeight(16));
                }
				return false;
            case TreeViewItemEditor.TextureIcons.GUIDE:
                if (null == m_textureGuide ||
                    m_forceButtonText)
                {
                    GUILayout.Label("|", GUILayout.MaxWidth(16));
                }
                else
                {
                    GUILayout.Label(m_textureGuide, GUILayout.MaxWidth(16), GUILayout.MaxHeight(16));
                }
				return false;
            case TreeViewItemEditor.TextureIcons.LAST_SIBLING_COLLAPSED:
                if (null == m_textureLastSiblingCollapsed ||
                    m_forceButtonText)
                {
                    return GUILayout.Button("<", GUILayout.MaxWidth(16));
                }
                else
                {
                    return ShowButtonTexture(m_textureLastSiblingCollapsed);
                }
            case TreeViewItemEditor.TextureIcons.LAST_SIBLING_EXPANDED:
                if (null == m_textureLastSiblingExpanded ||
                    m_forceButtonText)
                {
                    return GUILayout.Button(">", GUILayout.MaxWidth(16));
                }
                else
                {
                    return ShowButtonTexture(m_textureLastSiblingExpanded);
                }
            case TreeViewItemEditor.TextureIcons.LAST_SIBLING_NO_CHILD:
                if (null == m_textureLastSiblingNoChild ||
                    m_forceButtonText)
                {
                    return GUILayout.Button("-", GUILayout.MaxWidth(16));
                }
                else
                {
                    return GUILayout.Button(m_textureLastSiblingNoChild, GUILayout.MaxWidth(16));
                }
            case TreeViewItemEditor.TextureIcons.MIDDLE_SIBLING_COLLAPSED:
                if (null == m_textureMiddleSiblingCollapsed ||
                    m_forceButtonText)
                {
                    return GUILayout.Button("<", GUILayout.MaxWidth(16));
                }
                else
                {
                    return ShowButtonTexture(m_textureMiddleSiblingCollapsed);
                }
            case TreeViewItemEditor.TextureIcons.MIDDLE_SIBLING_EXPANDED:
                if (null == m_textureMiddleSiblingExpanded ||
                    m_forceButtonText)
                {
                    return GUILayout.Button(">", GUILayout.MaxWidth(16));
                }
                else
                {
                    return GUILayout.Button(m_textureMiddleSiblingExpanded, GUILayout.MaxWidth(16));
                }
            case TreeViewItemEditor.TextureIcons.MIDDLE_SIBLING_NO_CHILD:
                if (null == m_textureMiddleSiblingNoChild ||
                    m_forceButtonText)
                {
                    return GUILayout.Button("-", GUILayout.MaxWidth(16));
                }
                else
                {
                    return ShowButtonTexture(m_textureMiddleSiblingNoChild);
                }
			case TreeViewItemEditor.TextureIcons.NORMAL_CHECKED:
                if (null == m_textureNormalChecked ||
                    m_forceButtonText)
                {
                    return GUILayout.Button("x", GUILayout.MaxWidth(16));
                }
                else
                {
                    return GUILayout.Button(m_textureNormalChecked, GUILayout.MaxWidth(16));
                }
			case TreeViewItemEditor.TextureIcons.NORMAL_UNCHECKED:
                if (null == m_textureNormalUnchecked ||
                    m_forceButtonText)
                {
                    return GUILayout.Button("o", GUILayout.MaxWidth(16));
                }
                else
                {
                    return ShowButtonTexture(m_textureNormalUnchecked);
                }
            default:
                return false;
        }
    }
コード例 #8
0
 public TreeViewItemEditor AddItem(string header, bool isExpanded, bool isChecked)
 {
     TreeViewItemEditor itemEditor = new TreeViewItemEditor(ParentControlEditor, this) { Header = header, IsExpanded = isExpanded, IsCheckBox = true, IsChecked = isChecked };
     Items.Add(itemEditor);
     return itemEditor;
 }
コード例 #9
0
 public TreeViewItemEditor AddItem(string header)
 {
     TreeViewItemEditor itemEditor = new TreeViewItemEditor(ParentControlEditor, this) { Header = header };
     Items.Add(itemEditor);
     return itemEditor;
 }
コード例 #10
0
    public override void OnInspectorGUI()
    {
        if (Application.isPlaying)
        {
            GUILayout.Label("Please avoid editing these fields while playing");
        }

        if (null == target &&
            !(target is TreeViewControlEditor))
        {
            Debug.LogError("Not a TreeViewControl");
            return;
        }

        TreeViewControlEditor item = (TreeViewControlEditor)target;
        if (null == item)
        {
            Debug.LogError("TreeViewControl is null");
            return;
        }

        bool needsRepainted = false;

        if (null != Event.current &&
            m_mousePos != Event.current.mousePosition)
        {
            needsRepainted = true;
        }
        
        if (item.SelectedItemEditor != _mLastSelectedItemEditor)
        {
            _mLastSelectedItemEditor = item.SelectedItemEditor;
            needsRepainted = true;
        }

        if (null != item.SelectedItemEditor &&
            string.IsNullOrEmpty(item.SelectedItemEditor.Header))
        {
            item.SelectedItemEditor.Header = "Root item";
            needsRepainted = true;
        }

        if (GUILayout.Button("Select Root TreeViewItem"))
        {
            item.SelectedItemEditor = item.RootItemEditor;
            Selection.activeGameObject = item.gameObject;
            needsRepainted = true;
        }

        if (null != item.SelectedItemEditor &&
            GUILayout.Button("Add Child TreeView Item"))
        {
            item.SelectedItemEditor.AddItem("Default text");
            needsRepainted = true;
        }

        if (null != item.SelectedItemEditor &&
            item.SelectedItemEditor != item.RootItemEditor &&
            null != item.SelectedItemEditor.Parent &&
            GUILayout.Button("Remove TreeView Item"))
        {
            TreeViewItemEditor oldItemEditor = item.SelectedItemEditor;
            item.SelectedItemEditor.Parent.Items.Remove(oldItemEditor);
            item.SelectedItemEditor = null;
            needsRepainted = true;
        }

        if (null != item.SelectedItemEditor &&
            null != item.SelectedItemEditor.Parent &&
            item.SelectedItemEditor != item.RootItemEditor &&
            item.SelectedItemEditor.Parent.Items.IndexOf(item.SelectedItemEditor) > 0 &&
            GUILayout.Button("Move Up"))
        {
            TreeViewItemEditor oldItemEditor = item.SelectedItemEditor;
            item.SelectedItemEditor = null;
            int index = oldItemEditor.Parent.Items.IndexOf(oldItemEditor);
            oldItemEditor.Parent.Items.Remove(oldItemEditor);
            oldItemEditor.Parent.Items.Insert(index - 1, oldItemEditor);
            item.SelectedItemEditor = oldItemEditor;
            needsRepainted = true;
        }

        if (null != item.SelectedItemEditor &&
            null != item.SelectedItemEditor.Parent &&
            item.SelectedItemEditor != item.RootItemEditor &&
            (item.SelectedItemEditor.Parent.Items.IndexOf(item.SelectedItemEditor) + 1) < item.SelectedItemEditor.Parent.Items.Count &&
            GUILayout.Button("Move Down"))
        {
            TreeViewItemEditor oldItemEditor = item.SelectedItemEditor;
            item.SelectedItemEditor = null;
            int index = oldItemEditor.Parent.Items.IndexOf(oldItemEditor);
            oldItemEditor.Parent.Items.Remove(oldItemEditor);
            oldItemEditor.Parent.Items.Insert(index + 1, oldItemEditor);
            item.SelectedItemEditor = oldItemEditor;
            needsRepainted = true;
        }

        if (null != item.SelectedItemEditor &&
            null != item.SelectedItemEditor.Parent &&
            null != item.SelectedItemEditor.Parent.Parent &&
            item.SelectedItemEditor != item.RootItemEditor &&
            item.SelectedItemEditor.Parent != item.RootItemEditor &&
            GUILayout.Button("Promote TreeView Item"))
        {
            TreeViewItemEditor oldItemEditor = item.SelectedItemEditor;
            item.SelectedItemEditor = null;
            oldItemEditor.Parent.Items.Remove(oldItemEditor);
            oldItemEditor.Parent.Parent.Items.Insert(0, oldItemEditor);
            oldItemEditor.Parent = oldItemEditor.Parent.Parent;
            item.SelectedItemEditor = oldItemEditor;
            needsRepainted = true;
        }

        EditorGUILayout.Separator();

        if (null != item.SelectedItemEditor)
        {
            EditorGUILayout.LabelField("Parent:", (item.SelectedItemEditor.Parent == null) ? "(null)" : "(valid)");
            EditorGUILayout.LabelField("Parent Control:", (item.SelectedItemEditor.ParentControlEditor == null) ? "(null)" : "(valid)");
        }

        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("***** Selected Item:", "(editable fields) *******");
        if (null != item.SelectedItemEditor)
        {
            if (!string.IsNullOrEmpty(item.SelectedItemEditor.Header))
            {
                string header = EditorGUILayout.TextField("Header:", item.SelectedItemEditor.Header);
                if (!item.SelectedItemEditor.Header.Equals(header))
                {
                    item.SelectedItemEditor.Header = header;
                    needsRepainted = true;
                }
            }
            bool isExpanded = EditorGUILayout.Toggle("IsExpanded:", item.SelectedItemEditor.IsExpanded);
            if (isExpanded != item.SelectedItemEditor.IsExpanded)
            {
                item.SelectedItemEditor.IsExpanded = isExpanded;
                needsRepainted = true;
            }
			bool isCheckBox = EditorGUILayout.Toggle("IsCheckBox:", item.SelectedItemEditor.IsCheckBox);
            if (isCheckBox != item.SelectedItemEditor.IsCheckBox)
            {
                item.SelectedItemEditor.IsCheckBox = isCheckBox;
                needsRepainted = true;
            }
			bool isChecked = EditorGUILayout.Toggle("IsChecked:", item.SelectedItemEditor.IsChecked);
            if (isChecked != item.SelectedItemEditor.IsChecked)
            {
                item.SelectedItemEditor.IsChecked = isChecked;
                needsRepainted = true;
            }
        }

        if (needsRepainted)
        {
            Repaint();
            SceneView.RepaintAll();
        }

		base.OnInspectorGUI();

        if (item.DisplayInInspector)
		{
			EditorGUILayout.Separator();
            item.DisplayTreeView(TreeViewControlEditor.DisplayTypes.NONE);
			EditorGUILayout.Separator();
		}
    }
コード例 #11
0
 void Start()
 {
     SelectedItemEditor = null;
 }
コード例 #12
0
    public void DisplayItem(int levels, SiblingOrder siblingOrder)
    {
        Rect lastRect;
        int  offset = ParentControlEditor.m_textureGuide.width + ParentControlEditor.m_textureNormalChecked.width;

        if (null == ParentControlEditor)
        {
            return;
        }

        GUILayout.BeginHorizontal();

        for (int index = 0; index < levels; ++index)
        {
            ParentControlEditor.Button(TextureIcons.GUIDE);
        }

        if (!HasChildItems())
        {
            bool result;
            switch (siblingOrder)
            {
            case SiblingOrder.FIRST_CHILD:
                result = ParentControlEditor.Button(TextureIcons.MIDDLE_SIBLING_NO_CHILD);
                break;

            case SiblingOrder.MIDDLE_CHILD:
                result = ParentControlEditor.Button(TextureIcons.MIDDLE_SIBLING_NO_CHILD);
                break;

            case SiblingOrder.LAST_CHILD:
                result = ParentControlEditor.Button(TextureIcons.LAST_SIBLING_NO_CHILD);
                break;

            default:
                result = false;
                break;
            }
            if (result)
            {
                IsExpanded = !IsExpanded;
            }
        }
        else
        {
            if (IsExpanded)
            {
                bool result;
                switch (siblingOrder)
                {
                case SiblingOrder.FIRST_CHILD:
                    result = ParentControlEditor.Button(TextureIcons.MIDDLE_SIBLING_EXPANDED);
                    break;

                case SiblingOrder.MIDDLE_CHILD:
                    result = ParentControlEditor.Button(TextureIcons.MIDDLE_SIBLING_EXPANDED);
                    break;

                case SiblingOrder.LAST_CHILD:
                    result = ParentControlEditor.Button(TextureIcons.LAST_SIBLING_EXPANDED);
                    break;

                default:
                    result = false;
                    break;
                }
                if (result)
                {
                    IsExpanded = !IsExpanded;
                }
            }
            else
            {
                bool result;
                switch (siblingOrder)
                {
                case SiblingOrder.FIRST_CHILD:
                    result = ParentControlEditor.Button(TextureIcons.MIDDLE_SIBLING_COLLAPSED);
                    break;

                case SiblingOrder.MIDDLE_CHILD:
                    result = ParentControlEditor.Button(TextureIcons.MIDDLE_SIBLING_COLLAPSED);
                    break;

                case SiblingOrder.LAST_CHILD:
                    result = ParentControlEditor.Button(TextureIcons.LAST_SIBLING_COLLAPSED);
                    break;

                default:
                    result = false;
                    break;
                }
                if (result)
                {
                    IsExpanded = !IsExpanded;
                }
            }
        }

        // display the text for the tree view
        //also compute the size max>
        if (!string.IsNullOrEmpty(Header))
        {
            bool isSelected;
            if (ParentControlEditor.SelectedItemEditor == this &&
                !ParentControlEditor.m_forceDefaultSkin)
            {
                //use selected skin
                GUI.skin   = ParentControlEditor.m_skinSelected;
                isSelected = true;
            }
            else
            {
                isSelected = false;
            }

            if (IsCheckBox)
            {
                if (IsChecked &&
                    ParentControlEditor.Button(TextureIcons.NORMAL_CHECKED))
                {
                    IsChecked = false;
                    if (ParentControlEditor.SelectedItemEditor != this)
                    {
                        ParentControlEditor.SelectedItemEditor = this;
                        this.IsSelected = true;
                        if (null != Selected)
                        {
                            Selected.Invoke(this, new SelectedEventArgs());
                        }
                    }
                    if (null != Unchecked)
                    {
                        Unchecked.Invoke(this, new UncheckedEventArgs());
                    }
                }
                else if (!IsChecked &&
                         ParentControlEditor.Button(TextureIcons.NORMAL_UNCHECKED))
                {
                    IsChecked = true;
                    if (ParentControlEditor.SelectedItemEditor != this)
                    {
                        ParentControlEditor.SelectedItemEditor = this;
                        this.IsSelected = true;
                        if (null != Selected)
                        {
                            Selected.Invoke(this, new SelectedEventArgs());
                        }
                    }
                    if (null != Checked)
                    {
                        Checked.Invoke(this, new CheckedEventArgs());
                    }
                }

                ParentControlEditor.Button(TextureIcons.BLANK);
            }

            if (ParentControlEditor.IsHoverEnabled)
            {
                GUISkin oldSkin = GUI.skin;
                if (isSelected)
                {
                    GUI.skin = ParentControlEditor.m_skinSelected;
                }
                else if (IsHover)
                {
                    GUI.skin = ParentControlEditor.m_skinHover;
                }
                else
                {
                    GUI.skin = ParentControlEditor.m_skinUnselected;
                }
                if (ParentControlEditor.IsHoverAnimationEnabled)
                {
                    GUI.skin.button.fontSize = (int)Mathf.Lerp(12f, 12f, m_hoverTime);
                }
                GUI.SetNextControlName("toggleButton"); //workaround to dirty GUI
                //var size : Vector2 = GUI.skin.GetStyle("ProgressBarText").CalcSize(GUIContent(label));
                Vector2 size = GUI.skin.label.CalcSize(new GUIContent(Header));
                if (size.x + (levels * offset) + 15 > ParentControlEditor.maxWidth)
                {
                    ParentControlEditor.maxWidth = (int)size.x + (levels * offset) + 15;
                }
                //Debug.Log (size.x.ToString()+" size and level*offset "+(levels*offset).ToString());
                if (GUILayout.Button(Header))
                {
                    GUI.FocusControl("toggleButton"); //workaround to dirty GUI
                    if (ParentControlEditor.SelectedItemEditor != this)
                    {
                        ParentControlEditor.SelectedItemEditor = this;
                        this.IsSelected = true;
                        if (null != Selected)
                        {
                            Selected.Invoke(this, new SelectedEventArgs());
                        }
                    }
                    if (null != Click)
                    {
                        Click.Invoke(this, new ClickEventArgs());
                    }
                }
                GUI.skin = oldSkin;
            }
            else
            {
                GUI.SetNextControlName("toggleButton"); //workaround to dirty GUI
                Vector2 size = GUI.skin.label.CalcSize(new GUIContent(Header));
                if (size.x + (levels * offset) + 15 > ParentControlEditor.maxWidth)
                {
                    ParentControlEditor.maxWidth = (int)size.x + (levels * offset) + 15;
                }
                if (GUILayout.Button(Header))
                {
                    GUI.FocusControl("toggleButton");                     //workaround to dirty GUI
                    if (ParentControlEditor.SelectedItemEditor != this)
                    {
                        ParentControlEditor.SelectedItemEditor = this;
                        this.IsSelected = true;
                        if (null != Selected)
                        {
                            Selected.Invoke(this, new SelectedEventArgs());
                        }
                    }
                    if (null != Click)
                    {
                        Click.Invoke(this, new ClickEventArgs());
                    }
                }
            }

            if (isSelected &&
                !ParentControlEditor.m_forceDefaultSkin)
            {
                //return to default skin
                GUI.skin = ParentControlEditor.m_skinUnselected;
            }
        }

        GUILayout.EndHorizontal();

        if (ParentControlEditor.IsHoverEnabled)
        {
            if (null != Event.current &&
                Event.current.type == EventType.Repaint)
            {
                Vector2 mousePos = Event.current.mousePosition;
                if (ParentControlEditor.HasFocus(mousePos))
                {
                    lastRect = GUILayoutUtility.GetLastRect();
                    if (lastRect.Contains(mousePos))
                    {
                        IsHover = true;
                        ParentControlEditor.HoverItemEditor = this;
                    }
                    else
                    {
                        IsHover = false;
                    }
                    if (ParentControlEditor.IsHoverEnabled &&
                        ParentControlEditor.IsHoverAnimationEnabled)
                    {
                        m_hoverTime = CalculateHoverTime(lastRect, Event.current.mousePosition);
                    }
                }
            }
        }

        if (HasChildItems() &&
            IsExpanded)
        {
            for (int index = 0; index < Items.Count; ++index)
            {
                TreeViewItemEditor child = Items[index];
                child.Parent = this;
                if ((index + 1) == Items.Count)
                {
                    child.DisplayItem(levels + 1, SiblingOrder.LAST_CHILD);
                }
                else if (index == 0)
                {
                    child.DisplayItem(levels + 1, SiblingOrder.FIRST_CHILD);
                }
                else
                {
                    child.DisplayItem(levels + 1, SiblingOrder.MIDDLE_CHILD);
                }
            }
        }

        if (IsSelected &&
            ParentControlEditor.SelectedItemEditor != this)
        {
            if (null != Unselected)
            {
                Unselected.Invoke(this, new UnselectedEventArgs());
            }
        }
        IsSelected = ParentControlEditor.SelectedItemEditor == this;
    }