Skip to content

NodeEditorRenderer has no hook for host content inside a node body #441

Description

@matt-edmondson

NodeEditorRenderer draws a fixed node body and offers no way for a host to add content to it, so a widget inside a node is not reachable without abandoning the renderer. Raised while investigating #437.

What happens

RenderNode (NodeEditorRenderer.cs:305) submits a title bar, then one ImGui.Text per input pin and one right-aligned ImGui.Text per output pin, between ImNodes.BeginNode (:340) and ImNodes.EndNode (:396). There is no callback anywhere on the type: no property on NodeEditorRenderer is an Action or a Func.

ImNodes itself has no such restriction. Anything submitted between BeginNode and EndNode, or inside an attribute's begin and end pair, is drawn in the node and sized into it, which is how a slider or a combo ends up on a node in the usual ImNodes idiom.

Why it matters

A host wanting a value editable on the node face has two choices today, and both are bad. Fork the renderer, which means giving up zoom, hover highlighting, the measured position and dimension feedback and the pin offset publishing, all of which live in this class. Or draw the graph with raw ImNodes calls and use NodeEditorEngine for topology and physics alone, which throws away the same things.

A renderer hook is also the piece that makes the pin offsets keep working. The engine measures a link between the points a renderer joins, via UpdatePinOffset, and PublishPinOffsets runs off the rows this method records. Content drawn by a host inside the node changes those rows, and the renderer is the only place that can see the change.

Sketch

A per-node callback invoked inside the node, after the pins:

public Action<Node>? DrawNodeBody { get; set; }

and possibly a per-pin one, invoked inside the input attribute so an unconnected input can offer an inline editor in the place the value would arrive:

public Action<Node, Pin>? DrawPinBody { get; set; }

Both would need to say clearly what the host may and may not call: the id stack is the node's, the cursor is mid-node, and ImNodes sizes the node from whatever gets submitted.

The per-pin form is the one that matters for #437 and needs the most thought, because whether an input pin should show an editor depends on whether it is connected, which is a question about the graph and not about drawing.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions