Skip to content

Commit 3966e21

Browse files
committed
[Bundle] ImGuiContextHookType_Begin/EndWindow: handle m_BeginWindowDepth
1 parent e4704e6 commit 3966e21

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

imgui_canvas.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ bool ImGuiEx::Canvas::Begin(ImGuiID id, const ImVec2& size)
160160
//ImGui::SetNextWindowViewport( ImGui::GetCurrentWindow()->Viewport->ID );
161161

162162
auto canvas = reinterpret_cast< Canvas * >( hook->UserData );
163+
164+
canvas->m_BeginWindowDepth += 1;
165+
if (canvas->m_BeginWindowDepth > 1)
166+
return;
167+
163168
if ( canvas->m_SuspendCounter == 0 )
164169
{
165170
if ( ( context->NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos ) != 0 )
@@ -195,6 +200,11 @@ bool ImGuiEx::Canvas::Begin(ImGuiID id, const ImVec2& size)
195200
endWindowHook.Callback = []( ImGuiContext * ctx, ImGuiContextHook * hook )
196201
{
197202
auto canvas = reinterpret_cast< Canvas * >( hook->UserData );
203+
204+
canvas->m_BeginWindowDepth -= 1;
205+
if (canvas->m_BeginWindowDepth > 0)
206+
return;
207+
198208
canvas->Resume();
199209
ImGui::SetCursorScreenPos( canvas->m_BeginWindowCursorBackup );
200210
ImGui::GetCurrentWindow()->DC.IsSetPos = false;

imgui_canvas.h

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ struct Canvas
265265
// [ADAPT_IMGUI_BUNDLE]: added ImGuiContextHookType_BeginWindow, ImGuiContextHookType_EndWindow, cf https://github.com/thedmd/imgui-node-editor/issues/242#issuecomment-1681806764
266266
ImGuiID m_beginWindowHook, m_endWindowHook;
267267
ImVec2 m_BeginWindowCursorBackup;
268+
int m_BeginWindowDepth = 0;
268269
// [/ADAPT_IMGUI_BUNDLE]
269270
};
270271

0 commit comments

Comments
 (0)