dear_imnodes/lib.rs
1//! Dear ImNodes - Rust Bindings with Dear ImGui Compatibility
2//!
3//! High-level Rust bindings for ImNodes, the node editor for Dear ImGui.
4//! This crate follows the same patterns as our `dear-implot` and `dear-imguizmo`
5//! crates: Ui extensions, RAII tokens, and strongly-typed flags/enums.
6
7use dear_imnodes_sys as sys;
8
9const _: [(); std::mem::size_of::<sys::ImVec2>()] = [(); std::mem::size_of::<sys::ImVec2_c>()];
10const _: [(); std::mem::align_of::<sys::ImVec2>()] = [(); std::mem::align_of::<sys::ImVec2_c>()];
11
12// Similar to ImGui 1.92+ return-by-value changes, generated bindings for
13// `dear-imnodes-sys` may exist in the build directory in both the legacy
14// out-parameter form and the newer return-by-value form. rust-analyzer can end
15// up indexing the wrong `OUT_DIR` and report spurious signature errors.
16//
17// Keep the high-level wrapper stable by calling local extern declarations for
18// the return-by-value APIs we expose.
19#[allow(non_snake_case)]
20pub(crate) mod compat_ffi {
21 use super::sys;
22
23 unsafe extern "C" {
24 pub fn imnodes_EditorContextGetPanning() -> sys::ImVec2;
25 pub fn imnodes_GetNodeScreenSpacePos(node_id: i32) -> sys::ImVec2;
26 pub fn imnodes_GetNodeEditorSpacePos(node_id: i32) -> sys::ImVec2;
27 pub fn imnodes_GetNodeDimensions(node_id: i32) -> sys::ImVec2;
28 }
29}
30
31mod context;
32mod style;
33mod types;
34mod ui_ext;
35
36pub use context::*;
37pub use style::*;
38pub use types::*;
39pub use ui_ext::*;