Add the option to deselect all whereve there is a select all, Refactor much of the codebase to use keybinds from InputOptions.

This commit is contained in:
Menotdan
2023-12-08 20:16:07 -05:00
parent bcce52ca22
commit 13cc45c3d7
13 changed files with 179 additions and 65 deletions

View File

@@ -382,6 +382,7 @@ namespace FlaxEditor.Surface
{
new InputActionsContainer.Binding(options => options.Delete, Delete),
new InputActionsContainer.Binding(options => options.SelectAll, SelectAll),
new InputActionsContainer.Binding(options => options.DeselectAll, DeselectAll),
new InputActionsContainer.Binding(options => options.Copy, Copy),
new InputActionsContainer.Binding(options => options.Paste, Paste),
new InputActionsContainer.Binding(options => options.Cut, Cut),
@@ -611,17 +612,14 @@ namespace FlaxEditor.Surface
_context.MarkAsModified(graphEdited);
}
/// <summary>
/// Selects all the nodes.
/// </summary>
public void SelectAll()
private void BulkSelectUpdate(bool select = true)
{
bool selectionChanged = false;
for (int i = 0; i < _rootControl.Children.Count; i++)
{
if (_rootControl.Children[i] is SurfaceControl control && !control.IsSelected)
if (_rootControl.Children[i] is SurfaceControl control && control.IsSelected != select)
{
control.IsSelected = true;
control.IsSelected = select;
selectionChanged = true;
}
}
@@ -629,6 +627,22 @@ namespace FlaxEditor.Surface
SelectionChanged?.Invoke();
}
/// <summary>
/// Selects all the nodes.
/// </summary>
public void SelectAll()
{
BulkSelectUpdate(true);
}
/// <summary>
/// Deelects all the nodes.
/// </summary>
public void DeselectAll()
{
BulkSelectUpdate(false);
}
/// <summary>
/// Clears the selection.
/// </summary>