mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
BeginPopupModal() can have an optional close-window button (#249)
This commit is contained in:
parent
bce495c581
commit
8c790a3234
11
imgui.cpp
11
imgui.cpp
@ -3234,7 +3234,7 @@ bool ImGui::BeginPopup(const char* str_id)
|
|||||||
return BeginPopupEx(str_id, ImGuiWindowFlags_ShowBorders);
|
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;
|
ImGuiState& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
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;
|
ImGuiWindowFlags flags = extra_flags|ImGuiWindowFlags_Popup|ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoSavedSettings;
|
||||||
bool opened = ImGui::Begin(name, NULL, ImVec2(0.0f, 0.0f), -1.0f, flags);
|
bool opened = ImGui::Begin(name, p_opened, 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)
|
if (!opened || (p_opened && !*p_opened)) // Opened can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||||
|
{
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
if (opened)
|
||||||
|
ClosePopup(id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return opened;
|
return opened;
|
||||||
}
|
}
|
||||||
|
2
imgui.h
2
imgui.h
@ -171,7 +171,7 @@ namespace ImGui
|
|||||||
// Popup
|
// Popup
|
||||||
IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). close childs popups if any. will close popup when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
|
IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). close childs popups if any. will close popup when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
|
||||||
IMGUI_API bool BeginPopup(const char* str_id); // return true if popup if opened and start outputting to it. only call EndPopup() if BeginPopup() returned true!
|
IMGUI_API bool BeginPopup(const char* str_id); // return true if popup if opened and start outputting to it. only call EndPopup() if BeginPopup() returned true!
|
||||||
IMGUI_API bool BeginPopupModal(const char* name, ImGuiWindowFlags extra_flags = 0);
|
IMGUI_API bool BeginPopupModal(const char* name, bool* p_opened = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (can't close them by clicking outside)
|
||||||
IMGUI_API bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); // helper to open and begin popup when clicked on last item
|
IMGUI_API bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); // helper to open and begin popup when clicked on last item
|
||||||
IMGUI_API bool BeginPopupContextWindow(bool also_over_items = true, const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on current window
|
IMGUI_API bool BeginPopupContextWindow(bool also_over_items = true, const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on current window
|
||||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (no window)
|
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (no window)
|
||||||
|
Loading…
Reference in New Issue
Block a user