dear-imnodes
Safe, idiomatic Rust bindings for ImNodes via the cimnodes C API, aligned with our dear-imgui workspace and BEST_PRACTICES.
- Ui extension:
ui.imnodes(&ctx)returns aNodesUifor the current frame - Contexts:
Context(global) andEditorContext(per-editor) withDrop - RAII tokens:
editor(),node(id),input_attr(id),output_attr(id),static_attr(id) - Strongly-typed enums/bitflags for style and attributes
- Helpers: links, selection, node positions, minimap, IO setup
Links
- Upstream: https://github.com/Nelarius/imnodes
- C API: https://github.com/cimgui/cimnodes
Compatibility
| Item | Version |
|---|---|
| Crate | 0.7.x |
| dear-imgui-rs | 0.7.x |
| dear-imnodes-sys | 0.7.x |
See also: docs/COMPATIBILITY.md for the full workspace matrix.
Quick Start
Basic setup and per-frame usage:
use Ui;
use dear_imnodes as imnodes;
// One-time setup (alongside your ImGui context)
// Per-frame draw
IO and Interaction
Bind common shortcuts to ImNodes IO (call while the editor is active):
// Ctrl to detach links; multi-select via Shift; emulate 3-button mouse with Alt
editor.enable_link_detach_with_ctrl;
editor.enable_multiple_select_with_shift;
editor.emulate_three_button_mouse_with_alt;
// Misc IO tweaks
editor.set_alt_mouse_button; // e.g. MouseRight
editor.set_auto_panning_speed;
Styling
Use presets or fine-tune values. You can push scoped styles/colors (RAII) or set persistent style:
// Presets
editor.style_colors_dark;
// Push a color for this scope
let _color = editor.push_color;
// Push a style var for this scope
let _sv = editor.push_style_var;
// Persistent style
editor.set_grid_spacing;
editor.set_node_corner_rounding;
// Read/Write a style color (persistent)
let link_rgba = editor.get_color;
editor.set_color;
Node Positions and Queries
// Position nodes (grid/editor/screen space helpers available)
editor.set_node_pos_grid;
let size = editor.get_node_dimensions; // [w, h]
// Hover/active queries
if editor.is_editor_hovered
if let Some = editor.hovered_node
if editor.is_attribute_active
Selection and Link Lifecycle
// Selection helpers
let selected_nodes = editor.selected_nodes;
let selected_links = editor.selected_links;
// Link lifecycle
if let Some = editor.is_link_created_with_nodes
if let Some = editor.is_link_destroyed
Saving/Loading Editor State
Use EditorContext to persist per-editor state across sessions, or use post-editor helpers for the current editor:
// Per-editor state (no active frame required)
let s = editor_ctx.save_state_to_ini_string;
editor_ctx.load_state_from_ini_string;
editor_ctx.save_state_to_ini_file;
editor_ctx.load_state_from_ini_file;
// Or directly after ending a frame
let post = editor.end;
let s2 = post.save_state_to_ini_string;
post.load_state_from_ini_string;
post.save_state_to_ini_file;
See crate docs for the full API surface and patterns.