Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Easy to use, hand-crafted API with default arguments, named parameters and Zig s
* [Plot API](#plot-api) for advanced data visualizations
* [Gizmo API](#gizmo-api) for gizmo
* [Node editor API](#node-editor-api) for node based stuff
* [Knobs API](https://github.com/altschuler/imgui-knobs) for knobs

## Versions

Expand All @@ -21,6 +22,7 @@ Easy to use, hand-crafted API with default arguments, named parameters and Zig s
* [ImPlot](https://github.com/epezent/implot) `O.17`
* [ImGuizmo](https://github.com/CedricGuillemet/ImGuizmo) `1.89 WIP`
* [ImGuiNodeEditor](https://github.com/thedmd/imgui-node-editor/tree/v0.9.3) `O.9.3`
* [imgui-knobs](https://github.com/altschuler/imgui-knobs/commit/8a43bf7b31c4166ec50f3a52c382c2cc66a91516) `main - commit 8a43bf7b31c4166ec50f3a52c382c2cc66a91516`

## Getting started

Expand Down Expand Up @@ -240,3 +242,47 @@ defer zgui.node_editor.setCurrentEditor(null);
}
}
```

### Imgui-Knobs Api.
zig wrapper for [imgui-knobs](https://github.com/altschuler/imgui-knobs)

``` zig
// Minimal knob function call
_ = zgui.knobs.knob("Minimal", .{
.v = &v_knob,
.v_min = 0,
.v_max = 1.0,
});
zgui.sameLine(.{});

// Styled f32 knob
_ = zgui.knobs.knob("f32 Knob", .{
.v = &v_knob,
.v_min = 0,
.v_max = 1.0,
.size = 200,
.speed = 0.0005,
.angle_min = std.math.pi,
.angle_max = 2 * std.math.pi,
.variant = .{ .stepped = true },
.steps = 5,
});
zgui.sameLine(.{});

// Styled i32 knob (applied color)
zgui.pushStyleColor4f(.{ .idx = zgui.StyleCol.button_active, .c = .{ 0.6, 0.2, 0.2, 1 } });
zgui.pushStyleColor4f(.{ .idx = zgui.StyleCol.button_hovered, .c = .{ 0.6, 0.4, 0.4, 1 } });
zgui.pushStyleColor4f(.{ .idx = zgui.StyleCol.button, .c = .{ 0.4, 0, 0, 1 } });
_ = zgui.knobs.knobInt("i32 Knob", .{
.v = &v_knob_int,
.v_min = -10,
.v_max = 10,
.size = 250,
.variant = zgui.knobs.KnobVariant{ .wiper_dot = true },
.flags = zgui.knobs.KnobFlags{
.drag_horizontal = true,
.no_input = true,
},
});
zgui.popStyleColor(.{ .count = 3 });
```
21 changes: 21 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ pub fn build(b: *std.Build) void {
"with_freetype",
"Build with system FreeType engine support",
) orelse false,
.with_knobs = b.option(
bool,
"with_knobs",
"Build with bundled Imgui-Knobs",
) orelse false,
.use_wchar32 = b.option(
bool,
"use_wchar32",
Expand Down Expand Up @@ -193,6 +198,22 @@ pub fn build(b: *std.Build) void {
});
}

if (options.with_knobs) {
imgui.addIncludePath(b.path("libs/imgui_knobs/"));

imgui.addCSourceFile(.{
.file = b.path("src/zknobs.cpp"),
.flags = cflags,
});

imgui.addCSourceFiles(.{
.files = &.{
"libs/imgui_knobs/imgui-knobs.cpp",
},
.flags = cflags,
});
}

if (options.with_node_editor) {
imgui.addCSourceFile(.{
.file = b.path("src/znode_editor.cpp"),
Expand Down
21 changes: 21 additions & 0 deletions libs/imgui_knobs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Simon Altschuler

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading