MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / DockContextBindNodeToWindow

Method DockContextBindNodeToWindow

imgui_tiny_app/imgui/imgui.cpp:21105–21146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21103}
21104
21105static ImGuiDockNode* ImGui::DockContextBindNodeToWindow(ImGuiContext* ctx, ImGuiWindow* window)
21106{
21107 ImGuiContext& g = *ctx;
21108 ImGuiDockNode* node = DockContextFindNodeByID(ctx, window->DockId);
21109 IM_ASSERT(window->DockNode == NULL);
21110
21111 // We should not be docking into a split node (SetWindowDock should avoid this)
21112 if (node && node->IsSplitNode())
21113 {
21114 DockContextProcessUndockWindow(ctx, window);
21115 return NULL;
21116 }
21117
21118 // Create node
21119 if (node == NULL)
21120 {
21121 node = DockContextAddNode(ctx, window->DockId);
21122 node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Window;
21123 node->LastFrameAlive = g.FrameCount;
21124 }
21125
21126 // If the node just turned visible and is part of a hierarchy, it doesn't have a Size assigned by DockNodeTreeUpdatePosSize() yet,
21127 // so we're forcing a Pos/Size update from the first ancestor that is already visible (often it will be the root node).
21128 // If we don't do this, the window will be assigned a zero-size on its first frame, which won't ideally warm up the layout.
21129 // This is a little wonky because we don't normally update the Pos/Size of visible node mid-frame.
21130 if (!node->IsVisible)
21131 {
21132 ImGuiDockNode* ancestor_node = node;
21133 while (!ancestor_node->IsVisible && ancestor_node->ParentNode)
21134 ancestor_node = ancestor_node->ParentNode;
21135 IM_ASSERT(ancestor_node->Size.x > 0.0f && ancestor_node->Size.y > 0.0f);
21136 DockNodeUpdateHasCentralNodeChild(DockNodeGetRootNode(ancestor_node));
21137 DockNodeTreeUpdatePosSize(ancestor_node, ancestor_node->Pos, ancestor_node->Size, node);
21138 }
21139
21140 // Add window to node
21141 bool node_was_visible = node->IsVisible;
21142 DockNodeAddWindow(node, window, true);
21143 node->IsVisible = node_was_visible; // Don't mark visible right away (so DockContextEndFrame() doesn't render it, maybe other side effects? will see)
21144 IM_ASSERT(node == window->DockNode);
21145 return node;
21146}
21147
21148static void StoreDockStyleForWindow(ImGuiWindow* window)
21149{

Callers

nothing calls this directly

Calls 1

DockNodeGetRootNodeFunction · 0.85

Tested by

no test coverage detected