From 2303b67c40a7ab2a45fc680403d37b1178ed94d3 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 21 Aug 2016 16:05:19 +0200 Subject: [PATCH] Close button submitted after collapse button. Should have no effect. Consistent with expectation & will be used as fallback for nav (#323) --- imgui.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index f6a39491..4bb89688 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5088,15 +5088,6 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us window->DC.ItemFlags &= ~ImGuiItemFlags_AllowNavDefaultFocus; window->DC.NavLayerCurrent++; - // Close button - if (p_open != NULL) - { - const float PAD = 2.0f; - const float rad = (window->TitleBarHeight() - PAD*2.0f) * 0.5f; - if (CloseButton(window->GetID("#CLOSE"), window->Rect().GetTR() + ImVec2(-PAD - rad, PAD + rad), rad)) - *p_open = false; - } - // Collapse button const ImVec2 text_size = CalcTextSize(name, NULL, true); if (!(flags & ImGuiWindowFlags_NoCollapse)) @@ -5110,6 +5101,15 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us RenderCollapseTriangle(window->Pos + style.FramePadding, !window->Collapsed, 1.0f, true); } + // Close button + if (p_open != NULL) + { + const float PAD = 2.0f; + const float rad = (window->TitleBarHeight() - PAD*2.0f) * 0.5f; + if (CloseButton(window->GetID("#CLOSE"), window->Rect().GetTR() + ImVec2(-PAD - rad, PAD + rad), rad)) + *p_open = false; + } + window->DC.NavLayerCurrent--; window->DC.ItemFlags = backup_item_options;