mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
Internals: rename bg/fg drawlist holders in structs to reduce confusion.
This commit is contained in:
parent
52587c28d6
commit
cf3726bcbc
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).
|
||||
|
@ -1600,8 +1600,8 @@ struct ImGuiOldColumns
|
||||
// Every instance of ImGuiViewport is in fact a ImGuiViewportP.
|
||||
struct ImGuiViewportP : public ImGuiViewport
|
||||
{
|
||||
int DrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
||||
ImDrawList* DrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
||||
int BgFgDrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
||||
ImDrawList* BgFgDrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
||||
ImDrawData DrawDataP;
|
||||
ImDrawDataBuilder DrawDataBuilder; // Temporary data while building final ImDrawData
|
||||
ImVec2 WorkOffsetMin; // Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!)
|
||||
@ -1609,8 +1609,8 @@ struct ImGuiViewportP : public ImGuiViewport
|
||||
ImVec2 BuildWorkOffsetMin; // Work Area: Offset being built during current frame. Generally >= 0.0f.
|
||||
ImVec2 BuildWorkOffsetMax; // Work Area: Offset being built during current frame. Generally <= 0.0f.
|
||||
|
||||
ImGuiViewportP() { DrawListsLastFrame[0] = DrawListsLastFrame[1] = -1; DrawLists[0] = DrawLists[1] = NULL; }
|
||||
~ImGuiViewportP() { if (DrawLists[0]) IM_DELETE(DrawLists[0]); if (DrawLists[1]) IM_DELETE(DrawLists[1]); }
|
||||
ImGuiViewportP() { BgFgDrawListsLastFrame[0] = BgFgDrawListsLastFrame[1] = -1; BgFgDrawLists[0] = BgFgDrawLists[1] = NULL; }
|
||||
~ImGuiViewportP() { if (BgFgDrawLists[0]) IM_DELETE(BgFgDrawLists[0]); if (BgFgDrawLists[1]) IM_DELETE(BgFgDrawLists[1]); }
|
||||
|
||||
// Calculate work rect pos/size given a set of offset (we have 1 pair of offset for rect locked from last frame data, and 1 pair for currently building rect)
|
||||
ImVec2 CalcWorkRectPos(const ImVec2& off_min) const { return ImVec2(Pos.x + off_min.x, Pos.y + off_min.y); }
|
||||
|
Loading…
Reference in New Issue
Block a user