From bfc0efaae9c4322557abc0146af1b3244a3a63a4 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 11 Apr 2018 12:43:38 +0200 Subject: [PATCH] Internals: Window: Aggregating ImDrawList into the ImGuiWindow structure. --- imgui.cpp | 5 +++-- imgui_internal.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 6b7ce2f0b..b07e7391d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1918,6 +1918,7 @@ bool ImGuiListClipper::Step() //----------------------------------------------------------------------------- ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) + : DrawListInst(&context->DrawListSharedData) { Name = ImStrdup(name); ID = ImHash(name, 0); @@ -1959,7 +1960,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) ItemWidthDefault = 0.0f; FontWindowScale = 1.0f; - DrawList = IM_NEW(ImDrawList)(&context->DrawListSharedData); + DrawList = &DrawListInst; DrawList->_OwnerName = Name; ParentWindow = NULL; RootWindow = NULL; @@ -1978,7 +1979,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) ImGuiWindow::~ImGuiWindow() { - IM_DELETE(DrawList); + IM_ASSERT(DrawList == &DrawListInst); IM_DELETE(Name); for (int i = 0; i != ColumnsStorage.Size; i++) ColumnsStorage[i].~ImGuiColumnsSet(); diff --git a/imgui_internal.h b/imgui_internal.h index 7f0c3464b..4b512ee3e 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -943,7 +943,8 @@ struct IMGUI_API ImGuiWindow ImGuiStorage StateStorage; ImVector ColumnsStorage; float FontWindowScale; // Scale multiplier per-window - ImDrawList* DrawList; + ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer) + ImDrawList DrawListInst; ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL. ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.