public sealed class NodeGraphViewA NodeGraphModel on a NodeCanvas, with every gesture going through the undo stack.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Two graph types, and the view is the only thing that knows both. NodeGraphModel is the document — identities, port names, saved and diffed — and Vixen.Ui.Controls.Advanced.NodeGraph is what a canvas draws, which is boxes with sockets on and no idea what a node type is. Keeping them apart is what lets the model be tested against numbers and the canvas be tested against a fixture with three nodes called "a", "b" and "c"; this class is the projection between them and it is one direction only. The model is the truth and the canvas is a picture of it.
⚠ Every structural change reprojects the whole graph. A cheaper incremental update is possible and was not written, for two reasons: the canvas culls to the viewport already, so the expensive part is bounded by the screen rather than by the graph; and a projection that is rebuilt cannot drift from the model, which an incremental one does the first time somebody adds an edit path and forgets a case. A drag is the one thing that does not reproject — it writes positions in place — because that is the path that runs every frame.
⚠ The canvas edits its own copy optimistically, and that is on purpose. Dragging a wire connects it in the picture before this class has recorded anything, which is what makes the gesture feel live. What follows is either a command — and the reprojection agrees with it — or a reprojection alone, which puts the picture back. A canvas that had to ask permission before drawing would be a canvas with a frame of latency in every gesture.
No stack means read-only. Every edit here goes through Stack, so a view without one shows a graph and refuses to change it — which is exactly what a preview of a sub-graph, or of an asset that is not open for editing, should do.
Fields and properties (17)
protected override string TagNameThe element name this type answers to when a caller does not choose one.
protected override bool AcceptsFocusWhether the focus can rest on this kind of control at all.
public NodeCanvas CanvasThe canvas everything is drawn on.
public NodeMinimap MinimapThe overview in the corner, which is the canvas's own.
public NodePreviewLayer PreviewsThe swatches under the nodes that asked for one.
public NodeSearchPopup SearchThe create-a-node popup.
public float NodeWidthHow wide a node is drawn, in graph units.
public int DecimalsHow many decimal places a number on a node shows.
public NodeGraphModel GraphThe graph being shown.
public NodeTypeRegistry RegistryThe node types the graph may contain.
public ISubGraphSource? SubGraphSourceWhere sub-graphs are found, when this graph has any.
public INodePreviewSource? PreviewSourceWhere a preview swatch's colour comes from.
public NodeGraphClipboard ClipboardWhere copy and paste put things.
public CommandStack? StackWhere edits are recorded, or null for a view that cannot be edited.
public EditorDocument? EditedDocumentThe document to mark dirty, if the graph belongs to one.
public bool IsReadOnlyWhether edits are refused because there is nowhere to record them.
public IReadOnlyCollection<NodeId> SelectionWhat is selected, by identity.
Events (4)
public Action<NodeGraphView>? SelectionChangedRaised after the selection changes.
public Action<NodeGraphView, ConnectionRefusal>? ConnectionRefusedRaised when a wire was dropped somewhere it could not go.
public Action<NodeGraphView, string, NodeGraphModel>? SubGraphOpenedRaised when a node standing for a sub-graph is opened.
public Action<NodeGraphView>? GraphChangedRaised after the model this view is showing changed, however it changed.
Methods (20)
protected override void OnCreated()Builds whatever this element is made of, once, as it joins a document.
protected override void OnRemoved()protected override void OnDraw(DrawContext context)public NodeTypeDefinition? Definition(string type)The node type at a path, including the two a sub-graph's boundary nodes use.
public GraphNode? NodeOf(GraphNode node)The model node an element on the canvas is showing.
public void Project()Rebuilds the picture from the model.
public GraphNode? Create(string type, Vector2 position)Adds a node.
public bool DeleteSelection()Deletes what is selected, and the wires that touched it.
public bool GroupSelection(string title = "Group")Draws a box round what is selected.
public bool UngroupSelection()Removes every group that holds a selected node, leaving the nodes where they are.
public GraphComment? AddComment(string text, Vector2 position)Adds a sticky note.
public bool CopySelection()Copies what is selected.
public bool CutSelection()Copies what is selected and deletes it.
public bool Paste(Vector2? at = null)Pastes whatever was copied, offset so it does not land on the original.
public bool AutoLayout()Lays the whole graph out left to right.
public NodeLayoutOptions LayoutOptions()What the layout should assume about node sizes, read off the canvas's theme.
public NodeGraphModel? ExtractSelection(string name, string path, SubGraphLibrary library)Lifts what is selected out into a sub-graph.
public void Frame(bool selectionOnly = false)Pans and zooms until everything fits, or until the selection does.
public void Select(IEnumerable<NodeId> nodes)Selects some nodes and nothing else.
public void OpenSearch(float x, float y)Opens the create-a-node popup, with nothing wired to it.
Used by (9)
- CompositorViewVixen.Editor.AssetEditors
- NodeInspectorVixen.Editor.NodeGraph
- NodePreviewLayerVixen.Editor.NodeGraph
- PortValueTestsVixen.Editor.NodeGraph.Tests
- ShaderGraphViewVixen.Editor.AssetEditors
- ShaderGraphViewTestsVixen.Editor.AssetEditors.Tests
- VfxGraphViewVixen.Editor.AssetEditors
- ViewFixtureVixen.Editor.NodeGraph.Tests
- ViewTestsVixen.Editor.NodeGraph.Tests