mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-12 02:00:58 +01:00
CheckboxFlags: Display mixed-value/tristate marker when passed flags that have multiple bits set and stored value matches neither zero neither the full set.
This commit is contained in:
parent
4fd43a8b64
commit
12d9505534
@ -80,6 +80,8 @@ Other Changes:
|
|||||||
with signed and unsigned types. Added reverse Sliders to Demo. (#3432, #3449) [@rokups]
|
with signed and unsigned types. Added reverse Sliders to Demo. (#3432, #3449) [@rokups]
|
||||||
- Text: Bypass unnecessary formatting when using the TextColored()/TextWrapped()/TextDisabled() helpers
|
- Text: Bypass unnecessary formatting when using the TextColored()/TextWrapped()/TextDisabled() helpers
|
||||||
with a "%s" format string. (#3466)
|
with a "%s" format string. (#3466)
|
||||||
|
- CheckboxFlags: Display mixed-value/tristate marker when passed flags that have multiple bits set and
|
||||||
|
stored value matches neither zero neither the full set.
|
||||||
- BeginMenuBar: Fixed minor bug where CursorPosMax gets pushed to CursorPos prior to calling BeginMenuBar(),
|
- BeginMenuBar: Fixed minor bug where CursorPosMax gets pushed to CursorPos prior to calling BeginMenuBar(),
|
||||||
so e.g. calling the function at the end of a window would often add +ItemSpacing.y to scrolling range.
|
so e.g. calling the function at the end of a window would often add +ItemSpacing.y to scrolling range.
|
||||||
- TreeNode, CollapsingHeader: Made clicking on arrow toggle toggle the open state on the Mouse Down event
|
- TreeNode, CollapsingHeader: Made clicking on arrow toggle toggle the open state on the Mouse Down event
|
||||||
|
@ -1071,7 +1071,8 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|||||||
RenderNavHighlight(total_bb, id);
|
RenderNavHighlight(total_bb, id);
|
||||||
RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
|
RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||||
ImU32 check_col = GetColorU32(ImGuiCol_CheckMark);
|
ImU32 check_col = GetColorU32(ImGuiCol_CheckMark);
|
||||||
if (window->DC.ItemFlags & ImGuiItemFlags_MixedValue)
|
bool mixed_value = (window->DC.ItemFlags & ImGuiItemFlags_MixedValue) != 0;
|
||||||
|
if (mixed_value)
|
||||||
{
|
{
|
||||||
// Undocumented tristate/mixed/indeterminate checkbox (#2644)
|
// Undocumented tristate/mixed/indeterminate checkbox (#2644)
|
||||||
ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)));
|
ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)));
|
||||||
@ -1084,7 +1085,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
LogRenderedText(&total_bb.Min, *v ? "[x]" : "[ ]");
|
LogRenderedText(&total_bb.Min, mixed_value ? "[~]" : *v ? "[x]" : "[ ]");
|
||||||
if (label_size.x > 0.0f)
|
if (label_size.x > 0.0f)
|
||||||
RenderText(ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y), label);
|
RenderText(ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y), label);
|
||||||
|
|
||||||
@ -1095,7 +1096,21 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|||||||
bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value)
|
bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value)
|
||||||
{
|
{
|
||||||
bool v = ((*flags & flags_value) == flags_value);
|
bool v = ((*flags & flags_value) == flags_value);
|
||||||
bool pressed = Checkbox(label, &v);
|
bool pressed;
|
||||||
|
if (v == false && (*flags & flags_value) != 0)
|
||||||
|
{
|
||||||
|
// Mixed value (FIXME: find a way to expose neatly to Checkbox?)
|
||||||
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
const ImGuiItemFlags backup_item_flags = window->DC.ItemFlags;
|
||||||
|
window->DC.ItemFlags |= ImGuiItemFlags_MixedValue;
|
||||||
|
pressed = Checkbox(label, &v);
|
||||||
|
window->DC.ItemFlags = backup_item_flags;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Regular checkbox
|
||||||
|
pressed = Checkbox(label, &v);
|
||||||
|
}
|
||||||
if (pressed)
|
if (pressed)
|
||||||
{
|
{
|
||||||
if (v)
|
if (v)
|
||||||
|
Loading…
Reference in New Issue
Block a user