Vixen
02b45cc4
csharp
public sealed class MoveNodesCommand

Moving some nodes.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Merging is what makes a drag one undo step, the same bargain SetMembersCommand makes for a slider: two of these merge when they move the same nodes, and the merged one keeps the earlier's starting positions, so one undo goes back to before the drag rather than to one mouse-move ago. CommandStack.Seal on the pointer release ends the run.

⚠ The starting positions are read when the command is built, not when it is applied. A view that has already moved its own copy of the nodes — which is what a live drag is — must build this before writing anything back to the model, or the "before" it records is the "after".

Fields and properties (1)

  • public override string Name

    What this is called in the undo history, as a person would say it.

Methods (4)

  • public MoveNodesCommand(NodeGraphModel graph, IReadOnlyDictionary<NodeId, Vector2> positions, EditorDocument? document = null, string name = "Move Nodes", bool coalesces = true)

    Describes moving some nodes.

  • protected override void Apply()

    Makes the change. Called once on execute and again on every redo.

  • protected override void Revert()

    Puts back exactly what Apply changed.

  • public override bool TryMergeWith(IEditorCommand previous, out IEditorCommand? merged)

Used by (3)

  • CommandTestsVixen.Editor.NodeGraph.Tests
  • LayoutCommandVixen.Editor.NodeGraph
  • NodeGraphViewVixen.Editor.NodeGraph