Docking: Fixed assert in DockContextProcessDock() preventing some uses of DockNodeBuilder api. (#2357, #2109)

This commit is contained in:
omar 2019-02-18 16:13:17 +01:00
parent 5bf9029bf9
commit 3de440fda2

View File

@ -10624,8 +10624,9 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
} }
// FIXME-DOCK: When we are trying to dock an existing single-window node into a loose window, transfer Node ID as well // FIXME-DOCK: When we are trying to dock an existing single-window node into a loose window, transfer Node ID as well
// When processing an interactive split, usually LastFrameAlive will be < g.FrameCount. But DockBuilder operations can make it ==.
if (target_node) if (target_node)
IM_ASSERT(target_node->LastFrameAlive < g.FrameCount); IM_ASSERT(target_node->LastFrameAlive <= g.FrameCount);
if (target_node && target_window && target_node == target_window->DockNodeAsHost) if (target_node && target_window && target_node == target_window->DockNodeAsHost)
IM_ASSERT(target_node->Windows.Size > 0 || target_node->IsSplitNode() || target_node->IsCentralNode); IM_ASSERT(target_node->Windows.Size > 0 || target_node->IsSplitNode() || target_node->IsCentralNode);
@ -11975,7 +11976,7 @@ void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImG
parent_node->VisibleWindow = NULL; parent_node->VisibleWindow = NULL;
float size_avail = (parent_node->Size[split_axis] - IMGUI_DOCK_SPLITTER_SIZE); float size_avail = (parent_node->Size[split_axis] - IMGUI_DOCK_SPLITTER_SIZE);
IM_ASSERT(size_avail > 0.0f); IM_ASSERT(size_avail > 0.0f); // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting.
child_0->SizeRef = child_1->SizeRef = parent_node->Size; child_0->SizeRef = child_1->SizeRef = parent_node->Size;
child_0->SizeRef[split_axis] = ImFloor(size_avail * split_ratio); child_0->SizeRef[split_axis] = ImFloor(size_avail * split_ratio);
child_1->SizeRef[split_axis] = ImFloor(size_avail - child_0->SizeRef[split_axis]); child_1->SizeRef[split_axis] = ImFloor(size_avail - child_0->SizeRef[split_axis]);
@ -12476,7 +12477,6 @@ ImGuiID ImGui::DockBuilderAddNode(ImGuiID id, ImGuiDockNodeFlags flags)
{ {
DockSpace(id, ImVec2(0, 0), flags | ImGuiDockNodeFlags_KeepAliveOnly); DockSpace(id, ImVec2(0, 0), flags | ImGuiDockNodeFlags_KeepAliveOnly);
node = DockContextFindNodeByID(ctx, id); node = DockContextFindNodeByID(ctx, id);
node->LastFrameAlive = -1;
} }
else else
{ {
@ -12484,8 +12484,8 @@ ImGuiID ImGui::DockBuilderAddNode(ImGuiID id, ImGuiDockNodeFlags flags)
node = DockContextFindNodeByID(ctx, id); node = DockContextFindNodeByID(ctx, id);
if (!node) if (!node)
node = DockContextAddNode(ctx, id); node = DockContextAddNode(ctx, id);
node->LastFrameAlive = ctx->FrameCount;
} }
node->LastFrameAlive = ctx->FrameCount; // Set this otherwise BeginDocked will undock during the same frame.
return node->ID; return node->ID;
} }