From fc7628e2ee22975f8e524f315efba6cf728454d3 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 10 May 2024 19:22:23 -0500 Subject: [PATCH] Add tree node guidlines --- Source/Editor/GUI/Tree/TreeNode.cs | 32 +++++++++++++++++++++++ Source/Editor/Options/InterfaceOptions.cs | 7 +++++ 2 files changed, 39 insertions(+) diff --git a/Source/Editor/GUI/Tree/TreeNode.cs b/Source/Editor/GUI/Tree/TreeNode.cs index f4ff33e8d3..7b94f7f302 100644 --- a/Source/Editor/GUI/Tree/TreeNode.cs +++ b/Source/Editor/GUI/Tree/TreeNode.cs @@ -698,6 +698,38 @@ public override void Draw() } } + // Show tree guide lines + if (Editor.Instance.Options.Options.Interface.ShowTreeLines) + { + TreeNode parentNode = Parent as TreeNode; + bool thisNodeIsLast = false; + while (parentNode != null && parentNode != ParentTree.Children[0]) + { + float bottomOffset = 0; + float topOffset = 0; + + if (Parent == parentNode && this == Parent.Children[0]) + topOffset = 2; + + if (thisNodeIsLast && parentNode.Children.Count == 1) + bottomOffset = topOffset != 0 ? 4 : 2; + + if (Parent == parentNode && this == Parent.Children[Parent.Children.Count - 1] && !_opened) + { + thisNodeIsLast = true; + bottomOffset = topOffset != 0 ? 4 : 2; + } + + float leftOffset = 9; + // Adjust offset for icon image + if (_iconCollaped.IsValid) + leftOffset += 18; + var lineRect1 = new Rectangle(parentNode.TextRect.Left - leftOffset, parentNode.HeaderRect.Top + topOffset, 1, parentNode.HeaderRect.Height - bottomOffset); + Render2D.FillRectangle(lineRect1, isSelected ? style.ForegroundGrey : style.LightBackground); + parentNode = parentNode.Parent as TreeNode; + } + } + // Base if (_opened) { diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 4cf1fe0506..2234201913 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -210,6 +210,13 @@ public enum ValueFormattingType [EditorDisplay("Interface"), EditorOrder(310)] public bool SeparateValueAndUnit { get; set; } + /// + /// Gets or sets the option to put a space between numbers and units for unit formatting. + /// + [DefaultValue(true)] + [EditorDisplay("Interface"), EditorOrder(320)] + public bool ShowTreeLines { get; set; } = true; + /// /// Gets or sets the timestamps prefix mode for output log messages. ///