From f37f6f67f657ed50b6f03d44853e1d9b9b21aa88 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 27 Nov 2023 16:33:20 +0100 Subject: [PATCH] Windows: BeginChild(): Fixed auto-resizing erroneously limiting size to host viewport minus padding. (#7063) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 9561fc95..0c945fe8 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -44,6 +44,8 @@ Breaking changes: Other changes: +- Windows: BeginChild(): Fixed auto-resizing erroneously limiting size to host viewport + minus padding. There are no limit to a child width/height. (#7063) [@Devyre] - Drag and Drop: Fixed drop target highlight on items temporarily pushing a widened clip rect (namely Selectables and Treenodes using SpanAllColumn flag) so the highlight properly covers all columns. (#7049, #4281, #3272) diff --git a/imgui.cpp b/imgui.cpp index a29f3372..34002831 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5788,8 +5788,8 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont { // Maximum window size is determined by the viewport size or monitor size ImVec2 size_min = CalcWindowMinSize(window); - ImVec2 avail_size = ImGui::GetMainViewport()->WorkSize; - ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, avail_size - style.DisplaySafeAreaPadding * 2.0f)); + ImVec2 size_max = (window->Flags & ImGuiWindowFlags_ChildWindow) ? ImVec2(FLT_MAX, FLT_MAX) : ImGui::GetMainViewport()->WorkSize - style.DisplaySafeAreaPadding * 2.0f; + ImVec2 size_auto_fit = ImClamp(size_desired, size_min, size_max); // When the window cannot fit all contents (either because of constraints, either because screen is too small), // we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding.