Skip to content

feat: Introduce NodeId type decoupled from egui::Id#41

Merged
mitchmindtree merged 2 commits intonannou-org:mainfrom
mitchmindtree:node-id
Jan 17, 2026
Merged

feat: Introduce NodeId type decoupled from egui::Id#41
mitchmindtree merged 2 commits intonannou-org:mainfrom
mitchmindtree:node-id

Conversation

@mitchmindtree
Copy link
Member

Add a dedicated NodeId type for identifying nodes within a graph, separate from egui's internal Id type. This allows node identity and layout positions to remain stable even when the graph widget's egui ID context changes (e.g., when viewing the same graph through different UI paths or contexts).

Key changes:

  • Add NodeId wrapper type around u64 with constructors
  • Change Layout from HashMap<egui::Id, Pos2> to HashMap<NodeId, Pos2>
  • Update Node::from_id to accept NodeId instead of egui::Id
  • Update Edge to use NodeId for node references
  • Add node::egui_id(graph_id, node_id) helper to derive internal
    egui::Id for area_rect lookups
  • Update selection tracking to use NodeId
  • Update layout() function signature to use NodeId

BREAKING CHANGE: Public API now uses NodeId instead of egui::Id for node identification. Users must update their code to use NodeId::new(), NodeId::from_u64(), or NodeId::from().

Add a dedicated `NodeId` type for identifying nodes within a graph,
separate from egui's internal `Id` type. This allows node identity
and layout positions to remain stable even when the graph widget's
egui ID context changes (e.g., when viewing the same graph through
different UI paths or contexts).

Key changes:
- Add `NodeId` wrapper type around `u64` with constructors
- Change `Layout` from `HashMap<egui::Id, Pos2>` to `HashMap<NodeId, Pos2>`
- Update `Node::from_id` to accept `NodeId` instead of `egui::Id`
- Update `Edge` to use `NodeId` for node references
- Add `node::egui_id(graph_id, node_id)` helper to derive internal
  egui::Id for area_rect lookups
- Update selection tracking to use `NodeId`
- Update `layout()` function signature to use `NodeId`

BREAKING CHANGE: Public API now uses `NodeId` instead of `egui::Id`
for node identification. Users must update their code to use
`NodeId::new()`, `NodeId::from_u64()`, or `NodeId::from()`.
@mitchmindtree mitchmindtree self-assigned this Jan 17, 2026
@mitchmindtree mitchmindtree merged commit 9691b30 into nannou-org:main Jan 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant