Added scene panel to seperate the tree from the search bar and made the tree not able to scroll when renaming

This commit is contained in:
Chandler Cox
2022-10-10 15:38:30 -05:00
parent 52904cbe3e
commit 95e60ea68e
2 changed files with 37 additions and 4 deletions

View File

@@ -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);
}
/// <inheritdoc />

View File

@@ -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
/// </summary>
/// <param name="editor">The editor.</param>
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);
}
/// <summary>
/// Enables or disables vertical and horizontal scrolling on the scene tree panel
/// </summary>
/// <param name="enabled">The state to set scrolling to</param>
public void ScrollingOnSceneTreeView(bool enabled)
{
if (_sceneTreePanel.VScrollBar != null)
_sceneTreePanel.VScrollBar.ThumbEnabled = enabled;
if (_sceneTreePanel.HScrollBar != null)
_sceneTreePanel.HScrollBar.ThumbEnabled = enabled;
}
private void OnSearchBoxTextChanged()
{