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.
| 10498 | // If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup. |
| 10499 | // 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. |
| 10500 | bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags) |
| 10501 | { |
| 10502 | ImGuiContext& g = *GImGui; |
| 10503 | ImGuiWindow* window = g.CurrentWindow; |
| 10504 | const ImGuiID id = window->GetID(name); |
| 10505 | if (!IsPopupOpen(id, ImGuiPopupFlags_None)) |
| 10506 | { |
| 10507 | g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values |
| 10508 | return false; |
| 10509 | } |
| 10510 | |
| 10511 | // Center modal windows by default for increased visibility |
| 10512 | // (this won't really last as settings will kick in, and is mostly for backward compatibility. user may do the same themselves) |
| 10513 | // FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window. |
| 10514 | if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0) |
| 10515 | { |
| 10516 | const ImGuiViewport* viewport = GetMainViewport(); |
| 10517 | SetNextWindowPos(viewport->GetCenter(), ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f)); |
| 10518 | } |
| 10519 | |
| 10520 | flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse; |
| 10521 | const bool is_open = Begin(name, p_open, flags); |
| 10522 | if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display) |
| 10523 | { |
| 10524 | EndPopup(); |
| 10525 | if (is_open) |
| 10526 | ClosePopupToLevel(g.BeginPopupStack.Size, true); |
| 10527 | return false; |
| 10528 | } |
| 10529 | return is_open; |
| 10530 | } |
| 10531 | |
| 10532 | void ImGui::EndPopup() |
| 10533 | { |
nothing calls this directly
no test coverage detected