The imgui-knobs library provides knob widgets to dear imgui like these:
Enabling the module
To enable the knobs module, you can either hard-code the USE_KNOBS_MODULE
option in your CMakeLists.txt
file by finding the following line:
option(USE_KNOBS_MODULE "Use the knobs module" OFF)
and setting it to this:
option(USE_KNOBS_MODULE "Use the knobs module" ON)
Alternatively, you can also use CMake options through the CLI:
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DUSE_KNOBS_MODULE=ON
Finally, update your uvproj.yaml
so that the knobs
key under enabled-modules
is set to true like this:
name: "MyProject"
version: "1.0.0.0"
engine-version: "1.0.0.0"
enabled-modules:
knobs: true
Next, include the Modules.hpp
header in your components, like this:
#include <Modules/Modules.hpp>
Event safety
The entire module is flagged as event safe at All ready
Testing out the module
In one of your widgets, add the following code to your tick function:
static float value = 0;
if (ImGuiKnobs::Knob("Volume", &value, -6.0f, 6.0f, 0.1f, "%.1fdB", ImGuiKnobVariant_Tick)) {
// value was changed
}
Compile and run.
Learning the module
To learn more about the knobs module, navigate to the imgui-knobs GitHub repository.
Checking for the module
To check for the module at compile time, use the UIMGUI_KNOBS_MODULE_ENABLED
macro.
Runtime checking can be done using the knobs
member of the ModuleSettings
struct. More info can be found here.
- Home
- Beginner content
- Install guide
- Creating and using the UI components
- The Instance
- The Init Info struct
- Additional features
- Custom type definitions
- C API development
- Config files and Folders
- Interfaces
- Internal Event safety
- Modules system
- I18N
- Plotting
- Knobs
- Spinners
- Toggles
- Text Utils
- Undo/Redo
- CLI Parser
- Theming
- OS
- Opening URLs and using file pickers
- Exec integration
- Fonts
- Unix
- DBus utilities
- XDG integration
- Advanced content
- Loading dynamic libraries at runtime
- Understanding the library layout
- Compilation mode modifiers
- Adding plugin support to your application
- Production export and deployment
- Developer and contributor resources
- Misc