If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup. Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here.
| 10751 | // If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup. |
| 10752 | // Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here. |
| 10753 | bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags) |
| 10754 | { |
| 10755 | ImGuiContext& g = *GImGui; |
| 10756 | ImGuiWindow* window = g.CurrentWindow; |
| 10757 | const ImGuiID id = window->GetID(name); |
| 10758 | if (!IsPopupOpen(id, ImGuiPopupFlags_None)) |
| 10759 | { |
| 10760 | g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values |
| 10761 | return false; |
| 10762 | } |
| 10763 | |
| 10764 | // Center modal windows by default for increased visibility |
| 10765 | // (this won't really last as settings will kick in, and is mostly for backward compatibility. user may do the same themselves) |
| 10766 | // FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window. |
| 10767 | if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0) |
| 10768 | { |
| 10769 | const ImGuiViewport* viewport = window->WasActive ? window->Viewport : GetMainViewport(); // FIXME-VIEWPORT: What may be our reference viewport? |
| 10770 | SetNextWindowPos(viewport->GetCenter(), ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f)); |
| 10771 | } |
| 10772 | |
| 10773 | flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDocking; |
| 10774 | const bool is_open = Begin(name, p_open, flags); |
| 10775 | if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display) |
| 10776 | { |
| 10777 | EndPopup(); |
| 10778 | if (is_open) |
| 10779 | ClosePopupToLevel(g.BeginPopupStack.Size, true); |
| 10780 | return false; |
| 10781 | } |
| 10782 | return is_open; |
| 10783 | } |
| 10784 | |
| 10785 | void ImGui::EndPopup() |
| 10786 | { |
nothing calls this directly
no test coverage detected