From 69db792bf0d28ab066d7dfe0053a82a9b9bc9728 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 15 Oct 2018 17:38:36 +0200 Subject: [PATCH] Viewport: Exposed GetOverlayDrawList(ImGuiViewport* viewport) in public API. (#1542, #1660, #1878, etc.) --- imgui.cpp | 3 ++- imgui.h | 3 ++- imgui_internal.h | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 1577fc0af..38a0bd41c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2919,10 +2919,11 @@ int ImGui::GetFrameCount() return GImGui->FrameCount; } -ImDrawList* ImGui::GetOverlayDrawList(ImGuiViewportP* viewport) +ImDrawList* ImGui::GetOverlayDrawList(ImGuiViewport* viewport_public) { // Create the draw list on demand, because it is not frequently used for all viewports ImGuiContext& g = *GImGui; + ImGuiViewportP* viewport = (ImGuiViewportP*)viewport_public; if (viewport->OverlayDrawList == NULL) { viewport->OverlayDrawList = IM_NEW(ImDrawList)(&g.DrawListSharedData); diff --git a/imgui.h b/imgui.h index b6e87cd65..23b5d98dd 100644 --- a/imgui.h +++ b/imgui.h @@ -558,7 +558,8 @@ namespace ImGui IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side. IMGUI_API double GetTime(); IMGUI_API int GetFrameCount(); - IMGUI_API ImDrawList* GetOverlayDrawList(); // this draw list will be the last rendered. it covers the entire current viewport. useful to quickly draw overlays shapes/text + IMGUI_API ImDrawList* GetOverlayDrawList(); // get overlay draw list for the viewport associated to the current window. this draw list will be the last rendered. useful to quickly draw overlays shapes/text. + IMGUI_API ImDrawList* GetOverlayDrawList(ImGuiViewport* viewport); // get overlay draw list for the given viewport. IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances IMGUI_API const char* GetStyleColorName(ImGuiCol idx); IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it) diff --git a/imgui_internal.h b/imgui_internal.h index 90c33a0a9..ebf36baf1 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1189,7 +1189,6 @@ namespace ImGui IMGUI_API void SetCurrentFont(ImFont* font); inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; } - IMGUI_API ImDrawList* GetOverlayDrawList(ImGuiViewportP* viewport); inline ImDrawList* GetOverlayDrawList(ImGuiWindow* window) { return GetOverlayDrawList(window->Viewport); } // Init