summaryrefslogtreecommitdiff
path: root/src/vendor-imgui-ext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vendor-imgui-ext.cpp')
-rw-r--r--src/vendor-imgui-ext.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/vendor-imgui-ext.cpp b/src/vendor-imgui-ext.cpp
new file mode 100644
index 0000000..743261b
--- /dev/null
+++ b/src/vendor-imgui-ext.cpp
@@ -0,0 +1,42 @@
+
+#include "vendor-imgui-ext.hpp"
+#include "imgui_internal.h"
+
+// copy-pasted
+// TODO submit PR so this isn't necessary
+template<typename T>
+bool ImGui::CheckboxFlagsT(const char* label, T* flags, T flags_value)
+{
+ bool all_on = (*flags & flags_value) == flags_value;
+ bool any_on = (*flags & flags_value) != 0;
+ bool pressed;
+ if (!all_on && any_on)
+ {
+ ImGuiContext& g = *GImGui;
+ g.NextItemData.ItemFlags |= ImGuiItemFlags_MixedValue;
+ pressed = Checkbox(label, &all_on);
+ }
+ else
+ {
+ pressed = Checkbox(label, &all_on);
+
+ }
+ if (pressed)
+ {
+ if (all_on)
+ *flags |= flags_value;
+ else
+ *flags &= ~flags_value;
+ }
+ return pressed;
+}
+
+bool ImGui::CheckboxFlags(const char* label, long int* flags, long int flags_value)
+{
+ return CheckboxFlagsT(label, flags, flags_value);
+}
+
+bool ImGui::CheckboxFlags(const char* label, unsigned long int* flags, unsigned long int flags_value)
+{
+ return CheckboxFlagsT(label, flags, flags_value);
+}