Checkbox: minor tidying up to simplify work on multi-select branch.
This commit is contained in:
+8
-5
@@ -1132,7 +1132,8 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|||||||
const ImVec2 pos = window->DC.CursorPos;
|
const ImVec2 pos = window->DC.CursorPos;
|
||||||
const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
|
const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
|
||||||
ItemSize(total_bb, style.FramePadding.y);
|
ItemSize(total_bb, style.FramePadding.y);
|
||||||
if (!ItemAdd(total_bb, id))
|
const bool is_visible = ItemAdd(total_bb, id);
|
||||||
|
if (!is_visible)
|
||||||
{
|
{
|
||||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
||||||
return false;
|
return false;
|
||||||
@@ -1147,10 +1148,12 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz));
|
const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz));
|
||||||
|
const bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0;
|
||||||
|
if (is_visible)
|
||||||
|
{
|
||||||
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);
|
||||||
bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0;
|
|
||||||
if (mixed_value)
|
if (mixed_value)
|
||||||
{
|
{
|
||||||
// Undocumented tristate/mixed/indeterminate checkbox (#2644)
|
// Undocumented tristate/mixed/indeterminate checkbox (#2644)
|
||||||
@@ -1163,11 +1166,11 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|||||||
const float pad = ImMax(1.0f, IM_TRUNC(square_sz / 6.0f));
|
const float pad = ImMax(1.0f, IM_TRUNC(square_sz / 6.0f));
|
||||||
RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f);
|
RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y);
|
const ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y);
|
||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]");
|
LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]");
|
||||||
if (label_size.x > 0.0f)
|
if (is_visible && label_size.x > 0.0f)
|
||||||
RenderText(label_pos, label);
|
RenderText(label_pos, label);
|
||||||
|
|
||||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
||||||
|
|||||||
Reference in New Issue
Block a user