mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 13:35:49 +02:00
Internals: rename bg/fg drawlist holders in structs to reduce confusion.
This commit is contained in:
20
imgui.cpp
20
imgui.cpp
@ -4258,33 +4258,33 @@ int ImGui::GetFrameCount()
|
||||
return GImGui->FrameCount;
|
||||
}
|
||||
|
||||
static ImDrawList* GetViewportDrawList(ImGuiViewportP* viewport, size_t drawlist_no, const char* drawlist_name)
|
||||
static ImDrawList* GetViewportBgFgDrawList(ImGuiViewportP* viewport, size_t drawlist_no, const char* drawlist_name)
|
||||
{
|
||||
// Create the draw list on demand, because they are not frequently used for all viewports
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(drawlist_no < IM_ARRAYSIZE(viewport->DrawLists));
|
||||
ImDrawList* draw_list = viewport->DrawLists[drawlist_no];
|
||||
IM_ASSERT(drawlist_no < IM_ARRAYSIZE(viewport->BgFgDrawLists));
|
||||
ImDrawList* draw_list = viewport->BgFgDrawLists[drawlist_no];
|
||||
if (draw_list == NULL)
|
||||
{
|
||||
draw_list = IM_NEW(ImDrawList)(&g.DrawListSharedData);
|
||||
draw_list->_OwnerName = drawlist_name;
|
||||
viewport->DrawLists[drawlist_no] = draw_list;
|
||||
viewport->BgFgDrawLists[drawlist_no] = draw_list;
|
||||
}
|
||||
|
||||
// Our ImDrawList system requires that there is always a command
|
||||
if (viewport->DrawListsLastFrame[drawlist_no] != g.FrameCount)
|
||||
if (viewport->BgFgDrawListsLastFrame[drawlist_no] != g.FrameCount)
|
||||
{
|
||||
draw_list->_ResetForNewFrame();
|
||||
draw_list->PushTextureID(g.IO.Fonts->TexID);
|
||||
draw_list->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size, false);
|
||||
viewport->DrawListsLastFrame[drawlist_no] = g.FrameCount;
|
||||
viewport->BgFgDrawListsLastFrame[drawlist_no] = g.FrameCount;
|
||||
}
|
||||
return draw_list;
|
||||
}
|
||||
|
||||
ImDrawList* ImGui::GetBackgroundDrawList(ImGuiViewport* viewport)
|
||||
{
|
||||
return GetViewportDrawList((ImGuiViewportP*)viewport, 0, "##Background");
|
||||
return GetViewportBgFgDrawList((ImGuiViewportP*)viewport, 0, "##Background");
|
||||
}
|
||||
|
||||
ImDrawList* ImGui::GetBackgroundDrawList()
|
||||
@ -4295,7 +4295,7 @@ ImDrawList* ImGui::GetBackgroundDrawList()
|
||||
|
||||
ImDrawList* ImGui::GetForegroundDrawList(ImGuiViewport* viewport)
|
||||
{
|
||||
return GetViewportDrawList((ImGuiViewportP*)viewport, 1, "##Foreground");
|
||||
return GetViewportBgFgDrawList((ImGuiViewportP*)viewport, 1, "##Foreground");
|
||||
}
|
||||
|
||||
ImDrawList* ImGui::GetForegroundDrawList()
|
||||
@ -5090,7 +5090,7 @@ void ImGui::Render()
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
InitViewportDrawData(viewport);
|
||||
if (viewport->DrawLists[0] != NULL)
|
||||
if (viewport->BgFgDrawLists[0] != NULL)
|
||||
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
|
||||
}
|
||||
|
||||
@ -5125,7 +5125,7 @@ void ImGui::Render()
|
||||
FlattenDrawDataIntoSingleLayer(&viewport->DrawDataBuilder);
|
||||
|
||||
// Add foreground ImDrawList (for each active viewport)
|
||||
if (viewport->DrawLists[1] != NULL)
|
||||
if (viewport->BgFgDrawLists[1] != NULL)
|
||||
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
|
||||
|
||||
// We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch).
|
||||
|
Reference in New Issue
Block a user