From e01fb5462d4fc8b30cf7e23229ee5be4b8d7b3e9 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 18 Dec 2019 18:26:28 +0100 Subject: [PATCH] Internals: Separator: Simplify duplicated code. --- imgui_widgets.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 684dbe55..135715ff 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1259,21 +1259,14 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags) // We don't provide our width to the layout so that it doesn't get feed back into AutoFit const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness_draw)); ItemSize(ImVec2(0.0f, thickness_layout)); - if (!ItemAdd(bb, 0)) + const bool item_visible = ItemAdd(bb, 0); + if (item_visible) { - if (columns) - { - PopColumnsBackground(); - columns->LineMinY = window->DC.CursorPos.y; - } - return; + // Draw + window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x, bb.Min.y), GetColorU32(ImGuiCol_Separator)); + if (g.LogEnabled) + LogRenderedText(&bb.Min, "--------------------------------"); } - - // Draw - window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x, bb.Min.y), GetColorU32(ImGuiCol_Separator)); - if (g.LogEnabled) - LogRenderedText(&bb.Min, "--------------------------------"); - if (columns) { PopColumnsBackground();