1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-14 11:07:48 +01:00

Internals: Renamed GetFrontMostModalRootWindow() to GetFrontMostPopupModal() and exposed in imgui_internal.h (#1738)

This commit is contained in:
omar 2018-04-10 15:04:36 +02:00
parent 9117632bf0
commit 52cac135c9
2 changed files with 7 additions and 7 deletions

View File

@ -741,7 +741,6 @@ static void MarkIniSettingsDirty(ImGuiWindow* window);
static ImRect GetViewportRect(); static ImRect GetViewportRect();
static void ClosePopupToLevel(int remaining); static void ClosePopupToLevel(int remaining);
static ImGuiWindow* GetFrontMostModalRootWindow();
static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data); static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data);
static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end); static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end);
@ -3354,7 +3353,7 @@ void ImGui::NewFrameUpdateHoveredWindowAndCaptureFlags()
g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL; g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
// Modal windows prevents cursor from hovering behind them. // Modal windows prevents cursor from hovering behind them.
ImGuiWindow* modal_window = GetFrontMostModalRootWindow(); ImGuiWindow* modal_window = GetFrontMostPopupModal();
if (modal_window) if (modal_window)
if (g.HoveredRootWindow && !IsWindowChildOf(g.HoveredRootWindow, modal_window)) if (g.HoveredRootWindow && !IsWindowChildOf(g.HoveredRootWindow, modal_window))
g.HoveredRootWindow = g.HoveredWindow = NULL; g.HoveredRootWindow = g.HoveredWindow = NULL;
@ -3505,7 +3504,7 @@ void ImGui::NewFrame()
NewFrameUpdateMovingWindow(); NewFrameUpdateMovingWindow();
NewFrameUpdateHoveredWindowAndCaptureFlags(); NewFrameUpdateHoveredWindowAndCaptureFlags();
if (GetFrontMostModalRootWindow() != NULL) if (GetFrontMostPopupModal() != NULL)
g.ModalWindowDarkeningRatio = ImMin(g.ModalWindowDarkeningRatio + g.IO.DeltaTime * 6.0f, 1.0f); g.ModalWindowDarkeningRatio = ImMin(g.ModalWindowDarkeningRatio + g.IO.DeltaTime * 6.0f, 1.0f);
else else
g.ModalWindowDarkeningRatio = 0.0f; g.ModalWindowDarkeningRatio = 0.0f;
@ -4029,7 +4028,7 @@ void ImGui::EndFrame()
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove)) if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove))
g.MovingWindow = g.HoveredWindow; g.MovingWindow = g.HoveredWindow;
} }
else if (g.NavWindow != NULL && GetFrontMostModalRootWindow() == NULL) else if (g.NavWindow != NULL && GetFrontMostPopupModal() == NULL)
{ {
// Clicking on void disable focus // Clicking on void disable focus
FocusWindow(NULL); FocusWindow(NULL);
@ -4042,7 +4041,7 @@ void ImGui::EndFrame()
{ {
// Find the top-most window between HoveredWindow and the front most Modal Window. // Find the top-most window between HoveredWindow and the front most Modal Window.
// This is where we can trim the popup stack. // This is where we can trim the popup stack.
ImGuiWindow* modal = GetFrontMostModalRootWindow(); ImGuiWindow* modal = GetFrontMostPopupModal();
bool hovered_window_above_modal = false; bool hovered_window_above_modal = false;
if (modal == NULL) if (modal == NULL)
hovered_window_above_modal = true; hovered_window_above_modal = true;
@ -4916,7 +4915,7 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window)
ClosePopupToLevel(n); ClosePopupToLevel(n);
} }
static ImGuiWindow* GetFrontMostModalRootWindow() ImGuiWindow* ImGui::GetFrontMostPopupModal()
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
for (int n = g.OpenPopupStack.Size-1; n >= 0; n--) for (int n = g.OpenPopupStack.Size-1; n >= 0; n--)
@ -5962,7 +5961,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
PushClipRect(viewport_rect.Min, viewport_rect.Max, true); PushClipRect(viewport_rect.Min, viewport_rect.Max, true);
// Draw modal window background (darkens what is behind them) // Draw modal window background (darkens what is behind them)
if ((flags & ImGuiWindowFlags_Modal) != 0 && window == GetFrontMostModalRootWindow()) if ((flags & ImGuiWindowFlags_Modal) != 0 && window == GetFrontMostPopupModal())
window->DrawList->AddRectFilled(viewport_rect.Min, viewport_rect.Max, GetColorU32(ImGuiCol_ModalWindowDarkening, g.ModalWindowDarkeningRatio)); window->DrawList->AddRectFilled(viewport_rect.Min, viewport_rect.Max, GetColorU32(ImGuiCol_ModalWindowDarkening, g.ModalWindowDarkeningRatio));
// Draw navigation selection/windowing rectangle background // Draw navigation selection/windowing rectangle background

View File

@ -1052,6 +1052,7 @@ namespace ImGui
IMGUI_API bool IsPopupOpen(ImGuiID id); IMGUI_API bool IsPopupOpen(ImGuiID id);
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, bool override_previous_tooltip = true); IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
IMGUI_API ImGuiWindow* GetFrontMostPopupModal();
IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit); IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
IMGUI_API void NavMoveRequestCancel(); IMGUI_API void NavMoveRequestCancel();