MCPcopy Create free account
hub / github.com/XJTU-Graphics/dandelion / DockBuilderRemoveNodeChildNodes

Method DockBuilderRemoveNodeChildNodes

deps/imgui/imgui.cpp:20225–20293  ·  view source on GitHub ↗

root_id = 0 to remove all, root_id != 0 to remove child of given node.

Source from the content-addressed store, hash-verified

20223
20224// root_id = 0 to remove all, root_id != 0 to remove child of given node.
20225void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id)
20226{
20227 ImGuiContext& g = *GImGui;
20228 ImGuiDockContext* dc = &g.DockContext;
20229
20230 ImGuiDockNode* root_node = root_id ? DockContextFindNodeByID(&g, root_id) : NULL;
20231 if (root_id && root_node == NULL)
20232 return;
20233 bool has_central_node = false;
20234
20235 ImGuiDataAuthority backup_root_node_authority_for_pos = root_node ? root_node->AuthorityForPos : ImGuiDataAuthority_Auto;
20236 ImGuiDataAuthority backup_root_node_authority_for_size = root_node ? root_node->AuthorityForSize : ImGuiDataAuthority_Auto;
20237
20238 // Process active windows
20239 ImVector<ImGuiDockNode*> nodes_to_remove;
20240 for (int n = 0; n < dc->Nodes.Data.Size; n++)
20241 if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
20242 {
20243 bool want_removal = (root_id == 0) || (node->ID != root_id && DockNodeGetRootNode(node)->ID == root_id);
20244 if (want_removal)
20245 {
20246 if (node->IsCentralNode())
20247 has_central_node = true;
20248 if (root_id != 0)
20249 DockContextQueueNotifyRemovedNode(&g, node);
20250 if (root_node)
20251 {
20252 DockNodeMoveWindows(root_node, node);
20253 DockSettingsRenameNodeReferences(node->ID, root_node->ID);
20254 }
20255 nodes_to_remove.push_back(node);
20256 }
20257 }
20258
20259 // DockNodeMoveWindows->DockNodeAddWindow will normally set those when reaching two windows (which is only adequate during interactive merge)
20260 // Make sure we don't lose our current pos/size. (FIXME-DOCK: Consider tidying up that code in DockNodeAddWindow instead)
20261 if (root_node)
20262 {
20263 root_node->AuthorityForPos = backup_root_node_authority_for_pos;
20264 root_node->AuthorityForSize = backup_root_node_authority_for_size;
20265 }
20266
20267 // Apply to settings
20268 for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
20269 if (ImGuiID window_settings_dock_id = settings->DockId)
20270 for (int n = 0; n < nodes_to_remove.Size; n++)
20271 if (nodes_to_remove[n]->ID == window_settings_dock_id)
20272 {
20273 settings->DockId = root_id;
20274 break;
20275 }
20276
20277 // Not really efficient, but easier to destroy a whole hierarchy considering DockContextRemoveNode is attempting to merge nodes
20278 if (nodes_to_remove.Size > 1)
20279 ImQsort(nodes_to_remove.Data, nodes_to_remove.Size, sizeof(ImGuiDockNode*), DockNodeComparerDepthMostFirst);
20280 for (int n = 0; n < nodes_to_remove.Size; n++)
20281 DockContextRemoveNode(&g, nodes_to_remove[n], false);
20282

Callers

nothing calls this directly

Calls 7

DockNodeGetRootNodeFunction · 0.85
ImQsortFunction · 0.85
next_chunkMethod · 0.80
push_backMethod · 0.45
beginMethod · 0.45
ClearMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected