(Demo) Knob and Toggle Widgets (Dear ImGui)

GeeXLab demo (Python, Lua, OpenGL, Vulkan)



Downloads

 
Here is a small demo that shows how to use two new widgets added in the gh_imgui library (Lua and Python).

This demo requires GeeXLab 0.50+ and is available in the OpenGL 2.1 demopack in the geexlab-demopack-gl21/d29-imgui/imgui-knob-toggle/ folder.

GeeXLab demo - Dear ImGui - Knob and toggle widgets

 
Here is a code snippet in Lua that shows how to use the toggle widget:

GeeXLab demo - Dear ImGui - toggle widget

ImGuiToggleFlags_None                   = 0
ImGuiToggleFlags_Animated               = 1  
ImGuiToggleFlags_BorderedFrame          = 8  
ImGuiToggleFlags_BorderedKnob           = 16 
ImGuiToggleFlags_ShadowedFrame          = 32 
ImGuiToggleFlags_ShadowedKnob           = 64 
ImGuiToggleFlags_A11y                   = 256

size_x = 40
size_y = 20
toggle_flags = ImGuiToggleFlags_Animated
animation_duration = 0.1
frame_rounding = 1.0 
knob_rounding = 1.0 
label = "Horizontal drag"
DragHorizontal = gh_imgui.toggle(label, DragHorizontal, 
                                 size_x, size_y, toggle_flags, animation_duration, 
                                 frame_rounding, knob_rounding)

The original knob library in C/C++ for Dear ImGui is available HERE.

 
And a code snippet in Lua showing the use of the knob widget:
GeeXLab demo - Dear ImGui - Knob widget

ImGuiKnobVariant_Tick = 1
ImGuiKnobVariant_Dot = 2
ImGuiKnobVariant_Wiper = 4
ImGuiKnobVariant_WiperOnly = 8
ImGuiKnobVariant_WiperDot = 16
ImGuiKnobVariant_Stepped = 32
ImGuiKnobVariant_Space = 64 

ImGuiKnobFlags_NoTitle = 1
ImGuiKnobFlags_NoInput = 2
ImGuiKnobFlags_ValueTooltip = 4
ImGuiKnobFlags_DragHorizontal = 8
-- this is special flag fopr GeeXLab only.
ImGuiKnobFlags_ReadOnlyInput = 16 
-- this is special flag fopr GeeXLab only.
ImGuiKnobFlags_DisableMouse = 32 

knob_flags = 0 
v_min = 0.0
v_max = 100.0
speed = 0.5
format = "%.1f"
size = 100
steps = 0
ret = 0
value = 0

label = "Tick"
knob_type = ImGuiKnobVariant_Tick
value, ret = gh_imgui.knob(label, knob_value01, v_min, v_max, speed, format, knob_type, size, knob_flags, steps)
if (ret == 1) then
  -- value has changed
  knob_value01 = value
end

The original toggle library in C/C++ for Dear ImGui is available HERE.





Leave a Comment

Your email address will not be published. Required fields are marked *