@@ -12908,7 +12908,7 @@ namespace ImGui
12908
12908
// ImGuiDockNode tree manipulations
12909
12909
static void DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiAxis split_axis, int split_first_child, float split_ratio, ImGuiDockNode* new_node);
12910
12910
static void DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiDockNode* merge_lead_child);
12911
- static void DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, bool only_write_to_marked_nodes = false );
12911
+ static void DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, ImGuiDockNode* only_write_to_single_node = NULL );
12912
12912
static void DockNodeTreeUpdateSplitter(ImGuiDockNode* node);
12913
12913
static ImGuiDockNode* DockNodeTreeFindVisibleNodeByPos(ImGuiDockNode* node, ImVec2 pos);
12914
12914
static ImGuiDockNode* DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node);
@@ -13604,7 +13604,6 @@ ImGuiDockNode::ImGuiDockNode(ImGuiID id)
13604
13604
IsVisible = true;
13605
13605
IsFocused = HasCloseButton = HasWindowMenuButton = HasCentralNodeChild = false;
13606
13606
WantCloseAll = WantLockSizeOnce = WantMouseMove = WantHiddenTabBarUpdate = WantHiddenTabBarToggle = false;
13607
- MarkedForPosSizeWrite = false;
13608
13607
}
13609
13608
13610
13609
ImGuiDockNode::~ImGuiDockNode()
@@ -14045,7 +14044,6 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
14045
14044
ImGuiContext& g = *GImGui;
14046
14045
IM_ASSERT(node->LastFrameActive != g.FrameCount);
14047
14046
node->LastFrameAlive = g.FrameCount;
14048
- node->MarkedForPosSizeWrite = false;
14049
14047
14050
14048
node->CentralNode = node->OnlyNodeWithWindows = NULL;
14051
14049
if (node->IsRootNode())
@@ -15153,11 +15151,11 @@ void ImGui::DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImG
15153
15151
15154
15152
// Update Pos/Size for a node hierarchy (don't affect child Windows yet)
15155
15153
// (Depth-first, Pre-Order)
15156
- void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, bool only_write_to_marked_nodes )
15154
+ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, ImGuiDockNode* only_write_to_single_node )
15157
15155
{
15158
15156
// During the regular dock node update we write to all nodes.
15159
- // 'only_write_to_marked_nodes ' is only set when turning a node visible mid-frame and we need its size right-away.
15160
- const bool write_to_node = (only_write_to_marked_nodes == false) || ( node->MarkedForPosSizeWrite) ;
15157
+ // 'only_write_to_single_node ' is only set when turning a node visible mid-frame and we need its size right-away.
15158
+ const bool write_to_node = only_write_to_single_node == NULL || only_write_to_single_node == node;
15161
15159
if (write_to_node)
15162
15160
{
15163
15161
node->Pos = pos;
@@ -15171,15 +15169,21 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
15171
15169
ImGuiDockNode* child_1 = node->ChildNodes[1];
15172
15170
ImVec2 child_0_pos = pos, child_1_pos = pos;
15173
15171
ImVec2 child_0_size = size, child_1_size = size;
15174
- if (child_0->IsVisible && child_1->IsVisible)
15172
+
15173
+ const bool child_0_is_toward_single_node = (only_write_to_single_node != NULL && DockNodeIsInHierarchyOf(only_write_to_single_node, child_0));
15174
+ const bool child_1_is_toward_single_node = (only_write_to_single_node != NULL && DockNodeIsInHierarchyOf(only_write_to_single_node, child_1));
15175
+ const bool child_0_is_or_will_be_visible = child_0->IsVisible || child_0_is_toward_single_node;
15176
+ const bool child_1_is_or_will_be_visible = child_1->IsVisible || child_1_is_toward_single_node;
15177
+
15178
+ if (child_0_is_or_will_be_visible && child_1_is_or_will_be_visible)
15175
15179
{
15180
+ ImGuiContext& g = *GImGui;
15176
15181
const float spacing = DOCKING_SPLITTER_SIZE;
15177
15182
const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
15178
15183
const float size_avail = ImMax(size[axis] - spacing, 0.0f);
15179
15184
15180
15185
// Size allocation policy
15181
15186
// 1) The first 0..WindowMinSize[axis]*2 are allocated evenly to both windows.
15182
- ImGuiContext& g = *GImGui;
15183
15187
const float size_min_each = ImFloor(ImMin(size_avail, g.Style.WindowMinSize[axis] * 2.0f) * 0.5f);
15184
15188
15185
15189
// FIXME: Blocks 2) and 3) are essentially doing nearly the same thing.
@@ -15230,11 +15234,15 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
15230
15234
15231
15235
child_1_pos[axis] += spacing + child_0_size[axis];
15232
15236
}
15233
- child_0->WantLockSizeOnce = child_1->WantLockSizeOnce = false;
15234
15237
15235
- if (child_0->IsVisible)
15238
+ if (only_write_to_single_node == NULL)
15239
+ child_0->WantLockSizeOnce = child_1->WantLockSizeOnce = false;
15240
+
15241
+ const bool child_0_recurse = only_write_to_single_node ? child_0_is_toward_single_node : child_0->IsVisible;
15242
+ const bool child_1_recurse = only_write_to_single_node ? child_1_is_toward_single_node : child_1->IsVisible;
15243
+ if (child_0_recurse)
15236
15244
DockNodeTreeUpdatePosSize(child_0, child_0_pos, child_0_size);
15237
- if (child_1->IsVisible )
15245
+ if (child_1_recurse )
15238
15246
DockNodeTreeUpdatePosSize(child_1, child_1_pos, child_1_size);
15239
15247
}
15240
15248
@@ -16048,16 +16056,11 @@ static ImGuiDockNode* ImGui::DockContextBindNodeToWindow(ImGuiContext* ctx, ImGu
16048
16056
if (!node->IsVisible)
16049
16057
{
16050
16058
ImGuiDockNode* ancestor_node = node;
16051
- while (!ancestor_node->IsVisible)
16052
- {
16053
- ancestor_node->IsVisible = true;
16054
- ancestor_node->MarkedForPosSizeWrite = true;
16055
- if (ancestor_node->ParentNode)
16056
- ancestor_node = ancestor_node->ParentNode;
16057
- }
16059
+ while (!ancestor_node->IsVisible && ancestor_node->ParentNode)
16060
+ ancestor_node = ancestor_node->ParentNode;
16058
16061
IM_ASSERT(ancestor_node->Size.x > 0.0f && ancestor_node->Size.y > 0.0f);
16059
16062
DockNodeUpdateHasCentralNodeChild(DockNodeGetRootNode(ancestor_node));
16060
- DockNodeTreeUpdatePosSize(ancestor_node, ancestor_node->Pos, ancestor_node->Size, true );
16063
+ DockNodeTreeUpdatePosSize(ancestor_node, ancestor_node->Pos, ancestor_node->Size, node );
16061
16064
}
16062
16065
16063
16066
// Add window to node
0 commit comments