Docking: Comments and renaming locals to facilitate debugging.

docking
omar 6 years ago
parent 0947fa3de0
commit c81a5a6070

@ -10462,10 +10462,10 @@ void ImGui::DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id
if (window->DockNode != NULL) if (window->DockNode != NULL)
continue; continue;
ImGuiDockNode* dock_node = DockContextFindNodeByID(ctx, window->DockId); ImGuiDockNode* node = DockContextFindNodeByID(ctx, window->DockId);
IM_ASSERT(dock_node != NULL); // This should have been called after DockContextBuildNodesFromSettings() IM_ASSERT(node != NULL); // This should have been called after DockContextBuildNodesFromSettings()
if (root_id == 0 || DockNodeGetRootNode(dock_node)->ID == root_id) if (root_id == 0 || DockNodeGetRootNode(node)->ID == root_id)
DockNodeAddWindow(dock_node, window, true); DockNodeAddWindow(node, window, true);
} }
} }
@ -12589,10 +12589,10 @@ void ImGui::DockBuilderCopyDockspace(ImGuiID src_dockspace_id, ImGuiID dst_docks
if (ImGuiID src_dock_id = node_remap_pairs[dock_remap_n]) if (ImGuiID src_dock_id = node_remap_pairs[dock_remap_n])
{ {
ImGuiID dst_dock_id = node_remap_pairs[dock_remap_n + 1]; ImGuiID dst_dock_id = node_remap_pairs[dock_remap_n + 1];
ImGuiDockNode* dock_node = DockBuilderGetNode(src_dock_id); ImGuiDockNode* node = DockBuilderGetNode(src_dock_id);
for (int window_n = 0; window_n < dock_node->Windows.Size; window_n++) for (int window_n = 0; window_n < node->Windows.Size; window_n++)
{ {
ImGuiWindow* window = dock_node->Windows[window_n]; ImGuiWindow* window = node->Windows[window_n];
if (src_windows.contains(window->ID)) if (src_windows.contains(window->ID))
continue; continue;
@ -12644,30 +12644,30 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
} }
// Bind to our dock node // Bind to our dock node
ImGuiDockNode* dock_node = window->DockNode; ImGuiDockNode* node = window->DockNode;
if (dock_node != NULL) if (node != NULL)
IM_ASSERT(window->DockId == dock_node->ID); IM_ASSERT(window->DockId == node->ID);
if (window->DockId != 0 && dock_node == NULL) if (window->DockId != 0 && node == NULL)
{ {
dock_node = DockContextFindNodeByID(ctx, window->DockId); node = DockContextFindNodeByID(ctx, window->DockId);
// We should not be docking into a split node (SetWindowDock should avoid this) // We should not be docking into a split node (SetWindowDock should avoid this)
if (dock_node && dock_node->IsSplitNode()) if (node && node->IsSplitNode())
{ {
DockContextProcessUndockWindow(ctx, window); DockContextProcessUndockWindow(ctx, window);
return; return;
} }
// Create node // Create node
if (dock_node == NULL) if (node == NULL)
{ {
dock_node = DockContextAddNode(ctx, window->DockId); node = DockContextAddNode(ctx, window->DockId);
if (auto_dock_node) if (auto_dock_node)
dock_node->LastFrameAlive = g.FrameCount; node->LastFrameAlive = g.FrameCount;
} }
DockNodeAddWindow(dock_node, window, true); DockNodeAddWindow(node, window, true);
IM_ASSERT(dock_node == window->DockNode); IM_ASSERT(node == window->DockNode);
// Fix an edge case with auto-resizing windows: if they are created on the same frame they are creating their dock node, // Fix an edge case with auto-resizing windows: if they are created on the same frame they are creating their dock node,
// we don't want their initial zero-size to spread to the DockNode. We preserve their size. // we don't want their initial zero-size to spread to the DockNode. We preserve their size.
@ -12677,7 +12677,7 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
} }
// Undock if the ImGuiDockNodeFlags_NoDockingInCentralNode got set // Undock if the ImGuiDockNodeFlags_NoDockingInCentralNode got set
if (dock_node->IsCentralNode && (dock_node->Flags & ImGuiDockNodeFlags_NoDockingInCentralNode)) if (node->IsCentralNode && (node->Flags & ImGuiDockNodeFlags_NoDockingInCentralNode))
{ {
DockContextProcessUndockWindow(ctx, window); DockContextProcessUndockWindow(ctx, window);
return; return;
@ -12685,10 +12685,10 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
// Undock if our dockspace node disappeared // Undock if our dockspace node disappeared
// Note how we are testing for LastFrameAlive and NOT LastFrameActive. A DockSpace node can be maintained alive while being inactive with ImGuiDockNodeFlags_KeepAliveOnly. // Note how we are testing for LastFrameAlive and NOT LastFrameActive. A DockSpace node can be maintained alive while being inactive with ImGuiDockNodeFlags_KeepAliveOnly.
if (dock_node->LastFrameAlive < g.FrameCount) if (node->LastFrameAlive < g.FrameCount)
{ {
// If the window has been orphaned, transition the docknode to an implicit node processed in DockContextUpdateDocking() // If the window has been orphaned, transition the docknode to an implicit node processed in DockContextUpdateDocking()
ImGuiDockNode* root_node = DockNodeGetRootNode(dock_node); ImGuiDockNode* root_node = DockNodeGetRootNode(node);
if (root_node->LastFrameAlive < g.FrameCount) if (root_node->LastFrameAlive < g.FrameCount)
{ {
DockContextProcessUndockWindow(ctx, window); DockContextProcessUndockWindow(ctx, window);
@ -12702,34 +12702,34 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
} }
// Undock if we are submitted earlier than the host window // Undock if we are submitted earlier than the host window
if (dock_node->HostWindow && window->BeginOrderWithinContext < dock_node->HostWindow->BeginOrderWithinContext) if (node->HostWindow && window->BeginOrderWithinContext < node->HostWindow->BeginOrderWithinContext)
{ {
DockContextProcessUndockWindow(ctx, window); DockContextProcessUndockWindow(ctx, window);
return; return;
} }
// FIXME-DOCK: replace ->HostWindow NULL compare with something more explicit (~was initially intended as a first frame test) // FIXME-DOCK: replace ->HostWindow NULL compare with something more explicit (~was initially intended as a first frame test)
if (dock_node->HostWindow == NULL) if (node->HostWindow == NULL)
{ {
window->DockTabIsVisible = false; window->DockTabIsVisible = false;
return; return;
} }
IM_ASSERT(dock_node->HostWindow); IM_ASSERT(node->HostWindow);
IM_ASSERT(dock_node->IsLeafNode()); IM_ASSERT(node->IsLeafNode());
// Position window // Position window
SetNextWindowPos(dock_node->Pos); SetNextWindowPos(node->Pos);
SetNextWindowSize(dock_node->Size); SetNextWindowSize(node->Size);
g.NextWindowData.PosUndock = false; // Cancel implicit undocking of SetNextWindowPos() g.NextWindowData.PosUndock = false; // Cancel implicit undocking of SetNextWindowPos()
window->DockIsActive = true; window->DockIsActive = true;
window->DockTabIsVisible = false; window->DockTabIsVisible = false;
if (dock_node->Flags & ImGuiDockNodeFlags_KeepAliveOnly) if (node->Flags & ImGuiDockNodeFlags_KeepAliveOnly)
return; return;
// When the window is selected we mark it as visible. // When the window is selected we mark it as visible.
if (dock_node->TabBar && dock_node->TabBar->VisibleTabId == window->ID) if (node->TabBar && node->TabBar->VisibleTabId == window->ID)
window->DockTabIsVisible = true; window->DockTabIsVisible = true;
// When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesForResize. // When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesForResize.
@ -12737,22 +12737,22 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
// This is analogous to regular windows being hidden from one frame. It is especially important as nested TabBars would otherwise generate flicker in the form // This is analogous to regular windows being hidden from one frame. It is especially important as nested TabBars would otherwise generate flicker in the form
// of one empty frame. // of one empty frame.
// Note that we set HiddenFramesForResize=2 because BeginDocked() is called just before Begin() has a chance to decrement the value. Effectively it'll be a 1 frame thing. // Note that we set HiddenFramesForResize=2 because BeginDocked() is called just before Begin() has a chance to decrement the value. Effectively it'll be a 1 frame thing.
if (!window->DockTabIsVisible && dock_node->TabBar && dock_node->TabBar->NextSelectedTabId == window->ID) if (!window->DockTabIsVisible && node->TabBar && node->TabBar->NextSelectedTabId == window->ID)
window->HiddenFramesForResize = 2; window->HiddenFramesForResize = 2;
// Update window flag // Update window flag
IM_ASSERT((window->Flags & ImGuiWindowFlags_ChildWindow) == 0); IM_ASSERT((window->Flags & ImGuiWindowFlags_ChildWindow) == 0);
window->Flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_NoResize; window->Flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_NoResize;
if (dock_node->IsHiddenTabBar) if (node->IsHiddenTabBar)
window->Flags |= ImGuiWindowFlags_NoTitleBar; window->Flags |= ImGuiWindowFlags_NoTitleBar;
else else
window->Flags &= ~ImGuiWindowFlags_NoTitleBar; // Clear the NoTitleBar flag in case the user set it: confusingly enough we need a title bar height so we are correctly offset, but it won't be displayed! window->Flags &= ~ImGuiWindowFlags_NoTitleBar; // Clear the NoTitleBar flag in case the user set it: confusingly enough we need a title bar height so we are correctly offset, but it won't be displayed!
// Save new dock order only if the tab bar is active // Save new dock order only if the tab bar is active
if (dock_node->TabBar) if (node->TabBar)
window->DockOrder = (short)DockNodeGetTabOrder(window); window->DockOrder = (short)DockNodeGetTabOrder(window);
if ((dock_node->WantCloseAll || dock_node->WantCloseTabID == window->ID) && p_open != NULL) if ((node->WantCloseAll || node->WantCloseTabID == window->ID) && p_open != NULL)
*p_open = false; *p_open = false;
// Update ChildId to allow returning from Child to Parent with Escape // Update ChildId to allow returning from Child to Parent with Escape
@ -13847,13 +13847,16 @@ void ImGui::ShowDockingDebug()
if (node->Windows.Size > 0) if (node->Windows.Size > 0)
open = ImGui::TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: %d windows (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", node->Windows.Size, node->VisibleWindow ? node->VisibleWindow->Name : "NULL"); open = ImGui::TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: %d windows (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", node->Windows.Size, node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
else else
open = ImGui::TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: split %s (act: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", (node->SplitAxis == ImGuiAxis_X) ? "horizontal" : (node->SplitAxis == ImGuiAxis_Y) ? "vertical" : "n/a", node->VisibleWindow ? node->VisibleWindow->Name : "NULL"); open = ImGui::TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: %s split (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", (node->SplitAxis == ImGuiAxis_X) ? "horizontal" : (node->SplitAxis == ImGuiAxis_Y) ? "vertical" : "n/a", node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
if (open) if (open)
{ {
IM_ASSERT(node->ChildNodes[0] == NULL || node->ChildNodes[0]->ParentNode == node); IM_ASSERT(node->ChildNodes[0] == NULL || node->ChildNodes[0]->ParentNode == node);
IM_ASSERT(node->ChildNodes[1] == NULL || node->ChildNodes[1]->ParentNode == node); IM_ASSERT(node->ChildNodes[1] == NULL || node->ChildNodes[1]->ParentNode == node);
ImGui::BulletText("Pos (%.0f,%.0f), Size (%.0f, %.0f) Ref (%.0f, %.0f)", ImGui::BulletText("Pos (%.0f,%.0f), Size (%.0f, %.0f) Ref (%.0f, %.0f)",
node->Pos.x, node->Pos.y, node->Size.x, node->Size.y, node->SizeRef.x, node->SizeRef.y); node->Pos.x, node->Pos.y, node->Size.x, node->Size.y, node->SizeRef.x, node->SizeRef.y);
ImGui::BulletText("VisibleWindow: 0x%08X %s", node->VisibleWindow ? node->VisibleWindow->ID : 0, node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
ImGui::BulletText("SelectedTabID: 0x%08X", node->SelectedTabID);
ImGui::BulletText("LastFocusedNodeID: 0x%08X", node->LastFocusedNodeID);
ImGui::BulletText("Flags 0x%02X%s%s%s%s", ImGui::BulletText("Flags 0x%02X%s%s%s%s",
node->Flags, node->IsDockSpace ? ", IsDockSpace" : "", node->IsCentralNode ? ", IsCentralNode" : "", node->Flags, node->IsDockSpace ? ", IsDockSpace" : "", node->IsCentralNode ? ", IsCentralNode" : "",
(GImGui->FrameCount - node->LastFrameAlive < 2) ? ", IsAlive" : "", (GImGui->FrameCount - node->LastFrameActive < 2) ? ", IsActive" : ""); (GImGui->FrameCount - node->LastFrameAlive < 2) ? ", IsAlive" : "", (GImGui->FrameCount - node->LastFrameActive < 2) ? ", IsActive" : "");

@ -829,13 +829,13 @@ struct ImGuiDockNode
ImGuiWindowClass WindowClass; ImGuiWindowClass WindowClass;
ImGuiWindow* HostWindow; ImGuiWindow* HostWindow;
ImGuiWindow* VisibleWindow; ImGuiWindow* VisibleWindow; // Generally point to window which is ID is == SelectedTabID, but when CTRL+Tabbing this can be a different window.
ImGuiDockNode* CentralNode; // [Root node only] Pointer to central node. ImGuiDockNode* CentralNode; // [Root node only] Pointer to central node.
ImGuiDockNode* OnlyNodeWithWindows; // [Root node only] Set when there is a single visible node within the hierarchy. ImGuiDockNode* OnlyNodeWithWindows; // [Root node only] Set when there is a single visible node within the hierarchy.
int LastFrameAlive; // Last frame number the node was updated or kept alive explicitly with DockSpace() + ImGuiDockNodeFlags_KeepAliveOnly int LastFrameAlive; // Last frame number the node was updated or kept alive explicitly with DockSpace() + ImGuiDockNodeFlags_KeepAliveOnly
int LastFrameActive; // Last frame number the node was updated. int LastFrameActive; // Last frame number the node was updated.
int LastFrameFocused; // Last frame number the node was focused. int LastFrameFocused; // Last frame number the node was focused.
ImGuiID LastFocusedNodeID; // [Root node only] Which of our child node (any ancestor in the hierarchy) was last focused. ImGuiID LastFocusedNodeID; // [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
ImGuiID SelectedTabID; // [Tab node only] Which of our tab is selected. ImGuiID SelectedTabID; // [Tab node only] Which of our tab is selected.
ImGuiID WantCloseTabID; // [Tab node only] Set when closing a specific tab. ImGuiID WantCloseTabID; // [Tab node only] Set when closing a specific tab.
bool InitFromFirstWindowPosSize :1; bool InitFromFirstWindowPosSize :1;

Loading…
Cancel
Save