iced_nodegraph

A node graph editor widget for iced

crates.io 0.5.0

What the host owns

The widget is stateless between frames and never mutates your data model. It renders the nodes and edges you pass in and reports intent through callbacks; your update applies the change and the next view reflects it. Which makes these yours to uphold:

  • Unique node ids. Lookups resolve by id, so a duplicate push is ignored (first wins) and debug builds assert on it. Prefer a stable id from your data - a database key, uuid::Uuid, a typed newtype - over a hand-managed counter.
  • Edge dedupe. on_connect fires on every snap during a drag, not on release, so one drag can report several connections. The default can_connect already rejects a second edge into an occupied input; for replace-on-drop instead, drop that rule (see connection) and remove the prior edge whose input matches - to is always the input pin.
  • Applying moves, deletes and clones. on_move / on_delete / on_clone report intent only.
  • Applying selection. Optional: the widget keeps a working selection, so clicks and the selection box work on their own. on_select reports it; to own it, mark the matching nodes with Node::selected on the next view and your value takes over whenever it changes. Selection is a node property, so there is no ordering to get right. The camera is the same story through on_camera and camera.