-
Notifications
You must be signed in to change notification settings - Fork 37
Ported Imgui-knobs #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I am about to test these functions, so I am going to commit those for a backup.
The PlotLines() and PlotHistogram() are now tested and they can produce the exact same result from the web imgui demo.
The code is done, and testing is in sight.
As suggested by the code review, I have replaced my direct array access with a null pointer check.
Now we finally have the knobs for zgui which is based on the altschuler's imgui-knobs. Although it seemsingly works fully, I will do more tests before doing a pull request, along with put some images for the README section to demonstrate how to use the elements.
A simple example is added for knobs such that to demostrate how to create knobs for your imgui programs.
Seems like my function name was a bit different where I used snake case while the other code use camcel case, so I have unified my code to align the coding style of others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ports the imgui-knobs library to zgui, enabling the creation of knob UI controls. The integration is optional and can be enabled with the with_knobs
build flag.
- Adds a Zig wrapper for the imgui-knobs C++ library with type-safe API
- Integrates the imgui-knobs source code and provides conditional compilation
- Provides both float and integer knob variants with extensive customization options
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/zknobs.cpp | C++ wrapper functions to bridge imgui-knobs with Zig |
src/knobs.zig | Zig API providing type-safe knob functions and configuration structs |
src/gui.zig | Exports the knobs module when available |
libs/imgui_knobs/imgui-knobs.h | Header file for the imgui-knobs library |
libs/imgui_knobs/imgui-knobs.cpp | Implementation of the imgui-knobs library |
libs/imgui_knobs/LICENSE | MIT license for the imgui-knobs library |
build.zig | Build configuration to conditionally include knobs support |
README.md | Documentation and usage examples for the knobs API |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please list the knobs lib version under the Versons section in the README.
After I have taken a look into the library, I just found it doesn't have a specific release version, so I am think of stating the last commit date of the library before I have ported it (which is 23 June 2025) or the commit id (8a43bf7) instead because giving it an arbitrary version will not reflect the actual version of the library and it might cause confusion. There is a chance that the library is small and the update is infrequent, so they don't really care to put them as a release. If you have concern about my approach, please let me know such that I will notify the author behind the knob library and hopefully they could do a proper release. |
The branch name + commit hash is sufficient. |
Due to the lack of official release, we have concluded to use branch name + commit hash, and I have also set the link used in the version redirecting to that particular commit history for reference.
Done! Besides added the version, clicking the link of the version to the knobs will redirect to that particular commit history as well. |
Thanks for waiting the setup of my new laptop before going back on working my proposal of porting the knob library.
As proposed in the issues, the library can be conditionally compiled by stating .with_knobs with true:
Once the knob part is included, simply call zgui.knobs.knob to create a knob:
For different knob style, resolution per step, arc shape, and color, we can apply with the additional parameter like shown:
The result based on the function call above (applied with zgui,sameLine() for the alignments):
Knobs.in.demo.mp4
Time for some code review, and let see if there are further requests to follow.