WIP Menus: fixed case where zero-sized display (e.g. minimised window) clips popups/menus and asserted (#126)

docking
ocornut 10 years ago
parent 88d7b3de23
commit 7f3f3891c0

@ -3062,11 +3062,13 @@ static bool BeginPopupEx(const char* str_id, ImGuiWindowFlags extra_flags)
ImFormatString(name, 20, "##popup_%08x", id); // Not recycling, so we can close/open during the same frame ImFormatString(name, 20, "##popup_%08x", id); // Not recycling, so we can close/open during the same frame
float alpha = 1.0f; float alpha = 1.0f;
bool opened = ImGui::Begin(name, NULL, ImVec2(0.0f, 0.0f), alpha, flags); bool opened = ImGui::Begin(name, NULL, ImVec2(0.0f, 0.0f), alpha, flags);
IM_ASSERT(opened);
if (!(window->Flags & ImGuiWindowFlags_ShowBorders)) if (!(window->Flags & ImGuiWindowFlags_ShowBorders))
GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders; GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders;
if (!opened) // opened can be 'false' when the popup is completely clipped (e.g. zero size display)
ImGui::EndPopup();
return opened; return opened;
} }
@ -7518,8 +7520,7 @@ bool ImGui::BeginMenu(const char* label)
if (opened) if (opened)
{ {
ImGui::SetNextWindowPos(popup_pos, ImGuiSetCond_Always); ImGui::SetNextWindowPos(popup_pos, ImGuiSetCond_Always);
bool popup_opened = BeginPopupEx(label, ImGuiWindowFlags_Menu); opened = BeginPopupEx(label, ImGuiWindowFlags_Menu); // opened can be 'false' when the popup is completely clipped (e.g. zero size display)
IM_ASSERT(opened == popup_opened);
} }
return opened; return opened;

Loading…
Cancel
Save