summaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/imgui_toggle.cpp31
-rw-r--r--src/widgets/imgui_toggle.h5
2 files changed, 36 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
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