Skip to content

Commit

Permalink
Docking: Draw empty node rect at the end of frame so we truly know th…
Browse files Browse the repository at this point in the history
…e node is empty.
  • Loading branch information
kudaba committed May 13, 2020
1 parent b3ad387 commit 7f0d65c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ static bool UpdateWindowManualResize(ImGuiWindow* window, const ImVe
static void RenderWindowOuterBorders(ImGuiWindow* window);
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
static void EndFrameDrawEmptyDockNodes(ImGuiContext* ctx);
static void EndFrameDrawDimmedBackgrounds();

// Viewports
Expand Down Expand Up @@ -4483,6 +4484,9 @@ void ImGui::EndFrame()
g.CurrentWindow->Active = false;
End();

// Draw dock nodes with no windows with alternate backgrounds
EndFrameDrawEmptyDockNodes(&g);

// Draw modal whitening background on _other_ viewports than the one the modal is one
EndFrameDrawDimmedBackgrounds();

Expand Down Expand Up @@ -11726,6 +11730,7 @@ namespace ImGui
// - DockContextPruneUnusedSettingsNodes()
// - DockContextBuildNodesFromSettings()
// - DockContextBuildAddWindowsToNodes()
// - EndFrameDrawEmptyDockNodes()
//-----------------------------------------------------------------------------

void ImGui::DockContextInitialize(ImGuiContext* ctx)
Expand Down Expand Up @@ -12035,6 +12040,19 @@ void ImGui::DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id
}
}

void ImGui::EndFrameDrawEmptyDockNodes(ImGuiContext* ctx)
{
ImGuiContext& g = *ctx;
for (int n = 0; n < g.DockContext->Nodes.Data.Size; n++)
if (ImGuiDockNode* node = (ImGuiDockNode*)g.DockContext->Nodes.Data[n].val_p)
{
// Draw empty node background (currently can only be the Central Node)
ImGuiWindow* host_window = node->HostWindow;
if (host_window && node->IsEmpty() && node->IsVisible && !(node->GetMergedFlags() & ImGuiDockNodeFlags_PassthruCentralNode))
host_window->DrawList->AddRectFilled(node->Pos, node->Pos + node->Size, GetColorU32(ImGuiCol_DockingEmptyBg));
}
}

//-----------------------------------------------------------------------------
// Docking: ImGuiDockContext Docking/Undocking functions
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -12938,10 +12956,6 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
DockNodeTreeUpdateSplitter(node);
}

// Draw empty node background (currently can only be the Central Node)
if (host_window && node->IsEmpty() && node->IsVisible && !(node_flags & ImGuiDockNodeFlags_PassthruCentralNode))
host_window->DrawList->AddRectFilled(node->Pos, node->Pos + node->Size, GetColorU32(ImGuiCol_DockingEmptyBg));

// Draw whole dockspace background if ImGuiDockNodeFlags_PassthruCentralNode if set.
if (render_dockspace_bg && node->IsVisible)
{
Expand Down

0 comments on commit 7f0d65c

Please sign in to comment.