Merge branch 'scenetree-scroll' of https://github.com/Zode/FlaxEngine into Zode-scenetree-scroll

This commit is contained in:
Wojtek Figat
2025-06-16 14:44:54 +02:00
2 changed files with 24 additions and 0 deletions

View File

@@ -73,6 +73,11 @@ namespace FlaxEditor.GUI.Tree
/// </summary>
public bool DrawRootTreeLine = true;
/// <summary>
/// Occurs when the defered layouting happens
/// </summary>
public event Action OnDeferedLayout;
/// <summary>
/// Gets or sets the margin for the child tree nodes.
/// </summary>
@@ -375,6 +380,7 @@ namespace FlaxEditor.GUI.Tree
if (_deferLayoutUpdate)
{
base.PerformLayout();
OnDeferedLayout?.Invoke();
_deferLayoutUpdate = false;
}

View File

@@ -34,6 +34,7 @@ namespace FlaxEditor.Windows
private DragScriptItems _dragScriptItems;
private DragHandlers _dragHandlers;
private bool _isDropping = false;
private bool _forceScrollNodeToView = false;
/// <summary>
/// Scene tree panel.
@@ -91,6 +92,14 @@ namespace FlaxEditor.Windows
_tree.SelectedChanged += Tree_OnSelectedChanged;
_tree.RightClick += OnTreeRightClick;
_tree.Parent = _sceneTreePanel;
_tree.OnDeferedLayout += () => {
if(_forceScrollNodeToView)
{
_forceScrollNodeToView = false;
ScrollToSelectedNode();
}
};
headerPanel.Parent = this;
// Setup input actions
@@ -142,6 +151,15 @@ namespace FlaxEditor.Windows
root.TreeNode.UpdateFilter(query);
_tree.UnlockChildrenRecursive();
var nodeSelection = _tree.Selection;
if(nodeSelection.Count != 0)
{
var node = nodeSelection[nodeSelection.Count - 1];
node.Expand(true);
_forceScrollNodeToView = true;
}
PerformLayout();
PerformLayout();
}