From 03c271c82ccb434997fdde7bac140bb86b48accd Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 9 Mar 2024 19:06:53 +0100 Subject: toggle case match --- src/widgets/imgui_toggle.cpp | 31 +++++++++++++++++++++++++++++++ src/widgets/imgui_toggle.h | 5 +++++ 2 files changed, 36 insertions(+) create mode 100644 src/widgets/imgui_toggle.cpp create mode 100644 src/widgets/imgui_toggle.h (limited to 'src/widgets') 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 diff --git a/src/widgets/imgui_toggle.h b/src/widgets/imgui_toggle.h new file mode 100644 index 0000000..3a514a9 --- /dev/null +++ b/src/widgets/imgui_toggle.h @@ -0,0 +1,5 @@ +#pragma once + +namespace ImGui { + void ToggleButton(const char* label, bool* v); +} \ No newline at end of file -- cgit v1.2.3-70-g09d2