Various fixes to prefab tree view. Scrolling like scene view, disable scrolling on renaming, can open CM anywhere in tree panel.
This commit is contained in:
@@ -9,6 +9,8 @@ using FlaxEditor.GUI.Drag;
|
|||||||
using FlaxEditor.GUI.Tree;
|
using FlaxEditor.GUI.Tree;
|
||||||
using FlaxEditor.Scripting;
|
using FlaxEditor.Scripting;
|
||||||
using FlaxEditor.Utilities;
|
using FlaxEditor.Utilities;
|
||||||
|
using FlaxEditor.Windows;
|
||||||
|
using FlaxEditor.Windows.Assets;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
using FlaxEngine.GUI;
|
using FlaxEngine.GUI;
|
||||||
using Object = FlaxEngine.Object;
|
using Object = FlaxEngine.Object;
|
||||||
@@ -265,7 +267,7 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts the actor renaming action.
|
/// Starts the actor renaming action.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void StartRenaming()
|
public void StartRenaming(EditorWindow window)
|
||||||
{
|
{
|
||||||
// Block renaming during scripts reload
|
// Block renaming during scripts reload
|
||||||
if (Editor.Instance.ProgressReporting.CompileScripts.IsActive)
|
if (Editor.Instance.ProgressReporting.CompileScripts.IsActive)
|
||||||
@@ -273,16 +275,22 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
|
|
||||||
Select();
|
Select();
|
||||||
|
|
||||||
// Disable scrolling of scene view
|
// Disable scrolling of view
|
||||||
Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(false);
|
if (window is SceneTreeWindow)
|
||||||
|
(window as SceneTreeWindow).ScrollingOnSceneTreeView(false);
|
||||||
|
else if (window is PrefabWindow)
|
||||||
|
(window as PrefabWindow).ScrollingOnTreeView(false);
|
||||||
|
|
||||||
// Start renaming the actor
|
// Start renaming the actor
|
||||||
var dialog = RenamePopup.Show(this, HeaderRect, _actorNode.Name, false);
|
var dialog = RenamePopup.Show(this, HeaderRect, _actorNode.Name, false);
|
||||||
dialog.Renamed += OnRenamed;
|
dialog.Renamed += OnRenamed;
|
||||||
dialog.Closed += popup =>
|
dialog.Closed += popup =>
|
||||||
{
|
{
|
||||||
// Enable scrolling of scene view
|
// Enable scrolling of view
|
||||||
Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true);
|
if (window is SceneTreeWindow)
|
||||||
|
(window as SceneTreeWindow).ScrollingOnSceneTreeView(true);
|
||||||
|
else if (window is PrefabWindow)
|
||||||
|
(window as PrefabWindow).ScrollingOnTreeView(true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,9 +298,6 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
{
|
{
|
||||||
using (new UndoBlock(ActorNode.Root.Undo, Actor, "Rename"))
|
using (new UndoBlock(ActorNode.Root.Undo, Actor, "Rename"))
|
||||||
Actor.Name = renamePopup.Text;
|
Actor.Name = renamePopup.Text;
|
||||||
|
|
||||||
// Enable scrolling of scene view
|
|
||||||
Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -153,6 +153,9 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
{
|
{
|
||||||
OnPasteAction(pasteAction);
|
OnPasteAction(pasteAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scroll to new selected node
|
||||||
|
ScrollToSelectedNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -180,6 +183,9 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
{
|
{
|
||||||
OnPasteAction(pasteAction);
|
OnPasteAction(pasteAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scroll to new selected node
|
||||||
|
ScrollToSelectedNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPasteAction(PasteActorsAction pasteAction)
|
private void OnPasteAction(PasteActorsAction pasteAction)
|
||||||
@@ -328,6 +334,9 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
}, action2.ActionString);
|
}, action2.ActionString);
|
||||||
action.Do();
|
action.Do();
|
||||||
Undo.AddAction(action);
|
Undo.AddAction(action);
|
||||||
|
|
||||||
|
_treePanel.PerformLayout();
|
||||||
|
_treePanel.PerformLayout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
private DragHandlers _dragHandlers;
|
private DragHandlers _dragHandlers;
|
||||||
|
|
||||||
public SceneTreePanel(PrefabWindow window)
|
public SceneTreePanel(PrefabWindow window)
|
||||||
: base(ScrollBars.Vertical)
|
: base(ScrollBars.None)
|
||||||
{
|
{
|
||||||
_window = window;
|
_window = window;
|
||||||
Offsets = Margin.Zero;
|
Offsets = Margin.Zero;
|
||||||
@@ -310,7 +310,7 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
{
|
{
|
||||||
if (selection.Count != 0)
|
if (selection.Count != 0)
|
||||||
Select(actor);
|
Select(actor);
|
||||||
actor.TreeNode.StartRenaming();
|
actor.TreeNode.StartRenaming(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
private readonly SplitPanel _split1;
|
private readonly SplitPanel _split1;
|
||||||
private readonly SplitPanel _split2;
|
private readonly SplitPanel _split2;
|
||||||
private readonly TextBox _searchBox;
|
private readonly TextBox _searchBox;
|
||||||
|
private readonly Panel _treePanel;
|
||||||
private readonly PrefabTree _tree;
|
private readonly PrefabTree _tree;
|
||||||
private readonly PrefabWindowViewport _viewport;
|
private readonly PrefabWindowViewport _viewport;
|
||||||
private readonly CustomEditorPresenter _propertiesEditor;
|
private readonly CustomEditorPresenter _propertiesEditor;
|
||||||
@@ -132,17 +133,26 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
};
|
};
|
||||||
_searchBox.TextChanged += OnSearchBoxTextChanged;
|
_searchBox.TextChanged += OnSearchBoxTextChanged;
|
||||||
|
|
||||||
|
_treePanel = new Panel()
|
||||||
|
{
|
||||||
|
AnchorPreset = AnchorPresets.StretchAll,
|
||||||
|
Offsets = new Margin(0.0f, 0.0f, headerPanel.Bottom, 0.0f),
|
||||||
|
ScrollBars = ScrollBars.Both,
|
||||||
|
IsScrollable = true,
|
||||||
|
Parent = sceneTreePanel,
|
||||||
|
};
|
||||||
|
|
||||||
// Prefab structure tree
|
// Prefab structure tree
|
||||||
Graph = new LocalSceneGraph(new CustomRootNode(this));
|
Graph = new LocalSceneGraph(new CustomRootNode(this));
|
||||||
_tree = new PrefabTree
|
_tree = new PrefabTree
|
||||||
{
|
{
|
||||||
Y = headerPanel.Bottom,
|
|
||||||
Margin = new Margin(0.0f, 0.0f, -16.0f, 0.0f), // Hide root node
|
Margin = new Margin(0.0f, 0.0f, -16.0f, 0.0f), // Hide root node
|
||||||
|
IsScrollable = true,
|
||||||
};
|
};
|
||||||
_tree.AddChild(Graph.Root.TreeNode);
|
_tree.AddChild(Graph.Root.TreeNode);
|
||||||
_tree.SelectedChanged += OnTreeSelectedChanged;
|
_tree.SelectedChanged += OnTreeSelectedChanged;
|
||||||
_tree.RightClick += OnTreeRightClick;
|
_tree.RightClick += OnTreeRightClick;
|
||||||
_tree.Parent = sceneTreePanel;
|
_tree.Parent = _treePanel;
|
||||||
headerPanel.Parent = sceneTreePanel;
|
headerPanel.Parent = sceneTreePanel;
|
||||||
|
|
||||||
// Prefab viewport
|
// Prefab viewport
|
||||||
@@ -192,6 +202,32 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
InputActions.Add(options => options.Rename, Rename);
|
InputActions.Add(options => options.Rename, Rename);
|
||||||
InputActions.Add(options => options.FocusSelection, _viewport.FocusSelection);
|
InputActions.Add(options => options.FocusSelection, _viewport.FocusSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables or disables vertical and horizontal scrolling on the tree panel.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="enabled">The state to set scrolling to</param>
|
||||||
|
public void ScrollingOnTreeView(bool enabled)
|
||||||
|
{
|
||||||
|
if (_treePanel.VScrollBar != null)
|
||||||
|
_treePanel.VScrollBar.ThumbEnabled = enabled;
|
||||||
|
if (_treePanel.HScrollBar != null)
|
||||||
|
_treePanel.HScrollBar.ThumbEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scrolls to the selected node in the tree.
|
||||||
|
/// </summary>
|
||||||
|
public void ScrollToSelectedNode()
|
||||||
|
{
|
||||||
|
// Scroll to node
|
||||||
|
var nodeSelection = _tree.Selection;
|
||||||
|
if (nodeSelection.Count != 0)
|
||||||
|
{
|
||||||
|
var scrollControl = nodeSelection[nodeSelection.Count - 1];
|
||||||
|
_treePanel.ScrollViewTo(scrollControl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnSearchBoxTextChanged()
|
private void OnSearchBoxTextChanged()
|
||||||
{
|
{
|
||||||
@@ -211,6 +247,22 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||||
|
{
|
||||||
|
if (base.OnMouseUp(location, button))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (button == MouseButton.Right && _treePanel.ContainsPoint(ref location))
|
||||||
|
{
|
||||||
|
_tree.Deselect();
|
||||||
|
var locationCM = location + _searchBox.BottomLeft;
|
||||||
|
ShowContextMenu(Parent, ref locationCM);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnScriptsReloadBegin()
|
private void OnScriptsReloadBegin()
|
||||||
{
|
{
|
||||||
_isScriptsReloading = true;
|
_isScriptsReloading = true;
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ namespace FlaxEditor.Windows
|
|||||||
{
|
{
|
||||||
if (selection.Count != 0)
|
if (selection.Count != 0)
|
||||||
Editor.SceneEditing.Select(actor);
|
Editor.SceneEditing.Select(actor);
|
||||||
actor.TreeNode.StartRenaming();
|
actor.TreeNode.StartRenaming(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user