ImGui Toggle: toggle switches, an alternative to checkboxes, with several styles and an optional animation.
The C++ API of ImGui Toggle as it is bound to Python: the entries of the module imgui_bundle.imgui_toggle, in the same order, with their C++ signatures and the headers’ comments. From the stubs: the functions excluded from the bindings, the typedefs and the macros are absent.
imgui_toggle.h¶
Widgets: Toggle Switches¶
Toggles behave similarly to ImGui::Checkbox()
Sometimes called a toggle switch, see also: Toggle switch (widget)
They represent two mutually exclusive states, with an optional animation on the UI when toggled.
Optional parameters:flags: Values from the ImGuiToggleFlags_ enumeration to set toggle modes.
animation_duration: Animation duration. Amount of time in seconds the toggle should animate. (0,...] default: 1.0 (Overloads with this parameter imply ImGuiToggleFlags_Animated)
frame_rounding: A scalar that controls how rounded the toggle frame is. 0 is square, 1 is round. (0, 1) default 1.0
knob_rounding: A scalar that controls how rounded the toggle knob is. 0 is square, 1 is round. (0, 1) default 1.0
size: A width and height to draw the toggle at. Defaults to
ImGui::GetFrameHeight()and that height * Phi for the width.
Config structure:The overload taking a reference to an ImGuiToggleConfig structure allows for more complete control over the widget.
ImGui::Toggle¶
IMGUI_API bool Toggle(const char* label, bool* v, const ImVec2& size = ImVec2());IMGUI_API bool Toggle(const char* label, bool* v, ImGuiToggleFlags flags, const ImVec2& size = ImVec2());IMGUI_API bool Toggle(const char* label, bool* v, ImGuiToggleFlags flags, float animation_duration, const ImVec2& size = ImVec2());IMGUI_API bool Toggle(const char* label, bool* v, ImGuiToggleFlags flags, float frame_rounding, float knob_rounding, const ImVec2& size = ImVec2());IMGUI_API bool Toggle(const char* label, bool* v, ImGuiToggleFlags flags, float animation_duration, float frame_rounding, float knob_rounding, const ImVec2& size = ImVec2());IMGUI_API bool Toggle(const char* label, bool* v, const ImGuiToggleConfig& config);ToggleFlags_ (enum)¶
ImGuiToggleFlags: A set of flags that adjust behavior and display for ImGui::Toggle().
| Member | Value | |
|---|---|---|
ImGuiToggleFlags_None = 0 | 0 | |
ImGuiToggleFlags_Animated = 1 << 0 | 1 << 0 | The toggle’s knob should be animated. |
ImGuiToggleFlags_BorderedFrame = 1 << 3 | 1 << 3 | The toggle should have a border drawn on the frame. |
ImGuiToggleFlags_BorderedKnob = 1 << 4 | 1 << 4 | The toggle should have a border drawn on the knob. |
ImGuiToggleFlags_ShadowedFrame = 1 << 5 | 1 << 5 | The toggle should have a shadow drawn under the frame. |
ImGuiToggleFlags_ShadowedKnob = 1 << 6 | 1 << 6 | The toggle should have a shadow drawn under the knob. |
ImGuiToggleFlags_A11y = 1 << 8 | 1 << 8 | The toggle should draw on and off glyphs to help indicate its state. |
ImGuiToggleFlags_Bordered = ImGuiToggleFlags_BorderedFrame | ImGuiToggleFlags_BorderedKnob | ToggleFlags_BorderedFrame | ToggleFlags_BorderedKnob | Shorthand for bordered frame and knob. |
ImGuiToggleFlags_Shadowed = ImGuiToggleFlags_ShadowedFrame | ImGuiToggleFlags_ShadowedKnob | ToggleFlags_ShadowedFrame | ToggleFlags_ShadowedKnob | Shorthand for shadowed frame and knob. |
ImGuiToggleFlags_Default = ImGuiToggleFlags_None | ToggleFlags_None | The default flags used when no ImGuiToggleFlags_ are specified. |
ToggleA11yStyle_ (enum)¶
ImGuiToggleA11yStyle: Styles to draw A11y labels.
| Member | Value | |
|---|---|---|
ImGuiToggleA11yStyle_Label | 0 | A11y glyphs draw as text labels. |
ImGuiToggleA11yStyle_Glyph | 1 | A11y glyphs draw as power-icon style “I/O” glyphs. |
ImGuiToggleA11yStyle_Dot | 2 | A11y glyphs draw as a small dot that can be colored separately from the frame. |
ImGuiToggleA11yStyle_Default = ImGuiToggleA11yStyle_Label | ToggleA11yStyle_Label | Default: text labels. |
ToggleStateConfig (struct)¶
| Member | |
|---|---|
float FrameBorderThickness = ImGuiToggleConstants::BorderThicknessDefault; | |
float FrameShadowThickness = ImGuiToggleConstants::ShadowThicknessDefault; | |
float KnobBorderThickness = ImGuiToggleConstants::BorderThicknessDefault; | |
float KnobShadowThickness = ImGuiToggleConstants::ShadowThicknessDefault; | |
const char* Label = nullptr; | (const) |
ImOffsetRect KnobInset = ImGuiToggleConstants::KnobInsetDefault; | |
ImVec2 KnobOffset = ImVec2(0.0f, 0.0f); | |
const ImGuiTogglePalette* Palette = nullptr; | (const) |
ToggleConfig (struct)¶
ImGuiToggleConfig: A collection of data used to customize the appearance and behavior of a toggle widget.
| Member | |
|---|---|
ImGuiToggleFlags Flags = ImGuiToggleFlags_Default; | |
ImGuiToggleFlags A11yStyle = ImGuiToggleA11yStyle_Default; | |
float AnimationDuration = ImGuiToggleConstants::AnimationDurationDefault; | |
float FrameRounding = ImGuiToggleConstants::FrameRoundingDefault; | |
float KnobRounding = ImGuiToggleConstants::KnobRoundingDefault; | |
float WidthRatio = ImGuiToggleConstants::WidthRatioDefault; | |
ImVec2 Size = ImVec2(0.0f, 0.0f); | |
ImGuiToggleStateConfig On; | |
ImGuiToggleStateConfig Off; |
imgui_toggle_presets.h¶
ImGui::DefaultStyle¶
ImGuiToggleConfig DefaultStyle();The default, unmodified style. (private API)
ImGui::RectangleStyle¶
ImGuiToggleConfig RectangleStyle();A style similar to default, but with rectangular knob and frame. (private API)
ImGui::GlowingStyle¶
ImGuiToggleConfig GlowingStyle();A style that uses a shadow to appear to glow while it’s on. (private API)
ImGui::iOSStyle¶
ImGuiToggleConfig iOSStyle(float size_scale = 1.0f, bool light_mode = false);A style that emulates what a toggle on iOS looks like. (private API)
ImGui::MaterialStyle¶
ImGuiToggleConfig MaterialStyle(float size_scale = 1.0f);A style that emulates what a Material Design toggle looks like. (private API)
ImGui::MinecraftStyle¶
ImGuiToggleConfig MinecraftStyle(float size_scale = 1.0f);A style that emulates what a toggle close to one from Minecraft. (private API)
imgui_toggle_palette.h¶
TogglePalette (struct)¶
ImGuiTogglePalette: A collection of colors used to customize the rendering of a toggle widget.
Leaving any ImVec4 as default (zero) will allow the theme color to be used for that member.
| Member | |
|---|---|
ImVec4 Knob; | |
ImVec4 KnobHover; | |
ImVec4 Frame; | |
ImVec4 FrameHover; | |
ImVec4 FrameBorder; | |
ImVec4 FrameShadow; | |
ImVec4 KnobBorder; | |
ImVec4 KnobShadow; | |
ImVec4 A11yGlyph; |
ImGui::UnionPalette¶
void UnionPalette(ImGuiTogglePalette* target, const ImGuiTogglePalette* candidate, const ImVec4 colors[], bool v);(private API)
ImGui::BlendPalettes¶
void BlendPalettes(ImGuiTogglePalette* result, const ImGuiTogglePalette& a, const ImGuiTogglePalette& b, float blend_amount);(private API)
}imgui_offset_rect.h¶
ImOffsetRect (struct)¶
Helper: ImOffsetRect A set of offsets to apply to an ImRect.
ImOffsetRect::ImOffsetRect¶
constexpr ImOffsetRect() : Top(0.0f), Left(0.0f), Bottom(0.0f), Right(0.0f);constexpr ImOffsetRect(const ImVec2& topLeft, const ImVec2& bottomRight) : ImOffsetRect(topLeft.y, topLeft.x, bottomRight.y, bottomRight.x);constexpr ImOffsetRect(const ImVec4& v) : ImOffsetRect(v.x, v.y, v.z, v.w);constexpr ImOffsetRect(float top, float left, float bottom, float right) : Top(top), Left(left), Bottom(bottom), Right(right);constexpr ImOffsetRect(float all) : Top(all), Left(all), Bottom(all), Right(all);ImOffsetRect::GetSize¶
ImVec2 GetSize() const;(private API)
ImOffsetRect::GetWidth¶
float GetWidth() const;(private API)
ImOffsetRect::GetHeight¶
float GetHeight() const;(private API)
ImOffsetRect::GetAverage¶
float GetAverage() const;(private API)
ImOffsetRect::MirrorHorizontally¶
ImOffsetRect MirrorHorizontally() const;(private API)
ImOffsetRect::MirrorVertically¶
ImOffsetRect MirrorVertically() const;(private API)
ImOffsetRect::Mirror¶
ImOffsetRect Mirror() const;(private API)