From 8639a2f9f8d6d53f4c7a221579de5871051153d9 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 25 Feb 2022 16:41:40 +0100 Subject: [PATCH] Viewports: Fixed translating a host viewport from briefly altering the size of AlwaysAutoResize windows. (#5057) --- docs/CHANGELOG.txt | 1 + imgui.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 9fd364eb405f..6186bbcb71c5 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -134,6 +134,7 @@ Docking+Viewports Branch: - Docking: Fixed floating docked nodes not being clamped into viewport workrect to stay reachable when g.ConfigWindowsMoveFromTitleBarOnly is set and multi-viewports are disabled. (#5044) +- Viewports: Fixed translating a host viewport from briefly altering the size of AlwaysAutoResize windows. (#5057) - Viewports: Fixed main viewport size not matching ImDrawData::DisplaySize for one frame during resize when multi-viewports are disabled. (#4900) diff --git a/imgui.cpp b/imgui.cpp index 35c7c9ef3556..a07004d8347f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4063,6 +4063,8 @@ void ImGui::UpdateMouseMovingWindowEndFrame() } } +// This is called during NewFrame()->UpdateViewportsNewFrame() only. +// Need to keep in sync with SetWindowPos() static void TranslateWindow(ImGuiWindow* window, const ImVec2& delta) { window->Pos += delta; @@ -4072,6 +4074,7 @@ static void TranslateWindow(ImGuiWindow* window, const ImVec2& delta) window->DC.CursorPos += delta; window->DC.CursorStartPos += delta; window->DC.CursorMaxPos += delta; + window->DC.IdealMaxPos += delta; } static void ScaleWindow(ImGuiWindow* window, float scale) @@ -7670,6 +7673,7 @@ void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) const ImVec2 old_pos = window->Pos; window->Pos = ImFloor(pos); ImVec2 offset = window->Pos - old_pos; + // FIXME: share code with TranslateWindow(), need to confirm whether the 3 rect modified by TranslateWindow() are desirable here. window->DC.CursorPos += offset; // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor window->DC.CursorMaxPos += offset; // And more importantly we need to offset CursorMaxPos/CursorStartPos this so ContentSize calculation doesn't get affected. window->DC.IdealMaxPos += offset;