diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-09 19:06:53 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-09 19:06:53 +0100 |
| commit | 03c271c82ccb434997fdde7bac140bb86b48accd (patch) | |
| tree | 748a39e554f4edd82c86f24266967b01cca8bff1 /src/widgets/imgui_toggle.cpp | |
| parent | e20735fe0a67c1fa3de16c10124bdc778acd88a8 (diff) | |
toggle case match
Diffstat (limited to 'src/widgets/imgui_toggle.cpp')
| -rw-r--r-- | src/widgets/imgui_toggle.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/widgets/imgui_toggle.cpp b/src/widgets/imgui_toggle.cpp new file mode 100644 index 0000000..f1c50da --- /dev/null +++ b/src/widgets/imgui_toggle.cpp @@ -0,0 +1,31 @@ +#include "imgui.h" +#include "imgui_toggle.h" + +namespace ImGui { + void ToggleButton(const char* label, bool* v) { + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + if (*v) { + ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor(204, 233, 252)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor(204, 233, 252)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor(204, 233, 252)); + ImGui::PushStyleColor(ImGuiCol_Border, (ImVec4)ImColor(0, 122, 204)); + ImGui::PushStyleColor(ImGuiCol_Text, (ImVec4)ImColor(64, 73, 79)); + + if (ImGui::Button(label)) { + *v = !(*v); + } + + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); + } + else { + if (ImGui::Button(label)) { + *v = !(*v); + } + } + ImGui::PopStyleVar(); + } +}
\ No newline at end of file |
