diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 584ca8899..59533f896 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -1110,13 +1110,14 @@ public partial class View CheckDimAuto (); var autoSize = Size.Empty; - + if (AutoSize) { + // TODO: Nuke this from orbit once Dim.Auto is fully implemented autoSize = GetTextAutoSize (); } - int newX = _x.Calculate (superviewContentSize.Width, _width, this, Dim.Dimension.Width, autoSize.Width, AutoSize); + int newX = _x.Calculate (superviewContentSize.Width, _width, this, Dim.Dimension.Width, autoSize.Width, AutoSize); int newW = _width.Calculate (newX, superviewContentSize.Width, this, Dim.Dimension.Width, autoSize.Width, AutoSize); int newY = _y.Calculate (superviewContentSize.Height, _height, this, Dim.Dimension.Height, autoSize.Height, AutoSize); int newH = _height.Calculate (newY, superviewContentSize.Height, this, Dim.Dimension.Height, autoSize.Height, AutoSize); diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs index a9b1f3ab6..4bc673608 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -37,10 +37,10 @@ public partial class View /// to and . /// /// - /// The text will word-wrap to additional lines if it does not fit horizontally. If 's height + /// The text will word-wrap to additional lines if it does not fit horizontally. If 's height /// is 1, the text will be clipped. /// - /// If is true, the will be adjusted to fit the text. + /// If is true, the will be adjusted to fit the text. /// When the text changes, the is fired. /// public virtual string Text @@ -87,7 +87,7 @@ public partial class View /// redisplay the . /// /// - /// If is true, the will be adjusted to fit the text. + /// If is true, the will be adjusted to fit the text. /// /// The text alignment. public virtual TextAlignment TextAlignment @@ -106,7 +106,7 @@ public partial class View /// . /// /// - /// If is true, the will be adjusted to fit the text. + /// If is true, the will be adjusted to fit the text. /// /// The text alignment. public virtual TextDirection TextDirection @@ -130,7 +130,7 @@ public partial class View /// the . /// /// - /// If is true, the will be adjusted to fit the text. + /// If is true, the will be adjusted to fit the text. /// /// The text alignment. public virtual VerticalTextAlignment VerticalTextAlignment @@ -174,8 +174,9 @@ public partial class View : 0; } + // BUGBUG: This API is fundamentally broken. Text autosize should have nothing to do with what's visible (Viewport) and only ContentSize. /// - /// Gets the Frame dimensions required to fit within using the text + /// Gets the Frame dimensions required to fit within using the text /// specified by the property and accounting for any /// characters. /// @@ -257,16 +258,17 @@ public partial class View int w = Viewport.Size.Width + GetHotKeySpecifierLength (); + // TODO: This is a hack. Figure out how to move this into DimDimAuto 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); + TextFormatter.Size = new Size (SuperView?.ContentSize.Width ?? 0, SuperView?.ContentSize.Height ?? 0); } else { - TextFormatter.Size = new Size (SuperView?.Viewport.Width ?? 0, Viewport.Size.Height + GetHotKeySpecifierLength ()); + TextFormatter.Size = new Size (SuperView?.ContentSize.Width ?? 0, ContentSize.Height + GetHotKeySpecifierLength ()); } w = TextFormatter.FormatAndGetSize ().Width; @@ -276,8 +278,9 @@ public partial class View TextFormatter.Size = new Size (w, SuperView?.Viewport.Height ?? 0); } - int h = Viewport.Size.Height + GetHotKeySpecifierLength (); + int h = ContentSize.Height + GetHotKeySpecifierLength (); + // TODO: This is a hack. Figure out how to move this into DimDimAuto if (Height is Dim.DimAuto heightAuto && heightAuto._style != Dim.DimAutoStyle.Subviews) { TextFormatter.NeedsFormat = true; @@ -336,12 +339,12 @@ public partial class View throw new InvalidOperationException ("SetFrameToFitText can only be called when AutoSize is true"); } - // BUGBUG: This API is broken - should not assume Frame.Height == Viewport.Height + // BUGBUG: This API is broken - should not assume Frame.Height == ContentSize.Height // // Gets the minimum dimensions required to fit the View's , factoring in . // // The minimum dimensions required. - // if the dimensions fit within the View's , otherwise. + // if the dimensions fit within the View's , otherwise. // // Always returns if is or // if (Horizontal) or (Vertical) are not not set or zero. @@ -368,7 +371,7 @@ public partial class View case true: int colWidth = TextFormatter.GetSumMaxCharWidth (TextFormatter.Text, 0, 1); - // TODO: v2 - This uses frame.Width; it should only use Viewport + // TODO: v2 - This uses frame.Width; it should only use ContentSize if (_frame.Width < colWidth && (Width is null || (ContentSize.Width >= 0 && Width is Dim.DimAbsolute && Width.Anchor (0) >= 0 && Width.Anchor (0) < colWidth))) {