blob: 743261b720481c9abd0cabc71186745d8578d94a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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);
}
|