mirror of
https://github.com/ocornut/imgui.git
synced 2026-02-04 04:00:07 +00:00
BeginPopupModal() can have an optional close-window button (#249)
This commit is contained in:
parent
bce495c581
commit
8c790a3234
2 changed files with 10 additions and 5 deletions
11
imgui.cpp
11
imgui.cpp
|
|
@ -3234,7 +3234,7 @@ bool ImGui::BeginPopup(const char* str_id)
|
|||
return BeginPopupEx(str_id, ImGuiWindowFlags_ShowBorders);
|
||||
}
|
||||
|
||||
bool ImGui::BeginPopupModal(const char* name, ImGuiWindowFlags extra_flags)
|
||||
bool ImGui::BeginPopupModal(const char* name, bool* p_opened, ImGuiWindowFlags extra_flags)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
|
@ -3246,9 +3246,14 @@ bool ImGui::BeginPopupModal(const char* name, ImGuiWindowFlags extra_flags)
|
|||
}
|
||||
|
||||
ImGuiWindowFlags flags = extra_flags|ImGuiWindowFlags_Popup|ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoSavedSettings;
|
||||
bool opened = ImGui::Begin(name, NULL, ImVec2(0.0f, 0.0f), -1.0f, flags);
|
||||
if (!opened) // Opened can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||
bool opened = ImGui::Begin(name, p_opened, ImVec2(0.0f, 0.0f), -1.0f, flags);
|
||||
if (!opened || (p_opened && !*p_opened)) // Opened can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||
{
|
||||
ImGui::EndPopup();
|
||||
if (opened)
|
||||
ClosePopup(id);
|
||||
return false;
|
||||
}
|
||||
|
||||
return opened;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue