Selaa lähdekoodia

Fixed stuff broke by merge

Tig 1 vuosi sitten
vanhempi
commit
cb9bafa984
2 muutettua tiedostoa jossa 52 lisäystä ja 5 poistoa
  1. 19 1
      Terminal.Gui/View/Layout/ViewLayout.cs
  2. 33 4
      Terminal.Gui/View/ViewText.cs

+ 19 - 1
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -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.

+ 33 - 4
Terminal.Gui/View/ViewText.cs

@@ -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 ();
+
+        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 (
-                                  ContentSize.Width + GetHotKeySpecifierLength (),
-                                  ContentSize.Height + GetHotKeySpecifierLength (false)
-                                 );
+        TextFormatter.Size = new Size (w, h);
     }
 
     private bool IsValidAutoSize (out Size autoSize)