Browse Source

Begin: Moved code that calls FocusWindow() on a newly appearing window lower in the function so that Nav branch can use CursorStartPos on the first window frame. (#323)
Pushing in master because it _should_ be a no-op but I'd rather test for any issue in Begin() as soon as possible.

ocornut 9 years ago
parent
commit
ffdd7d7f17
1 changed files with 6 additions and 7 deletions
  1. 6 7
      imgui.cpp

+ 6 - 7
imgui.cpp

@@ -3918,16 +3918,10 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
         else
         else
             PushClipRect(fullscreen_rect.Min, fullscreen_rect.Max, true);
             PushClipRect(fullscreen_rect.Min, fullscreen_rect.Max, true);
 
 
-        // New windows appears in front
         if (!window_was_active)
         if (!window_was_active)
         {
         {
-            window->AutoPosLastDirection = -1;
-
-            if (!(flags & ImGuiWindowFlags_NoFocusOnAppearing))
-                if (!(flags & (ImGuiWindowFlags_ChildWindow|ImGuiWindowFlags_Tooltip)) || (flags & ImGuiWindowFlags_Popup))
-                    FocusWindow(window);
-
             // Popup first latch mouse position, will position itself when it appears next frame
             // Popup first latch mouse position, will position itself when it appears next frame
+            window->AutoPosLastDirection = -1;
             if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
             if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
                 window->PosFloat = g.IO.MousePos;
                 window->PosFloat = g.IO.MousePos;
         }
         }
@@ -4265,6 +4259,11 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
         if (window->AutoFitFramesY > 0)
         if (window->AutoFitFramesY > 0)
             window->AutoFitFramesY--;
             window->AutoFitFramesY--;
 
 
+        // New windows appears in front (we need to do that AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there)
+        if (!window_was_active && !(flags & ImGuiWindowFlags_NoFocusOnAppearing))
+            if (!(flags & (ImGuiWindowFlags_ChildWindow|ImGuiWindowFlags_Tooltip)) || (flags & ImGuiWindowFlags_Popup))
+                FocusWindow(window);
+
         // Title bar
         // Title bar
         if (!(flags & ImGuiWindowFlags_NoTitleBar))
         if (!(flags & ImGuiWindowFlags_NoTitleBar))
         {
         {