Skip to content

Commit

Permalink
[ADAPT_IMGUI_BUNDLE]: added ImGuiContextHookType_Begin/EndWindow
Browse files Browse the repository at this point in the history
cf thedmd/imgui-node-editor#242 (comment)

This helps fixing issues in popup positionning inside the node editor
  • Loading branch information
pthom committed Oct 10, 2024
1 parent 2d34b12 commit e3db84b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7102,6 +7102,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()
Expand Down Expand Up @@ -8083,6 +8089,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)
Expand Down
4 changes: 3 additions & 1 deletion imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2199,7 +2199,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
{
Expand Down

0 comments on commit e3db84b

Please sign in to comment.