Skip to content

Commit 64eb642

Browse files
committed
bump wgpu 0.27
new api
1 parent 60e30df commit 64eb642

File tree

20 files changed

+2829
-1536
lines changed

20 files changed

+2829
-1536
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ categories = ["gui", "api-bindings"]
99
readme = "README.md"
1010

1111
[dependencies]
12-
imnodes-sys = { version = "0.5.0", path = "imnodes-sys" }
12+
imnodes-sys = { version = "0.6.0", path = "imnodes-sys" }
1313
imgui = "0.12"
1414

1515
[features]

README.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,33 @@ They are inspsired by [implot-rs](https://github.com/4bb4/implot-rs).
1919
## TODO/ Ideas
2020

2121
- add example with salsa or some other incremental computation lib
22-
- IO
23-
- all Mouse/ Modifier helpers
24-
25-
nice to have:
26-
27-
- use Serde to make it possible to declare graphs and render them
28-
- load and save as well using imnode_* functions
29-
- add comments to everything
30-
- figure out good descriptions of coordinate systems
31-
- review types in unsafe code
32-
- especially -> &mut sys::Style
3322

3423
## Example (see `imnodes-wgpu-examples/src/hello_world.rs`)
3524

3625
```rust
37-
fn show(ui: &imgui::Ui, context: &mut imnodes::EditorContext) {
26+
pub fn show<'a>(ui: &imgui::Ui, context: &mut imnodes::EditorContext<'a>) {
3827
let mut id_generator = context.new_identifier_generator();
3928

4029
imnodes::editor(context, |mut editor| {
4130
editor.add_node(id_generator.next_node(), |mut node| {
4231
node.add_titlebar(|| ui.text("simple node :)"));
43-
4432
node.add_input(
45-
id_generator.next_input_pin(),
46-
imnodes::PinShape::Circle,
33+
&imnodes::InputAttributeDesc {
34+
id: id_generator.next_input_pin(),
35+
shape: imnodes::PinShape::Circle,
36+
},
4737
|| ui.text("input"),
4838
);
49-
5039
node.add_output(
51-
id_generator.next_output_pin(),
52-
imnodes::PinShape::QuadFilled,
40+
&imnodes::OutputAttributeDesc {
41+
id: id_generator.next_output_pin(),
42+
shape: imnodes::PinShape::QuadFilled,
43+
},
5344
|| ui.text("output"),
5445
);
5546
});
5647
});
5748
}
58-
5949
```
50+
51+
If you are looking for a pure rust gui node editor: <https://github.com/emilk/egui/discussions/166>

imnodes-sys-bindgen/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
22
name = "imnodes-sys-bindgen"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Benedikt Mandelkow"]
55
edition = "2024"
66

77
[dependencies]
8-
bindgen = "0.71.1"
8+
bindgen = "0.72.1"
99
imgui-sys = "0.12"

imnodes-sys-bindgen/src/main.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
// to git so people don't have to install clang just to use imnodes-rs.
44

55
fn main() {
6-
let cwd = std::env::current_dir().expect("Could not read current directory");
7-
let sys_crate_path = cwd
6+
// Use CARGO_MANIFEST_DIR to find the workspace root reliably
7+
let manifest_dir = std::path::PathBuf::from(
8+
std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"),
9+
);
10+
let sys_crate_path = manifest_dir
811
.join("..")
912
.join("imnodes-sys")
1013
.canonicalize()
@@ -14,23 +17,19 @@ fn main() {
1417
std::env::var_os("DEP_IMGUI_THIRD_PARTY").expect("DEP_IMGUI_THIRD_PARTY not defined"),
1518
);
1619

20+
let cimnodes_include_path = sys_crate_path.join("third-party").join("cimnodes");
21+
22+
let imvec2_c_path = sys_crate_path.join("third-party").join("imvec2_c.h");
23+
1724
let bindings = bindgen::Builder::default()
18-
.header(
19-
cimgui_include_path
20-
.join("cimgui.h")
21-
.to_str()
22-
.expect("Could not convert cimgui.h path to string"),
23-
)
24-
.header(
25-
sys_crate_path
26-
.join("third-party")
27-
.join("cimnodes")
28-
.join("cimnodes.h")
29-
.to_str()
30-
.expect("Could not turn cimnodes.h path into string"),
31-
)
3225
// https://github.com/rust-lang/rust-bindgen/issues/1533
3326
.clang_arg(format!("-I{}", cimgui_include_path.to_str().unwrap()))
27+
.clang_arg(format!("-I{}", cimnodes_include_path.to_str().unwrap()))
28+
// Force-include ImVec2_c definition before any cimnodes headers.
29+
// The cimnodes generator expects cimgui to define ImVec2_c, but imgui-sys's
30+
// cimgui uses ImVec2 instead. This header bridges the gap.
31+
.clang_arg(format!("-include{}", imvec2_c_path.to_str().unwrap()))
32+
.header(cimnodes_include_path.join("cimnodes.h").to_str().unwrap())
3433
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
3534
.clang_arg("-DCIMGUI_DEFINE_ENUMS_AND_STRUCTS=1")
3635
.allowlist_function("imnodes_.*")

imnodes-sys/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "imnodes-sys"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
edition = "2024"
55
authors = ["Benedikt Mandelkow", "imnodes-rs contributors"]
66
description = "Raw FFI bindings to imnodes"
@@ -13,4 +13,4 @@ links = "imnodes"
1313
imgui-sys = "0.12"
1414

1515
[build-dependencies]
16-
cc = "1.2.19"
16+
cc = "1.2.49"

imnodes-sys/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ fn main() -> io::Result<()> {
4747
.include(&cimgui_include_path)
4848
.include(&imgui_include_path)
4949
.include("third-party/cimnodes/imnodes/")
50+
.include("third-party/")
51+
// Force-include ImVec2_c definition before any cimnodes headers.
52+
// The cimnodes generator expects cimgui to define ImVec2_c, but imgui-sys's
53+
// cimgui uses ImVec2 instead. This header bridges the gap.
54+
.flag("-include")
55+
.flag("third-party/imvec2_c.h")
5056
.warnings(false)
5157
.cpp(true)
5258
.flag("-std=c++11")

imnodes-sys/src/bindings.rs

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/* automatically generated by rust-bindgen 0.71.1 */
1+
/* automatically generated by rust-bindgen 0.72.1 */
22

33
#[repr(C)]
44
#[derive(Debug, Copy, Clone)]
5-
pub struct ImGuiContext {
6-
_unused: [u8; 0],
7-
}
8-
#[repr(C)]
9-
#[derive(Debug, Copy, Clone)]
10-
pub struct ImVec2 {
5+
pub struct ImVec2_c {
116
pub x: f32,
127
pub y: f32,
138
}
149
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1510
const _: () = {
16-
["Size of ImVec2"][::std::mem::size_of::<ImVec2>() - 8usize];
17-
["Alignment of ImVec2"][::std::mem::align_of::<ImVec2>() - 4usize];
18-
["Offset of field: ImVec2::x"][::std::mem::offset_of!(ImVec2, x) - 0usize];
19-
["Offset of field: ImVec2::y"][::std::mem::offset_of!(ImVec2, y) - 4usize];
11+
["Size of ImVec2_c"][::std::mem::size_of::<ImVec2_c>() - 8usize];
12+
["Alignment of ImVec2_c"][::std::mem::align_of::<ImVec2_c>() - 4usize];
13+
["Offset of field: ImVec2_c::x"][::std::mem::offset_of!(ImVec2_c, x) - 0usize];
14+
["Offset of field: ImVec2_c::y"][::std::mem::offset_of!(ImVec2_c, y) - 4usize];
2015
};
2116
#[repr(C)]
2217
#[derive(Debug, Copy, Clone)]
18+
pub struct ImGuiContext {
19+
_unused: [u8; 0],
20+
}
21+
#[repr(C)]
22+
#[derive(Debug, Copy, Clone)]
2323
pub struct ImNodesContext {
2424
_unused: [u8; 0],
2525
}
@@ -170,7 +170,7 @@ const _: () = {
170170
pub struct ImNodesStyle {
171171
pub GridSpacing: f32,
172172
pub NodeCornerRounding: f32,
173-
pub NodePadding: ImVec2,
173+
pub NodePadding: ImVec2_c,
174174
pub NodeBorderThickness: f32,
175175
pub LinkThickness: f32,
176176
pub LinkLineSegmentsPerLength: f32,
@@ -181,8 +181,8 @@ pub struct ImNodesStyle {
181181
pub PinLineThickness: f32,
182182
pub PinHoverRadius: f32,
183183
pub PinOffset: f32,
184-
pub MiniMapPadding: ImVec2,
185-
pub MiniMapOffset: ImVec2,
184+
pub MiniMapPadding: ImVec2_c,
185+
pub MiniMapOffset: ImVec2_c,
186186
pub Flags: ImNodesStyleFlags,
187187
pub Colors: [::std::os::raw::c_uint; 29usize],
188188
}
@@ -270,10 +270,10 @@ unsafe extern "C" {
270270
pub fn imnodes_EditorContextSet(noname1: *mut ImNodesEditorContext);
271271
}
272272
unsafe extern "C" {
273-
pub fn imnodes_EditorContextGetPanning(pOut: *mut ImVec2);
273+
pub fn imnodes_EditorContextGetPanning() -> ImVec2_c;
274274
}
275275
unsafe extern "C" {
276-
pub fn imnodes_EditorContextResetPanning(pos: ImVec2);
276+
pub fn imnodes_EditorContextResetPanning(pos: ImVec2_c);
277277
}
278278
unsafe extern "C" {
279279
pub fn imnodes_EditorContextMoveToNode(node_id: ::std::os::raw::c_int);
@@ -317,7 +317,7 @@ unsafe extern "C" {
317317
pub fn imnodes_PushStyleVar_Float(style_item: ImNodesStyleVar, value: f32);
318318
}
319319
unsafe extern "C" {
320-
pub fn imnodes_PushStyleVar_Vec2(style_item: ImNodesStyleVar, value: ImVec2);
320+
pub fn imnodes_PushStyleVar_Vec2(style_item: ImNodesStyleVar, value: ImVec2_c);
321321
}
322322
unsafe extern "C" {
323323
pub fn imnodes_PopStyleVar(count: ::std::os::raw::c_int);
@@ -329,7 +329,7 @@ unsafe extern "C" {
329329
pub fn imnodes_EndNode();
330330
}
331331
unsafe extern "C" {
332-
pub fn imnodes_GetNodeDimensions(pOut: *mut ImVec2, id: ::std::os::raw::c_int);
332+
pub fn imnodes_GetNodeDimensions(id: ::std::os::raw::c_int) -> ImVec2_c;
333333
}
334334
unsafe extern "C" {
335335
pub fn imnodes_BeginNodeTitleBar();
@@ -372,22 +372,28 @@ unsafe extern "C" {
372372
pub fn imnodes_SetNodeDraggable(node_id: ::std::os::raw::c_int, draggable: bool);
373373
}
374374
unsafe extern "C" {
375-
pub fn imnodes_SetNodeScreenSpacePos(node_id: ::std::os::raw::c_int, screen_space_pos: ImVec2);
375+
pub fn imnodes_SetNodeScreenSpacePos(
376+
node_id: ::std::os::raw::c_int,
377+
screen_space_pos: ImVec2_c,
378+
);
376379
}
377380
unsafe extern "C" {
378-
pub fn imnodes_SetNodeEditorSpacePos(node_id: ::std::os::raw::c_int, editor_space_pos: ImVec2);
381+
pub fn imnodes_SetNodeEditorSpacePos(
382+
node_id: ::std::os::raw::c_int,
383+
editor_space_pos: ImVec2_c,
384+
);
379385
}
380386
unsafe extern "C" {
381-
pub fn imnodes_SetNodeGridSpacePos(node_id: ::std::os::raw::c_int, grid_pos: ImVec2);
387+
pub fn imnodes_SetNodeGridSpacePos(node_id: ::std::os::raw::c_int, grid_pos: ImVec2_c);
382388
}
383389
unsafe extern "C" {
384-
pub fn imnodes_GetNodeScreenSpacePos(pOut: *mut ImVec2, node_id: ::std::os::raw::c_int);
390+
pub fn imnodes_GetNodeScreenSpacePos(node_id: ::std::os::raw::c_int) -> ImVec2_c;
385391
}
386392
unsafe extern "C" {
387-
pub fn imnodes_GetNodeEditorSpacePos(pOut: *mut ImVec2, node_id: ::std::os::raw::c_int);
393+
pub fn imnodes_GetNodeEditorSpacePos(node_id: ::std::os::raw::c_int) -> ImVec2_c;
388394
}
389395
unsafe extern "C" {
390-
pub fn imnodes_GetNodeGridSpacePos(pOut: *mut ImVec2, node_id: ::std::os::raw::c_int);
396+
pub fn imnodes_GetNodeGridSpacePos(node_id: ::std::os::raw::c_int) -> ImVec2_c;
391397
}
392398
unsafe extern "C" {
393399
pub fn imnodes_SnapNodeToGrid(node_id: ::std::os::raw::c_int);

imnodes-sys/third-party/imvec2_c.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ImVec2_c definition for cimnodes compatibility
2+
//
3+
// The cimnodes generator expects cimgui to be a sibling folder and uses
4+
// its `ImVec2_c` type. When using standalone with imgui-sys (which uses
5+
// a different cimgui version that defines ImVec2 instead), we need to
6+
// provide this definition.
7+
//
8+
// This header should be included before cimnodes.h
9+
10+
#ifndef IMVEC2_C_H
11+
#define IMVEC2_C_H
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
typedef struct ImVec2_c {
18+
float x;
19+
float y;
20+
} ImVec2_c;
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif
25+
26+
#endif // IMVEC2_C_H

imnodes-wgpu-examples/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "imnodes-wgpu-examples"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = [
55
"Benedikt Mandelkow <benedikt.mandelkow@rwth-aachen.de>",
66
"imgui-wgpu contributors",
@@ -10,9 +10,10 @@ edition = "2024"
1010
[dependencies]
1111
imnodes = { path = "../" }
1212

13-
wgpu = "25.0.0"
13+
wgpu = "27.0.1"
1414
winit = "0.30"
1515
futures = "0.3.31"
1616
imgui = "0.12"
1717
imgui-winit-support = "0.13"
18-
imgui-wgpu = "0.25"
18+
# imgui-wgpu = "0.25"
19+
imgui-wgpu = { git = "https://github.com/Yatekii/imgui-wgpu-rs", rev = "3db5c5ad6a63f46428d836e34b1f4557ded0b6b4" }

0 commit comments

Comments
 (0)