diff --git a/imgui.cpp b/imgui.cpp index 6a55cff7..ca718d74 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5626,7 +5626,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar // Docking: Unhide tab bar (small triangle in the corner), drag from small triangle to quickly undock ImGuiDockNode* node = window->DockNode; - if (node && window->DockIsActive && node->IsHiddenTabBar() && !node->IsNoTabBar()) + if (window->DockIsActive && node->IsHiddenTabBar() && !node->IsNoTabBar()) { float unhide_sz_draw = ImFloor(g.FontSize * 0.70f); float unhide_sz_hit = ImFloor(g.FontSize * 0.55f); @@ -5850,6 +5850,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) { BeginDocked(window, p_open); flags = window->Flags; + if (window->DockIsActive) + IM_ASSERT(window->DockNode != NULL); // Docking currently override constraints g.NextWindowData.Flags &= ~ImGuiNextWindowDataFlags_HasSizeConstraint; @@ -13135,7 +13137,7 @@ bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir //off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h), ImFloor(parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h)); hs_w = ImFloor(hs_for_central_nodes * 1.50f); hs_h = ImFloor(hs_for_central_nodes * 0.80f); - off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 0.0f - hs_h), ImFloor(parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 0.0f - hs_h)); + off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - hs_h), ImFloor(parent.GetHeight() * 0.5f - hs_h)); } else { diff --git a/imgui_internal.h b/imgui_internal.h index b17ebcc8..4f21d646 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1691,14 +1691,14 @@ struct IMGUI_API ImGuiWindow int MemoryDrawListVtxCapacity; // Docking - ImGuiDockNode* DockNode; // Which node are we docked into + ImGuiDockNode* DockNode; // Which node are we docked into. Important: Prefer testing DockIsActive in many cases as this will still be set when the dock node is hidden. ImGuiDockNode* DockNodeAsHost; // Which node are we owning (for parent windows) - ImGuiID DockId; // Backup of last valid DockNode->Id, so single value remember their dock node id + ImGuiID DockId; // Backup of last valid DockNode->ID, so single window remember their dock node id even when they are not bound any more ImGuiItemStatusFlags DockTabItemStatusFlags; ImRect DockTabItemRect; short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible. - bool DockIsActive :1; // =~ (DockNode != NULL) && (DockNode->Windows.Size > 1) - bool DockTabIsVisible :1; // Is the window visible this frame? =~ is the corresponding tab selected? + bool DockIsActive :1; // When docking artifacts are actually visible. When this is set, DockNode is guaranteed to be != NULL. ~~ (DockNode != NULL) && (DockNode->Windows.Size > 1). + bool DockTabIsVisible :1; // Is our window visible this frame? ~~ is the corresponding tab selected? bool DockTabWantClose :1; public: