From 95e60ea68e08fa03d1ea1765e74b72fd3bcba782 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 10 Oct 2022 15:38:30 -0500 Subject: [PATCH 1/2] Added scene panel to seperate the tree from the search bar and made the tree not able to scroll when renaming --- Source/Editor/SceneGraph/GUI/ActorTreeNode.cs | 11 +++++++ Source/Editor/Windows/SceneTreeWindow.cs | 30 ++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs index 82e9c3c77..ce64e2071 100644 --- a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs +++ b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs @@ -273,15 +273,26 @@ namespace FlaxEditor.SceneGraph.GUI Select(); + // disable scrolling of scene view + Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(false); + // Start renaming the actor var dialog = RenamePopup.Show(this, HeaderRect, _actorNode.Name, false); dialog.Renamed += OnRenamed; + dialog.Closed += popup => + { + // enable scrolling of scene view + Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true); + }; } private void OnRenamed(RenamePopup renamePopup) { using (new UndoBlock(ActorNode.Root.Undo, Actor, "Rename")) Actor.Name = renamePopup.Text; + + // enable scrolling of scene view + Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true); } /// diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index bccba12c2..f348c465e 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -131,6 +131,7 @@ namespace FlaxEditor.Windows private TextBox _searchBox; private Tree _tree; + private Panel _sceneTreePanel; private bool _isUpdatingSelection; private bool _isMouseDown; @@ -143,10 +144,9 @@ namespace FlaxEditor.Windows /// /// The editor. public SceneTreeWindow(Editor editor) - : base(editor, true, ScrollBars.Both) + : base(editor, true, ScrollBars.None) { Title = "Scene"; - ScrollMargin = new Margin(0, 0, 0, 100.0f); // Scene searching query input box var headerPanel = new ContainerControl @@ -165,19 +165,29 @@ namespace FlaxEditor.Windows }; _searchBox.TextChanged += OnSearchBoxTextChanged; + // Scene tree panel + _sceneTreePanel = new Panel + { + AnchorPreset = AnchorPresets.StretchAll, + Offsets = new Margin(0, 0, headerPanel.Bottom, 0), + IsScrollable = true, + ScrollBars = ScrollBars.Both, + Parent = this, + }; + // Create scene structure tree var root = editor.Scene.Root; root.TreeNode.ChildrenIndent = 0; root.TreeNode.Expand(); _tree = new Tree(true) { - Y = headerPanel.Bottom, Margin = new Margin(0.0f, 0.0f, -16.0f, 0.0f), // Hide root node + IsScrollable = true, }; _tree.AddChild(root.TreeNode); _tree.SelectedChanged += Tree_OnSelectedChanged; _tree.RightClick += OnTreeRightClick; - _tree.Parent = this; + _tree.Parent = _sceneTreePanel; headerPanel.Parent = this; // Setup input actions @@ -187,6 +197,18 @@ namespace FlaxEditor.Windows InputActions.Add(options => options.FocusSelection, () => Editor.Windows.EditWin.Viewport.FocusSelection()); InputActions.Add(options => options.Rename, Rename); } + + /// + /// Enables or disables vertical and horizontal scrolling on the scene tree panel + /// + /// The state to set scrolling to + public void ScrollingOnSceneTreeView(bool enabled) + { + if (_sceneTreePanel.VScrollBar != null) + _sceneTreePanel.VScrollBar.ThumbEnabled = enabled; + if (_sceneTreePanel.HScrollBar != null) + _sceneTreePanel.HScrollBar.ThumbEnabled = enabled; + } private void OnSearchBoxTextChanged() { From b0f4f8d636b3b498ec8d88e95032623072b24b8e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 12 Oct 2022 18:55:24 +0200 Subject: [PATCH 2/2] Code style fix --- Source/Editor/SceneGraph/GUI/ActorTreeNode.cs | 10 +++++----- Source/Editor/Windows/SceneTreeWindow.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs index ce64e2071..63043aa91 100644 --- a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs +++ b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs @@ -273,15 +273,15 @@ namespace FlaxEditor.SceneGraph.GUI Select(); - // disable scrolling of scene view + // Disable scrolling of scene view Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(false); - + // Start renaming the actor var dialog = RenamePopup.Show(this, HeaderRect, _actorNode.Name, false); dialog.Renamed += OnRenamed; dialog.Closed += popup => { - // enable scrolling of scene view + // Enable scrolling of scene view Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true); }; } @@ -290,8 +290,8 @@ namespace FlaxEditor.SceneGraph.GUI { using (new UndoBlock(ActorNode.Root.Undo, Actor, "Rename")) Actor.Name = renamePopup.Text; - - // enable scrolling of scene view + + // Enable scrolling of scene view Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true); } diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index f348c465e..b0bed2002 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -174,7 +174,7 @@ namespace FlaxEditor.Windows ScrollBars = ScrollBars.Both, Parent = this, }; - + // Create scene structure tree var root = editor.Scene.Root; root.TreeNode.ChildrenIndent = 0; @@ -197,9 +197,9 @@ namespace FlaxEditor.Windows InputActions.Add(options => options.FocusSelection, () => Editor.Windows.EditWin.Viewport.FocusSelection()); InputActions.Add(options => options.Rename, Rename); } - + /// - /// Enables or disables vertical and horizontal scrolling on the scene tree panel + /// Enables or disables vertical and horizontal scrolling on the scene tree panel. /// /// The state to set scrolling to public void ScrollingOnSceneTreeView(bool enabled)