mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Added ClosePopupsExceptModals() helper, unused for now (aimed at user being able to close popups on app focus loss, not necessarily a suitable default)
This commit is contained in:
parent
bbb95a5e06
commit
24a77824f2
19
imgui.cpp
19
imgui.cpp
@ -4072,6 +4072,10 @@ void ImGui::NewFrame()
|
|||||||
g.DragDropWithinTarget = false;
|
g.DragDropWithinTarget = false;
|
||||||
g.DragDropHoldJustPressedId = 0;
|
g.DragDropHoldJustPressedId = 0;
|
||||||
|
|
||||||
|
// Close popups on focus lost (currently wip/opt-in)
|
||||||
|
//if (g.IO.AppFocusLost)
|
||||||
|
// ClosePopupsExceptModals();
|
||||||
|
|
||||||
// Clear buttons state when focus is lost
|
// Clear buttons state when focus is lost
|
||||||
// (this is useful so e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger the Alt menu toggle)
|
// (this is useful so e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger the Alt menu toggle)
|
||||||
if (g.IO.AppFocusLost)
|
if (g.IO.AppFocusLost)
|
||||||
@ -8361,6 +8365,21 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui::ClosePopupsExceptModals()
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
|
int popup_count_to_keep;
|
||||||
|
for (popup_count_to_keep = g.OpenPopupStack.Size; popup_count_to_keep > 0; popup_count_to_keep--)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = g.OpenPopupStack[popup_count_to_keep - 1].Window;
|
||||||
|
if (!window || window->Flags & ImGuiWindowFlags_Modal)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below
|
||||||
|
ClosePopupToLevel(popup_count_to_keep, true);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup)
|
void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
@ -2447,6 +2447,7 @@ namespace ImGui
|
|||||||
IMGUI_API void OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags = ImGuiPopupFlags_None);
|
IMGUI_API void OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags = ImGuiPopupFlags_None);
|
||||||
IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
|
IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
|
||||||
IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
|
IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
|
||||||
|
IMGUI_API void ClosePopupsExceptModals();
|
||||||
IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags);
|
IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags);
|
||||||
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
||||||
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
|
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
|
||||||
@ -2454,9 +2455,9 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
||||||
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
||||||
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
||||||
IMGUI_API bool BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
|
|
||||||
|
|
||||||
// Menus
|
// Menus
|
||||||
|
IMGUI_API bool BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
|
||||||
IMGUI_API bool BeginMenuEx(const char* label, const char* icon, bool enabled = true);
|
IMGUI_API bool BeginMenuEx(const char* label, const char* icon, bool enabled = true);
|
||||||
IMGUI_API bool MenuItemEx(const char* label, const char* icon, const char* shortcut = NULL, bool selected = false, bool enabled = true);
|
IMGUI_API bool MenuItemEx(const char* label, const char* icon, const char* shortcut = NULL, bool selected = false, bool enabled = true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user