Merge branch 'visject-better-selection' of https://github.com/Zode/FlaxEngine into Zode-visject-better-selection
This commit is contained in:
@@ -27,6 +27,7 @@ namespace FlaxEditor.Surface
|
|||||||
private Float2 _movingNodesDelta;
|
private Float2 _movingNodesDelta;
|
||||||
private Float2 _gridRoundingDelta;
|
private Float2 _gridRoundingDelta;
|
||||||
private HashSet<SurfaceNode> _movingNodes;
|
private HashSet<SurfaceNode> _movingNodes;
|
||||||
|
private HashSet<SurfaceNode> _temporarySelectedNodes;
|
||||||
private readonly Stack<InputBracket> _inputBrackets = new Stack<InputBracket>();
|
private readonly Stack<InputBracket> _inputBrackets = new Stack<InputBracket>();
|
||||||
|
|
||||||
private class InputBracket
|
private class InputBracket
|
||||||
@@ -130,13 +131,34 @@ namespace FlaxEditor.Surface
|
|||||||
if (_rootControl.Children[i] is SurfaceControl control)
|
if (_rootControl.Children[i] is SurfaceControl control)
|
||||||
{
|
{
|
||||||
var select = control.IsSelectionIntersecting(ref selectionRect);
|
var select = control.IsSelectionIntersecting(ref selectionRect);
|
||||||
if (select != control.IsSelected)
|
|
||||||
|
if (Root.GetKey(KeyboardKeys.Shift))
|
||||||
{
|
{
|
||||||
control.IsSelected = select;
|
if (select == control.IsSelected && _temporarySelectedNodes.Contains(control))
|
||||||
selectionChanged = true;
|
{
|
||||||
|
control.IsSelected = !select;
|
||||||
|
selectionChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Root.GetKey(KeyboardKeys.Control))
|
||||||
|
{
|
||||||
|
if (select != control.IsSelected && !_temporarySelectedNodes.Contains(control))
|
||||||
|
{
|
||||||
|
control.IsSelected = select;
|
||||||
|
selectionChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (select != control.IsSelected)
|
||||||
|
{
|
||||||
|
control.IsSelected = select;
|
||||||
|
selectionChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectionChanged)
|
if (selectionChanged)
|
||||||
SelectionChanged?.Invoke();
|
SelectionChanged?.Invoke();
|
||||||
}
|
}
|
||||||
@@ -461,6 +483,19 @@ namespace FlaxEditor.Surface
|
|||||||
// Cache data
|
// Cache data
|
||||||
_isMovingSelection = false;
|
_isMovingSelection = false;
|
||||||
_mousePos = location;
|
_mousePos = location;
|
||||||
|
if(_temporarySelectedNodes == null)
|
||||||
|
_temporarySelectedNodes = new HashSet<SurfaceNode>();
|
||||||
|
else
|
||||||
|
_temporarySelectedNodes.Clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < _rootControl.Children.Count; i++)
|
||||||
|
{
|
||||||
|
if (_rootControl.Children[i] is SurfaceNode node && node.IsSelected)
|
||||||
|
{
|
||||||
|
_temporarySelectedNodes.Add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (button == MouseButton.Left)
|
if (button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
_leftMouseDown = true;
|
_leftMouseDown = true;
|
||||||
@@ -488,9 +523,11 @@ namespace FlaxEditor.Surface
|
|||||||
// Check if user is pressing control
|
// Check if user is pressing control
|
||||||
if (Root.GetKey(KeyboardKeys.Control))
|
if (Root.GetKey(KeyboardKeys.Control))
|
||||||
{
|
{
|
||||||
// Add/remove from selection
|
AddToSelection(controlUnderMouse);
|
||||||
controlUnderMouse.IsSelected = !controlUnderMouse.IsSelected;
|
}
|
||||||
SelectionChanged?.Invoke();
|
else if (Root.GetKey(KeyboardKeys.Shift))
|
||||||
|
{
|
||||||
|
RemoveFromSelection(controlUnderMouse);
|
||||||
}
|
}
|
||||||
// Check if node isn't selected
|
// Check if node isn't selected
|
||||||
else if (!controlUnderMouse.IsSelected)
|
else if (!controlUnderMouse.IsSelected)
|
||||||
@@ -500,10 +537,14 @@ namespace FlaxEditor.Surface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start moving selected nodes
|
// Start moving selected nodes
|
||||||
StartMouseCapture();
|
if (!Root.GetKey(KeyboardKeys.Shift))
|
||||||
_movingSelectionViewPos = _rootControl.Location;
|
{
|
||||||
_movingNodesDelta = Float2.Zero;
|
StartMouseCapture();
|
||||||
OnGetNodesToMove();
|
_movingSelectionViewPos = _rootControl.Location;
|
||||||
|
_movingNodesDelta = Float2.Zero;
|
||||||
|
OnGetNodesToMove();
|
||||||
|
}
|
||||||
|
|
||||||
Focus();
|
Focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -515,7 +556,12 @@ namespace FlaxEditor.Surface
|
|||||||
{
|
{
|
||||||
// Start selecting or commenting
|
// Start selecting or commenting
|
||||||
StartMouseCapture();
|
StartMouseCapture();
|
||||||
ClearSelection();
|
|
||||||
|
if (!Root.GetKey(KeyboardKeys.Control) && !Root.GetKey(KeyboardKeys.Shift))
|
||||||
|
{
|
||||||
|
ClearSelection();
|
||||||
|
}
|
||||||
|
|
||||||
Focus();
|
Focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -710,6 +710,18 @@ namespace FlaxEditor.Surface
|
|||||||
SelectionChanged?.Invoke();
|
SelectionChanged?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the specified control from the selection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="control">The control.</param>
|
||||||
|
public void RemoveFromSelection(SurfaceControl control)
|
||||||
|
{
|
||||||
|
if (!control.IsSelected)
|
||||||
|
return;
|
||||||
|
control.IsSelected = false;
|
||||||
|
SelectionChanged?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Selects the specified control.
|
/// Selects the specified control.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user