Node Editor
The screen
Section titled “The screen”
This backbuffer capture comes from the native Node Editor companion. It opens on a still native frame and plays the original GIF on request. The Node Editor is not a graph evaluation or persistence engine.
When it fits
Section titled “When it fits”Use it when your application already owns a graph model and needs a zoomable canvas with sockets, links, selection, and editing UI. The separate imkit::node_editor target draws a graph snapshot and returns typed edit requests to the host. It can sit beside Theme, ordinary ImGui widgets, and application-specific panels.
The module does not replace a graph data format, undo system, evaluation engine, or file format.
Minimal draw call
Section titled “Minimal draw call”#include <imkit/node_editor.h>
namespace ne = imkit::node_editor;
// Compile-checked function excerpt. Call from the host's active ImGui frame.void DrawNodeSurface(ne::GraphView graph, ne::EditorState& state, ne::RequestBuffer& requests, const ne::NodeStyle& style) { auto frame = ne::BeginEditor("material-graph", graph, state, requests, style); ne::DrawLinks(frame); // schedule links once; EndEditor draws them after node rows if (frame.visible) { ne::DrawNodes(frame); } ne::EndEditor(frame); // required even when frame.visible is false}Example type: this function excerpt is called from an existing host. The caller creates a GraphView from its host model, retains EditorState across frames, provides a finite RequestBuffer, and derives the style with MakeNodeStyle(theme). Call it between the host’s NewFrame and Render.
The minimum integration order is: build the view, call BeginEditor, schedule links once, draw nodes, call EndEditor, then consume requests. Use the same EditorFrame if you draw socket rows or node bodies yourself.
Connect it to the host model
Section titled “Connect it to the host model”GraphView borrows its nodes, pins, and links through std::span. Strings in NodeView, style pointers, callbacks, and user data are borrowed as well. Keep that storage stable until related draw calls finish, including inspectors and detached previews.
For each operation in RequestBuffer::Requests(), the host checks the graph ID and revision, validates all requests in the operation, then applies the full operation or rejects it without changes. Advance the revision after acceptance. Undo, copy/paste data, persistence, evaluation, workers, the context, and backend remain host responsibilities.
canConnect can preflight type conversions and application-specific rules, but final host validation is still required. Without a callback, distinct non-zero types do not match and zero means unspecified. The host chooses whether cycles are allowed.
Keep these rules
Section titled “Keep these rules”- Node, Pin, Link, and Graph IDs are distinct 64-bit types. Reserve zero and keep IDs unique within a graph.
- Always call
EndEditor, even when the returned frame is not visible. CallEndNodeonly afterBeginNodereturns true. - Keep one
EditorStateper editor and use it on the same Dear ImGui context. Do not retain the frame object or move it between contexts. - Do not partially persist an operation when capacity or revision checks fail. Treat Begin/Update of a continuous gesture as a draft and apply only Commit.