Docking: floating node with a central node hides properly when nothing is docked + rename.

This commit is contained in:
ocornut 2021-09-14 16:58:35 +02:00
parent 8dfb52245b
commit 29828d0469
3 changed files with 13 additions and 4 deletions

View File

@ -145,7 +145,8 @@ Docking+Viewports Branch:
docking hierarchy. Added ImGuiFocusedFlags_DockHierarchy flag to consider docking hierarchy in the test.
- IsWindowHovered: Fixed using ImGuiHoveredFlags_ChildWindows (without _RootWindow) from leaking the
docking hierarchy. Added ImGuiHoveredFlags_DockHierarchy flag to consider docking hierarchy in the test.
- Docking: fixed settings load issue when mouse wheeling. (#4310)
- Docking: Fixed settings load issue when mouse wheeling. (#4310)
- Docking: Fixed manually created floating node with a central node from not hiding when windows are gone.
- Docking + Drag and Drop: Fixed using BeginDragDropSource() or BeginDragDropTarget() inside a Begin()
that returned false because the window is docked. (#4515)
- Viewports: Fixed a crash while a window owning its viewport disappear while being dragged.

View File

@ -13330,6 +13330,7 @@ ImGuiDockNode::ImGuiDockNode(ImGuiID id)
State = ImGuiDockNodeState_Unknown;
HostWindow = VisibleWindow = NULL;
CentralNode = OnlyNodeWithWindows = NULL;
CountNodeWithWindows = 0;
LastFrameAlive = LastFrameActive = LastFrameFocused = -1;
LastFocusedNodeId = 0;
SelectedTabId = 0;
@ -13715,6 +13716,7 @@ static void ImGui::DockNodeUpdateForRootNode(ImGuiDockNode* node)
DockNodeFindInfo(node, &info);
node->CentralNode = info.CentralNode;
node->OnlyNodeWithWindows = (info.CountNodesWithWindows == 1) ? info.FirstNodeWithWindows : NULL;
node->CountNodeWithWindows = info.CountNodesWithWindows;
if (node->LastFocusedNodeId == 0 && info.FirstNodeWithWindows != NULL)
node->LastFocusedNodeId = info.FirstNodeWithWindows->ID;
@ -13764,9 +13766,14 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
// Early out for hidden root dock nodes (when all DockId references are in inactive windows, or there is only 1 floating window holding on the DockId)
bool want_to_hide_host_window = false;
if (node->Windows.Size <= 1 && node->IsFloatingNode() && node->IsLeafNode())
if (node->IsFloatingNode())
{
if (node->Windows.Size <= 1 && node->IsLeafNode())
if (!g.IO.ConfigDockingAlwaysTabBar && (node->Windows.Size == 0 || !node->Windows[0]->WindowClass.DockingAlwaysTabBar))
want_to_hide_host_window = true;
if (node->CountNodeWithWindows == 0)
want_to_hide_host_window = true;
}
if (want_to_hide_host_window)
{
if (node->Windows.Size == 1)

View File

@ -1363,6 +1363,7 @@ struct IMGUI_API ImGuiDockNode
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* OnlyNodeWithWindows; // [Root node only] Set when there is a single visible node within the hierarchy.
int CountNodeWithWindows; // [Root node only]
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 LastFrameFocused; // Last frame number the node was focused.
@ -1617,7 +1618,7 @@ struct ImGuiContext
ImGuiWindow* CurrentWindow; // Window being drawn into
ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs.
ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
ImGuiDockNode* HoveredDockNode; // Hovered dock node.
ImGuiDockNode* HoveredDockNode; // [Debug] Hovered dock node.
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindowDockTree.
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
ImVec2 WheelingWindowRefMousePos;