2
0
Эх сурвалжийг харах

Internals: UpdateWindowInFocusOrderList: amend a528398 to fix docking. (#3496, #4797)

ocornut 3 жил өмнө
parent
commit
248ed1b01d
2 өөрчлөгдсөн 7 нэмэгдсэн , 4 устгасан
  1. 6 4
      imgui.cpp
  2. 1 0
      imgui_internal.h

+ 6 - 4
imgui.cpp

@@ -5547,15 +5547,16 @@ static void ApplyWindowSettings(ImGuiWindow* window, ImGuiWindowSettings* settin
 static void UpdateWindowInFocusOrderList(ImGuiWindow* window, bool just_created, ImGuiWindowFlags new_flags)
 static void UpdateWindowInFocusOrderList(ImGuiWindow* window, bool just_created, ImGuiWindowFlags new_flags)
 {
 {
     ImGuiContext& g = *GImGui;
     ImGuiContext& g = *GImGui;
-    const ImGuiWindowFlags old_flags = window->Flags;
-    const bool child_flag_changed = (new_flags & ImGuiWindowFlags_ChildWindow) != (old_flags & ImGuiWindowFlags_ChildWindow);
 
 
-    if ((just_created || child_flag_changed) && !(new_flags & ImGuiWindowFlags_ChildWindow))
+    const bool new_is_explicit_child = (new_flags & ImGuiWindowFlags_ChildWindow) != 0;
+    const bool child_flag_changed = new_is_explicit_child != window->IsExplicitChild;
+    if ((just_created || child_flag_changed) && !new_is_explicit_child)
     {
     {
+        IM_ASSERT(!g.WindowsFocusOrder.contains(window));
         g.WindowsFocusOrder.push_back(window);
         g.WindowsFocusOrder.push_back(window);
         window->FocusOrder = (short)(g.WindowsFocusOrder.Size - 1);
         window->FocusOrder = (short)(g.WindowsFocusOrder.Size - 1);
     }
     }
-    else if (child_flag_changed && (new_flags & ImGuiWindowFlags_ChildWindow))
+    else if (!just_created && child_flag_changed && new_is_explicit_child)
     {
     {
         IM_ASSERT(g.WindowsFocusOrder[window->FocusOrder] == window);
         IM_ASSERT(g.WindowsFocusOrder[window->FocusOrder] == window);
         for (int n = window->FocusOrder + 1; n < g.WindowsFocusOrder.Size; n++)
         for (int n = window->FocusOrder + 1; n < g.WindowsFocusOrder.Size; n++)
@@ -5563,6 +5564,7 @@ static void UpdateWindowInFocusOrderList(ImGuiWindow* window, bool just_created,
         g.WindowsFocusOrder.erase(g.WindowsFocusOrder.Data + window->FocusOrder);
         g.WindowsFocusOrder.erase(g.WindowsFocusOrder.Data + window->FocusOrder);
         window->FocusOrder = -1;
         window->FocusOrder = -1;
     }
     }
+    window->IsExplicitChild = new_is_explicit_child;
 }
 }
 
 
 static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
 static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)

+ 1 - 0
imgui_internal.h

@@ -2189,6 +2189,7 @@ struct IMGUI_API ImGuiWindow
     bool                    Appearing;                          // Set during the frame where the window is appearing (or re-appearing)
     bool                    Appearing;                          // Set during the frame where the window is appearing (or re-appearing)
     bool                    Hidden;                             // Do not display (== HiddenFrames*** > 0)
     bool                    Hidden;                             // Do not display (== HiddenFrames*** > 0)
     bool                    IsFallbackWindow;                   // Set on the "Debug##Default" window.
     bool                    IsFallbackWindow;                   // Set on the "Debug##Default" window.
+    bool                    IsExplicitChild;                    // Set when passed _ChildWindow, left to false by BeginDocked()
     bool                    HasCloseButton;                     // Set when the window has a close button (p_open != NULL)
     bool                    HasCloseButton;                     // Set when the window has a close button (p_open != NULL)
     signed char             ResizeBorderHeld;                   // Current border being held for resize (-1: none, otherwise 0-3)
     signed char             ResizeBorderHeld;                   // Current border being held for resize (-1: none, otherwise 0-3)
     short                   BeginCount;                         // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
     short                   BeginCount;                         // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)