From 5abb39cb1f2fde6a4988a46548cafdd8727892af Mon Sep 17 00:00:00 2001 From: Daniel Martinek Date: Fri, 18 Mar 2016 14:02:14 +0100 Subject: [PATCH 1/2] Added support for CheckboxFlags that can set multiple flags at the same time. --- imgui.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index c50a894e6..62c5288c5 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6907,12 +6907,14 @@ bool ImGui::Checkbox(const char* label, bool* v) bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value) { - bool v = (*flags & flags_value) ? true : false; + bool v = ((*flags & flags_value) == flags_value); bool pressed = ImGui::Checkbox(label, &v); - if (v) - *flags |= flags_value; - else - *flags &= ~flags_value; + if(pressed) { + if (v) + *flags |= flags_value; + else + *flags &= ~flags_value; + } return pressed; } From 37716184b34c84d589913b87e94bf774a905054f Mon Sep 17 00:00:00 2001 From: Daniel Martinek Date: Fri, 18 Mar 2016 16:49:19 +0100 Subject: [PATCH 2/2] Fixed coding style. --- imgui.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 62c5288c5..0baebacfb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6909,12 +6909,14 @@ bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int f { bool v = ((*flags & flags_value) == flags_value); bool pressed = ImGui::Checkbox(label, &v); - if(pressed) { + if (pressed) + { if (v) *flags |= flags_value; else *flags &= ~flags_value; } + return pressed; }