|
@@ -6173,10 +6173,18 @@ 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 size_max = (window->ViewportOwned || ((window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_Popup))) ? ImVec2(FLT_MAX, FLT_MAX) : ImGui::GetMainViewport()->WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
|
|
- const int monitor_idx = window->ViewportAllowPlatformMonitorExtend;
|
|
|
- if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0)
|
|
|
- size_max = g.PlatformIO.Monitors[monitor_idx].WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
|
|
+ ImVec2 size_max = ImVec2(FLT_MAX, FLT_MAX);
|
|
|
+
|
|
|
+ // Child windows are layed within their parent (unless they are also popups/menus) and thus have no restriction
|
|
|
+ if ((window->Flags & ImGuiWindowFlags_ChildWindow) == 0 || (window->Flags & ImGuiWindowFlags_Popup) != 0)
|
|
|
+ {
|
|
|
+ if (!window->ViewportOwned)
|
|
|
+ size_max = ImGui::GetMainViewport()->WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
|
|
+ const int monitor_idx = window->ViewportAllowPlatformMonitorExtend;
|
|
|
+ if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size)
|
|
|
+ size_max = g.PlatformIO.Monitors[monitor_idx].WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
|
|
+ }
|
|
|
+
|
|
|
ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, size_max));
|
|
|
|
|
|
// FIXME: CalcWindowAutoFitSize() doesn't take into account that only one axis may be auto-fit when calculating scrollbars,
|