Merge branch 'xxSeys1-FocusSelectedVJControls'
This commit is contained in:
@@ -710,6 +710,10 @@ namespace FlaxEditor.Options
|
||||
[EditorDisplay("Node Editors"), EditorOrder(4580)]
|
||||
public InputBinding NodesDistributeVertical = new InputBinding(KeyboardKeys.A, KeyboardKeys.Alt);
|
||||
|
||||
[DefaultValue(typeof(InputBinding), "Shift+F")]
|
||||
[EditorDisplay("Node Editors"), EditorOrder(4590)]
|
||||
public InputBinding FocusSelectedNodes = new InputBinding(KeyboardKeys.F, KeyboardKeys.Shift);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,13 +573,13 @@ namespace FlaxEditor.Surface
|
||||
var showSearch = () => editor.ContentFinding.ShowSearch(window);
|
||||
|
||||
// Toolstrip
|
||||
saveButton = toolStrip.AddButton(editor.Icons.Save64, window.Save).LinkTooltip("Save", ref inputOptions.Save);
|
||||
saveButton = toolStrip.AddButton(editor.Icons.Save64, window.Save).LinkTooltip("Save.", ref inputOptions.Save);
|
||||
toolStrip.AddSeparator();
|
||||
undoButton = toolStrip.AddButton(editor.Icons.Undo64, undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo);
|
||||
redoButton = toolStrip.AddButton(editor.Icons.Redo64, undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo);
|
||||
undoButton = toolStrip.AddButton(editor.Icons.Undo64, undo.PerformUndo).LinkTooltip("Undo.", ref inputOptions.Undo);
|
||||
redoButton = toolStrip.AddButton(editor.Icons.Redo64, undo.PerformRedo).LinkTooltip("Redo.", ref inputOptions.Redo);
|
||||
toolStrip.AddSeparator();
|
||||
toolStrip.AddButton(editor.Icons.Search64, showSearch).LinkTooltip("Open content search tool", ref inputOptions.Search);
|
||||
toolStrip.AddButton(editor.Icons.CenterView64, surface.ShowWholeGraph).LinkTooltip("Show whole graph");
|
||||
toolStrip.AddButton(editor.Icons.Search64, showSearch).LinkTooltip("Open content search tool.", ref inputOptions.Search);
|
||||
toolStrip.AddButton(editor.Icons.CenterView64, surface.ShowWholeGraph).LinkTooltip("Show whole graph.");
|
||||
var gridSnapButton = toolStrip.AddButton(editor.Icons.Grid32, surface.ToggleGridSnapping);
|
||||
gridSnapButton.LinkTooltip("Toggle grid snapping for nodes.");
|
||||
gridSnapButton.AutoCheck = true;
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace FlaxEditor.Surface
|
||||
private HashSet<SurfaceNode> _movingNodes;
|
||||
private HashSet<SurfaceNode> _temporarySelectedNodes;
|
||||
private readonly Stack<InputBracket> _inputBrackets = new Stack<InputBracket>();
|
||||
private InputBinding _focusSelectedNodeBinding;
|
||||
|
||||
private class InputBracket
|
||||
{
|
||||
@@ -704,13 +705,21 @@ namespace FlaxEditor.Surface
|
||||
|
||||
private void MoveSelectedNodes(Float2 delta)
|
||||
{
|
||||
// TODO: undo
|
||||
List<MoveNodesAction> undoActions = new List<MoveNodesAction>();
|
||||
|
||||
delta /= _targetScale;
|
||||
OnGetNodesToMove();
|
||||
foreach (var node in _movingNodes)
|
||||
{
|
||||
node.Location += delta;
|
||||
if (Undo != null)
|
||||
undoActions.Add(new MoveNodesAction(Context, new[] { node.ID }, delta));
|
||||
}
|
||||
_isMovingSelection = false;
|
||||
MarkAsEdited(false);
|
||||
|
||||
if (undoActions.Count > 0)
|
||||
Undo?.AddAction(new MultiUndoAction(undoActions, "Moved "));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -845,7 +854,8 @@ namespace FlaxEditor.Surface
|
||||
|
||||
private void CurrentInputTextChanged(string currentInputText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(currentInputText))
|
||||
// Check if focus selected nodes binding is being pressed to prevent it triggering primary menu
|
||||
if (string.IsNullOrEmpty(currentInputText) || _focusSelectedNodeBinding.Process(RootWindow))
|
||||
return;
|
||||
if (IsPrimaryMenuOpened || !CanEdit)
|
||||
{
|
||||
|
||||
@@ -423,8 +423,9 @@ namespace FlaxEditor.Surface
|
||||
new InputActionsContainer.Binding(options => options.NodesAlignLeft, () => { AlignNodes(SelectedNodes, NodeAlignmentType.Left); }),
|
||||
new InputActionsContainer.Binding(options => options.NodesAlignCenter, () => { AlignNodes(SelectedNodes, NodeAlignmentType.Center); }),
|
||||
new InputActionsContainer.Binding(options => options.NodesAlignRight, () => { AlignNodes(SelectedNodes, NodeAlignmentType.Right); }),
|
||||
new InputActionsContainer.Binding(options => options.NodesDistributeHorizontal, () => { DistributeNodes(SelectedNodes, false); }),
|
||||
new InputActionsContainer.Binding(options => options.NodesDistributeVertical, () => { DistributeNodes(SelectedNodes, true); }),
|
||||
new InputActionsContainer.Binding(options => options.NodesDistributeHorizontal, () => { DistributeNodes(SelectedNodes, false); }),
|
||||
new InputActionsContainer.Binding(options => options.NodesDistributeVertical, () => { DistributeNodes(SelectedNodes, true); }),
|
||||
new InputActionsContainer.Binding(options => options.FocusSelectedNodes, () => { FocusSelectionOrWholeGraph(); }),
|
||||
});
|
||||
|
||||
Context.ControlSpawned += OnSurfaceControlSpawned;
|
||||
@@ -436,7 +437,10 @@ namespace FlaxEditor.Surface
|
||||
DragHandlers.Add(_dragAssets = new DragAssets<DragDropEventArgs>(ValidateDragItem));
|
||||
DragHandlers.Add(_dragParameters = new DragNames<DragDropEventArgs>(SurfaceParameter.DragPrefix, ValidateDragParameter));
|
||||
|
||||
OnEditorOptionsChanged(Editor.Instance.Options.Options);
|
||||
|
||||
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
|
||||
Editor.Instance.Options.OptionsChanged += OnEditorOptionsChanged;
|
||||
}
|
||||
|
||||
private void OnScriptsReloadBegin()
|
||||
@@ -446,6 +450,11 @@ namespace FlaxEditor.Surface
|
||||
_cmPrimaryMenu = null;
|
||||
}
|
||||
|
||||
private void OnEditorOptionsChanged(EditorOptions options)
|
||||
{
|
||||
_focusSelectedNodeBinding = options.Input.FocusSelectedNodes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display name of the connection type used in the surface.
|
||||
/// </summary>
|
||||
@@ -648,6 +657,37 @@ namespace FlaxEditor.Surface
|
||||
ViewCenterPosition = areaRect.Center;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the view to focus on the currently selected nodes, or the entire graph if no nodes are selected.
|
||||
/// </summary>
|
||||
public void FocusSelectionOrWholeGraph()
|
||||
{
|
||||
if (SelectedNodes.Count > 0)
|
||||
ShowSelection();
|
||||
else
|
||||
ShowWholeGraph();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the selected controls by changing the view scale and the position.
|
||||
/// </summary>
|
||||
public void ShowSelection()
|
||||
{
|
||||
var selection = SelectedControls;
|
||||
if (selection.Count == 0)
|
||||
return;
|
||||
|
||||
// Calculate the bounds of all selected controls
|
||||
Rectangle bounds = selection[0].Bounds;
|
||||
for (int i = 1; i < selection.Count; i++)
|
||||
bounds = Rectangle.Union(bounds, selection[i].Bounds);
|
||||
|
||||
// Add margin
|
||||
bounds = bounds.MakeExpanded(250.0f);
|
||||
|
||||
ShowArea(bounds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the given surface node by changing the view scale and the position and focuses the node.
|
||||
/// </summary>
|
||||
@@ -1071,6 +1111,7 @@ namespace FlaxEditor.Surface
|
||||
_cmPrimaryMenu?.Dispose();
|
||||
|
||||
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
|
||||
Editor.Instance.Options.OptionsChanged += OnEditorOptionsChanged;
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
{
|
||||
Parent = this
|
||||
};
|
||||
_toolstrip.AddButton(editor.Icons.Search64, () => Editor.Windows.ContentWin.Select(_item)).LinkTooltip("Show and select in Content Window");
|
||||
_toolstrip.AddButton(editor.Icons.Search64, () => Editor.Windows.ContentWin.Select(_item)).LinkTooltip("Show and select in Content Window.");
|
||||
|
||||
InputActions.Add(options => options.Save, Save);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user