Fixed stuff broke by merge

This commit is contained in:
Tig
2024-04-14 22:18:05 -06:00
parent 8da54ad41d
commit cb9bafa984
2 changed files with 52 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.IO.Compression;
using static Terminal.Gui.SpinnerStyle;
namespace Terminal.Gui;
@@ -894,7 +895,24 @@ public partial class View
foreach (View v in ordered)
{
LayoutSubview (v, ContentSize);
if (v.Width is Dim.DimAuto || v.Height is Dim.DimAuto)
{
// If the view is auto-sized...
Rectangle f = v.Frame;
v._frame = new (v.Frame.X, v.Frame.Y, 0, 0);
LayoutSubview (v, Viewport.Size);
if (v.Frame != f)
{
// The subviews changed; do it again
v.LayoutNeeded = true;
LayoutSubview (v, Viewport.Size);
}
}
else
{
LayoutSubview (v, Viewport.Size);
}
}
// If the 'to' is rooted to 'from' and the layoutstyle is Computed it's a special-case.

View File

@@ -1,3 +1,5 @@
using static Terminal.Gui.SpinnerStyle;
namespace Terminal.Gui;
public partial class View
@@ -171,6 +173,7 @@ public partial class View
? Math.Max (HotKeySpecifier.GetColumns (), 0)
: 0;
}
/// <summary>
/// Gets the Frame dimensions required to fit <see cref="Text"/> within <see cref="Viewport"/> using the text
/// <see cref="NavigationDirection"/> specified by the <see cref="TextFormatter"/> property and accounting for any
@@ -251,11 +254,37 @@ public partial class View
return;
}
int w = Viewport.Size.Width + GetHotKeySpecifierLength ();
TextFormatter.Size = new (
ContentSize.Width + GetHotKeySpecifierLength (),
ContentSize.Height + GetHotKeySpecifierLength (false)
);
if (Width is Dim.DimAuto widthAuto && widthAuto._style != Dim.DimAutoStyle.Subviews)
{
if (Height is Dim.DimAuto)
{
// Both are auto.
TextFormatter.Size = new Size (SuperView?.Viewport.Width ?? 0, SuperView?.Viewport.Height ?? 0);
}
else
{
TextFormatter.Size = new Size (SuperView?.Viewport.Width ?? 0, Viewport.Size.Height + GetHotKeySpecifierLength ());
}
w = TextFormatter.FormatAndGetSize ().Width;
}
else
{
TextFormatter.Size = new Size (w, SuperView?.Viewport.Height ?? 0);
}
int h = Viewport.Size.Height + GetHotKeySpecifierLength ();
if (Height is Dim.DimAuto heightAuto && heightAuto._style != Dim.DimAutoStyle.Subviews)
{
TextFormatter.NeedsFormat = true;
h = TextFormatter.FormatAndGetSize ().Height;
}
TextFormatter.Size = new Size (w, h);
}
private bool IsValidAutoSize (out Size autoSize)