mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-23 04:17:00 +00:00
Added extra asserts and tweaked code in Begin()
This commit is contained in:
parent
07f69966f8
commit
962ef3924a
13
imgui.cpp
13
imgui.cpp
@ -2451,6 +2451,9 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
|
|||||||
g.SetNextWindowCollapsedCond = 0;
|
g.SetNextWindowCollapsedCond = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find parent
|
||||||
|
ImGuiWindow* parent_window = (flags & ImGuiWindowFlags_ChildWindow) != 0 ? g.CurrentWindowStack[g.CurrentWindowStack.size()-2] : NULL;
|
||||||
|
|
||||||
// Find root (if we are a child window)
|
// Find root (if we are a child window)
|
||||||
size_t root_idx = g.CurrentWindowStack.size() - 1;
|
size_t root_idx = g.CurrentWindowStack.size() - 1;
|
||||||
while (root_idx > 0)
|
while (root_idx > 0)
|
||||||
@ -2483,7 +2486,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
|
|||||||
|
|
||||||
if (flags & ImGuiWindowFlags_ChildWindow)
|
if (flags & ImGuiWindowFlags_ChildWindow)
|
||||||
{
|
{
|
||||||
ImGuiWindow* parent_window = g.CurrentWindowStack[g.CurrentWindowStack.size()-2];
|
|
||||||
parent_window->DC.ChildWindows.push_back(window);
|
parent_window->DC.ChildWindows.push_back(window);
|
||||||
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
|
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
|
||||||
window->SizeFull = size;
|
window->SizeFull = size;
|
||||||
@ -2491,7 +2493,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
|
|||||||
|
|
||||||
// Outer clipping rectangle
|
// Outer clipping rectangle
|
||||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ComboBox))
|
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ComboBox))
|
||||||
PushClipRect(g.CurrentWindowStack[g.CurrentWindowStack.size()-2]->ClipRectStack.back());
|
PushClipRect(parent_window->ClipRectStack.back());
|
||||||
else
|
else
|
||||||
PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
|
PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
|
||||||
|
|
||||||
@ -2788,14 +2790,9 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
|
|||||||
|
|
||||||
// Outer clipping rectangle
|
// Outer clipping rectangle
|
||||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ComboBox))
|
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ComboBox))
|
||||||
{
|
|
||||||
ImGuiWindow* parent_window = g.CurrentWindowStack[g.CurrentWindowStack.size()-2];
|
|
||||||
PushClipRect(parent_window->ClipRectStack.back());
|
PushClipRect(parent_window->ClipRectStack.back());
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
|
PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inner clipping rectangle
|
// Inner clipping rectangle
|
||||||
@ -6068,6 +6065,7 @@ void ImDrawList::PushClipRect(const ImVec4& clip_rect)
|
|||||||
|
|
||||||
void ImDrawList::PopClipRect()
|
void ImDrawList::PopClipRect()
|
||||||
{
|
{
|
||||||
|
IM_ASSERT(clip_rect_stack.size() > 0);
|
||||||
clip_rect_stack.pop_back();
|
clip_rect_stack.pop_back();
|
||||||
const ImVec4 clip_rect = clip_rect_stack.empty() ? GNullClipRect : clip_rect_stack.back();
|
const ImVec4 clip_rect = clip_rect_stack.empty() ? GNullClipRect : clip_rect_stack.back();
|
||||||
SetClipRect(clip_rect);
|
SetClipRect(clip_rect);
|
||||||
@ -6100,6 +6098,7 @@ void ImDrawList::PushTextureID(const ImTextureID& texture_id)
|
|||||||
|
|
||||||
void ImDrawList::PopTextureID()
|
void ImDrawList::PopTextureID()
|
||||||
{
|
{
|
||||||
|
IM_ASSERT(texture_id_stack.size() > 0);
|
||||||
texture_id_stack.pop_back();
|
texture_id_stack.pop_back();
|
||||||
const ImTextureID texture_id = texture_id_stack.empty() ? NULL : texture_id_stack.back();
|
const ImTextureID texture_id = texture_id_stack.empty() ? NULL : texture_id_stack.back();
|
||||||
SetTextureID(texture_id);
|
SetTextureID(texture_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user