Просмотр исходного кода

Docking: fixed DockSpace() with ImGuiDockNodeFlags_KeepAliveOnly marking current window as written to,. (#6037)

ocornut 2 лет назад
Родитель
Сommit
824baa6a4d
2 измененных файлов с 7 добавлено и 1 удалено
  1. 3 0
      docs/CHANGELOG.txt
  2. 4 1
      imgui.cpp

+ 3 - 0
docs/CHANGELOG.txt

@@ -148,6 +148,9 @@ Docking+Viewports Branch:
 
 - Docking: Internals: fixed DockBuilderCopyDockSpace() crashing when windows not in the
   remapping list are docked on the left or top side of a split. (#6035)
+- Docking: fixed DockSpace() with ImGuiDockNodeFlags_KeepAliveOnly marking current window
+  as written to, even if it doesn't technically submit an item. This allow using KeepAliveOnly
+  from any window location. (#6037)
 - Backends: OSX: fixed typo in ImGui_ImplOSX_GetWindowSize that would cause issues when resiing
   from OS decorations, if they are enabled on secondary viewports. (#6009) [@sivu]
 - Backends: Metal: fixed secondary viewport rendering. (#6015) [@dmirty-kuzmenko]

+ 4 - 1
imgui.cpp

@@ -17218,11 +17218,12 @@ void ImGui::SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond)
 // Create an explicit dockspace node within an existing window. Also expose dock node flags and creates a CentralNode by default.
 // The Central Node is always displayed even when empty and shrink/extend according to the requested size of its neighbors.
 // DockSpace() needs to be submitted _before_ any window they can host. If you use a dockspace, submit it early in your app.
+// When ImGuiDockNodeFlags_KeepAliveOnly is set, nothing is submitted in the current window (function may be called from any location).
 ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags flags, const ImGuiWindowClass* window_class)
 {
     ImGuiContext* ctx = GImGui;
     ImGuiContext& g = *ctx;
-    ImGuiWindow* window = GetCurrentWindow();
+    ImGuiWindow* window = GetCurrentWindowRead();
     if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
         return 0;
 
@@ -17231,6 +17232,8 @@ ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags
     // If for whichever reason this is causing problem we would need to ensure that DockNodeUpdateTabBar() ends up clearing NextSelectedTabId even if SkipItems=true.
     if (window->SkipItems)
         flags |= ImGuiDockNodeFlags_KeepAliveOnly;
+    if ((flags & ImGuiDockNodeFlags_KeepAliveOnly) == 0)
+        window = GetCurrentWindow(); // call to set window->WriteAccessed = true;
 
     IM_ASSERT((flags & ImGuiDockNodeFlags_DockSpace) == 0);
     IM_ASSERT(id != 0);