Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

imgui_toggle (C++)

ImGui Toggle: toggle switches, an alternative to checkboxes, with several styles and an optional animation.

The C++ API of ImGui Toggle: the signatures and the documentation of its headers. This page is generated by litgen, the engine behind the Python bindings of Dear ImGui Bundle. Functions without Python bindings are not listed.

imgui_toggle.h

Widgets: Toggle Switches

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);

ImGuiToggleFlags_ (enum)

enum ImGuiToggleFlags_

ImGuiToggleFlags: A set of flags that adjust behavior and display for ImGui::Toggle().

MemberValue
ImGuiToggleFlags_None = 00
ImGuiToggleFlags_Animated = 1 << 01 << 0The toggle’s knob should be animated.
ImGuiToggleFlags_BorderedFrame = 1 << 31 << 3The toggle should have a border drawn on the frame.
ImGuiToggleFlags_BorderedKnob = 1 << 41 << 4The toggle should have a border drawn on the knob.
ImGuiToggleFlags_ShadowedFrame = 1 << 51 << 5The toggle should have a shadow drawn under the frame.
ImGuiToggleFlags_ShadowedKnob = 1 << 61 << 6The toggle should have a shadow drawn under the knob.
ImGuiToggleFlags_A11y = 1 << 81 << 8The toggle should draw on and off glyphs to help indicate its state.
ImGuiToggleFlags_Bordered = ImGuiToggleFlags_BorderedFrame | ImGuiToggleFlags_BorderedKnobToggleFlags_BorderedFrame | ToggleFlags_BorderedKnobShorthand for bordered frame and knob.
ImGuiToggleFlags_Shadowed = ImGuiToggleFlags_ShadowedFrame | ImGuiToggleFlags_ShadowedKnobToggleFlags_ShadowedFrame | ToggleFlags_ShadowedKnobShorthand for shadowed frame and knob.
ImGuiToggleFlags_Default = ImGuiToggleFlags_NoneToggleFlags_NoneThe default flags used when no ImGuiToggleFlags_ are specified.

ImGuiToggleA11yStyle_ (enum)

enum ImGuiToggleA11yStyle_

ImGuiToggleA11yStyle: Styles to draw A11y labels.

MemberValue
ImGuiToggleA11yStyle_Label0A11y glyphs draw as text labels.
ImGuiToggleA11yStyle_Glyph1A11y glyphs draw as power-icon style “I/O” glyphs.
ImGuiToggleA11yStyle_Dot2A11y glyphs draw as a small dot that can be colored separately from the frame.
ImGuiToggleA11yStyle_Default = ImGuiToggleA11yStyle_LabelToggleA11yStyle_LabelDefault: text labels.

ImGuiToggleStateConfig (struct)

struct ImGuiToggleStateConfig
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)

ImGuiToggleConfig (struct)

struct ImGuiToggleConfig

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

ImGuiTogglePalette (struct)

struct ImGuiTogglePalette

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)

struct ImOffsetRect

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)