From 0db725c2f18047be0d38ed88f9888f2b8f125aab Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Thu, 10 Oct 2024 11:22:22 +0200 Subject: [PATCH] [Bundle]: added ImGuiContextHookType_Begin/EndWindow cf https://github.com/thedmd/imgui-node-editor/issues/242#issuecomment-1681806764 This helps fixing issues in popup positionning inside the node editor --- imgui.cpp | 11 +++++++++++ imgui_internal.h | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index a141961cd722..efa24f66b587 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7372,6 +7372,12 @@ ImGuiWindow* ImGui::FindBlockingModal(ImGuiWindow* window) bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; + + { + // [ADAPT_IMGUI_BUNDLE]: added ImGuiContextHookType_BeginWindow, ImGuiContextHookType_EndWindow, cf https://github.com/thedmd/imgui-node-editor/issues/242#issuecomment-1681806764 + CallContextHooks(&g, ImGuiContextHookType_BeginWindow); + } + const ImGuiStyle& style = g.Style; IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required IM_ASSERT(g.WithinFrameScope); // Forgot to call ImGui::NewFrame() @@ -8361,6 +8367,11 @@ void ImGui::End() SetCurrentWindow(g.CurrentWindowStack.Size == 0 ? NULL : g.CurrentWindowStack.back().Window); if (g.CurrentWindow) SetCurrentViewport(g.CurrentWindow, g.CurrentWindow->Viewport); + + { + // [ADAPT_IMGUI_BUNDLE]: added ImGuiContextHookType_BeginWindow, ImGuiContextHookType_EndWindow, cf https://github.com/thedmd/imgui-node-editor/issues/242#issuecomment-1681806764 + CallContextHooks(&g, ImGuiContextHookType_EndWindow); + } } void ImGui::BringWindowToFocusFront(ImGuiWindow* window) diff --git a/imgui_internal.h b/imgui_internal.h index 5681e8688537..d6e2f0ae3a7a 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2230,7 +2230,9 @@ struct ImGuiIDStackTool //----------------------------------------------------------------------------- typedef void (*ImGuiContextHookCallback)(ImGuiContext* ctx, ImGuiContextHook* hook); -enum ImGuiContextHookType { ImGuiContextHookType_NewFramePre, ImGuiContextHookType_NewFramePost, ImGuiContextHookType_EndFramePre, ImGuiContextHookType_EndFramePost, ImGuiContextHookType_RenderPre, ImGuiContextHookType_RenderPost, ImGuiContextHookType_Shutdown, ImGuiContextHookType_PendingRemoval_ }; + +// [ADAPT_IMGUI_BUNDLE]: added ImGuiContextHookType_BeginWindow, ImGuiContextHookType_EndWindow, cf https://github.com/thedmd/imgui-node-editor/issues/242#issuecomment-1681806764 +enum ImGuiContextHookType { ImGuiContextHookType_NewFramePre, ImGuiContextHookType_NewFramePost, ImGuiContextHookType_EndFramePre, ImGuiContextHookType_EndFramePost, ImGuiContextHookType_RenderPre, ImGuiContextHookType_RenderPost, ImGuiContextHookType_Shutdown, ImGuiContextHookType_PendingRemoval_, ImGuiContextHookType_BeginWindow, ImGuiContextHookType_EndWindow }; struct ImGuiContextHook {