Skip to content

Commit a8d3b04

Browse files
committed
Fix for doing multiple Begin()/End() during the same frame
1 parent a830037 commit a8d3b04

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Diff for: imgui.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -1833,15 +1833,13 @@ bool Begin(const char* name, bool* open, ImVec2 size, float fill_alpha, ImGuiWin
18331833
parent_window->DC.ChildWindows.push_back(window);
18341834
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
18351835
window->SizeFull = size;
1836-
if (!(flags & ImGuiWindowFlags_ComboBox))
1837-
ImGui::PushClipRect(parent_window->ClipRectStack.back());
1838-
else
1839-
ImGui::PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
18401836
}
1837+
1838+
// Outer clipping rectangle
1839+
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ComboBox))
1840+
ImGui::PushClipRect(g.CurrentWindowStack[g.CurrentWindowStack.size()-2]->ClipRectStack.back());
18411841
else
1842-
{
18431842
ImGui::PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
1844-
}
18451843

18461844
// ID stack
18471845
window->IDStack.resize(0);
@@ -2082,8 +2080,16 @@ bool Begin(const char* name, bool* open, ImVec2 size, float fill_alpha, ImGuiWin
20822080
ImGui::CloseWindowButton(open);
20832081
}
20842082
}
2083+
else
2084+
{
2085+
// Outer clipping rectangle
2086+
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ComboBox))
2087+
ImGui::PushClipRect(g.CurrentWindowStack[g.CurrentWindowStack.size()-2]->ClipRectStack.back());
2088+
else
2089+
ImGui::PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
2090+
}
20852091

2086-
// Clip rectangle
2092+
// Innter clipping rectangle
20872093
// We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame
20882094
const ImGuiAabb title_bar_aabb = window->TitleBarAabb();
20892095
ImVec4 clip_rect(title_bar_aabb.Min.x+0.5f, title_bar_aabb.Max.y+0.5f, window->Aabb().Max.x-1.5f, window->Aabb().Max.y-1.5f);

0 commit comments

Comments
 (0)