Vixen
02b45cc4
csharp
public sealed class NodeGraphClipboard

Copying a slice of a graph, and holding it until somebody pastes it.

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

Remarks

A fragment is a NodeGraphAsset. A copied selection is a small graph — nodes, the edges between them, the values they carry — which is exactly what the file shape already is. Inventing a second shape for it would mean two things to keep in step and two things to version, and it would mean a fragment could not be written to the system clipboard as text without a converter of its own.

⚠ Only the edges with both ends in the selection travel. A wire whose far end is not copied is not a wire the paste could reproduce — there is nothing for it to arrive at — and carrying it as a dangling reference would produce a paste that silently dropped edges or, worse, connected to whatever node happened to hold that identity in the target graph.

An instance rather than a static. Two graph editors open at once should not share a clipboard by accident, and a test should not have to reset a global between cases. Default is there for the ordinary single-shell case, which is what the inspector's PropertyClipboard does and for the same reason.

Fields and properties (4)

  • public static readonly Vector2 DefaultOffset

    How far a paste offsets what it drops, when the caller does not say.

  • public static NodeGraphClipboard Default

    The one every graph editor in a shell shares.

  • public NodeGraphAsset? Content

    What was copied, or null when nothing has been.

  • public bool HasContent

    Whether there is anything to paste.

Methods (3)

  • public static NodeGraphAsset? Copy(NodeGraphModel graph, IEnumerable<NodeId> nodes)

    Takes a copy of some of a graph's nodes.

  • public bool Take(NodeGraphModel graph, IEnumerable<NodeId> nodes)

    Copies some of a graph's nodes into this clipboard.

  • public void Clear()

    Forgets what was copied.

Used by (2)

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