2
0
Tig 1 жил өмнө
parent
commit
7dedfb83e8

+ 1 - 1
ReactiveExample/LoginView.cs

@@ -79,7 +79,7 @@ public class LoginView : Window, IViewFor<LoginViewModel>
 
         var loginProgressLabel = new Label
         {
-            AutoSize = false,  X = Pos.Left (previous), Y = Pos.Top (previous) + 1, Width = 40, Height = 1, Text = idle
+            X = Pos.Left (previous), Y = Pos.Top (previous) + 1, Width = 40, Height = 1, Text = idle
         };
 
         ViewModel

+ 1 - 1
Terminal.Gui/View/Layout/PosDim.cs

@@ -917,7 +917,7 @@ public class Dim
         }
     }
 
-    internal class DimAuto (DimAutoStyle style, Dim min, Dim max) : Dim
+    public class DimAuto (DimAutoStyle style, Dim min, Dim max) : Dim
     {
         internal readonly Dim _max = max;
         internal readonly Dim _min = min;

+ 8 - 1
Terminal.Gui/View/ViewAdornments.cs

@@ -136,7 +136,14 @@ public partial class View
     ///     <para>Gets the thickness describing the sum of the Adornments' thicknesses.</para>
     /// </summary>
     /// <returns>A thickness that describes the sum of the Adornments' thicknesses.</returns>
-    public Thickness GetAdornmentsThickness () { return Margin.Thickness + Border.Thickness + Padding.Thickness; }
+    public Thickness GetAdornmentsThickness ()
+    {
+        if (Margin is null)
+        {
+            return Thickness.Empty;
+        }
+        return Margin.Thickness + Border.Thickness + Padding.Thickness;
+    }
 
     /// <summary>Lays out the Adornments of the View.</summary>
     /// <remarks>

+ 43 - 36
UICatalog/Scenarios/AllViewsTester.cs

@@ -208,7 +208,7 @@ public class AllViewsTester : Scenario
             Title = "Size (Dim)"
         };
 
-        radioItems = new [] { "Auto", "_Percent(width)", "_Fill(width)", "_Sized(width)" };
+        radioItems = new [] { "Auto (min)", "_Percent(width)", "_Fill(width)", "_Sized(width)" };
         label = new Label { X = 0, Y = 0, Text = "Width:" };
         _sizeFrame.Add (label);
         _wRadioGroup = new RadioGroup { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
@@ -221,12 +221,13 @@ public class AllViewsTester : Scenario
                                   {
                                       switch (_wRadioGroup.SelectedItem)
                                       {
-                                          case 0:
+                                          case 1:
                                               _wVal = Math.Min (int.Parse (_wText.Text), 100);
 
                                               break;
-                                          case 1:
+                                          case 0:
                                           case 2:
+                                          case 3:
                                               _wVal = int.Parse (_wText.Text);
 
                                               break;
@@ -240,7 +241,7 @@ public class AllViewsTester : Scenario
         _sizeFrame.Add (_wText);
         _sizeFrame.Add (_wRadioGroup);
 
-        radioItems = new [] { "_Auto", "P_ercent(height)", "F_ill(height)", "Si_zed(height)" };
+        radioItems = new [] { "_Auto (min)", "P_ercent(height)", "F_ill(height)", "Si_zed(height)" };
         label = new Label { X = Pos.Right (_wRadioGroup) + 1, Y = 0, Text = "Height:" };
         _sizeFrame.Add (label);
         _hText = new TextField { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_hVal}" };
@@ -251,12 +252,13 @@ public class AllViewsTester : Scenario
                                   {
                                       switch (_hRadioGroup.SelectedItem)
                                       {
-                                          case 0:
+                                          case 1:
                                               _hVal = Math.Min (int.Parse (_hText.Text), 100);
 
                                               break;
-                                          case 1:
+                                          case 0:
                                           case 2:
+                                          case 3:
                                               _hVal = int.Parse (_hText.Text);
 
                                               break;
@@ -386,38 +388,40 @@ public class AllViewsTester : Scenario
             //view.LayoutStyle = LayoutStyle.Absolute;
 
             view.X = _xRadioGroup.SelectedItem switch
-                     {
-                         0 => Pos.Percent (_xVal),
-                         1 => Pos.AnchorEnd (),
-                         2 => Pos.Center (),
-                         3 => Pos.At (_xVal),
-                         _ => view.X
-                     };
+            {
+                0 => Pos.Percent (_xVal),
+                1 => Pos.AnchorEnd (),
+                2 => Pos.Center (),
+                3 => Pos.At (_xVal),
+                _ => view.X
+            };
 
             view.Y = _yRadioGroup.SelectedItem switch
-                     {
-                         0 => Pos.Percent (_yVal),
-                         1 => Pos.AnchorEnd (),
-                         2 => Pos.Center (),
-                         3 => Pos.At (_yVal),
-                         _ => view.Y
-                     };
+            {
+                0 => Pos.Percent (_yVal),
+                1 => Pos.AnchorEnd (),
+                2 => Pos.Center (),
+                3 => Pos.At (_yVal),
+                _ => view.Y
+            };
 
             view.Width = _wRadioGroup.SelectedItem switch
-                         {
-                             0 => Dim.Percent (_wVal),
-                             1 => Dim.Fill (_wVal),
-                             2 => Dim.Sized (_wVal),
-                             _ => view.Width
-                         };
+            {
+                0 => Dim.Auto (min: _wVal),
+                1 => Dim.Percent (_wVal),
+                2 => Dim.Fill (_wVal),
+                3 => Dim.Sized (_wVal),
+                _ => view.Width
+            };
 
             view.Height = _hRadioGroup.SelectedItem switch
-                          {
-                              0 => Dim.Percent (_hVal),
-                              1 => Dim.Fill (_hVal),
-                              2 => Dim.Sized (_hVal),
-                              _ => view.Height
-                          };
+            {
+                0 => Dim.Auto (min: _hVal),
+                1 => Dim.Percent (_hVal),
+                2 => Dim.Fill (_hVal),
+                3 => Dim.Sized (_hVal),
+                _ => view.Height
+            };
         }
         catch (Exception e)
         {
@@ -476,14 +480,17 @@ public class AllViewsTester : Scenario
     {
         var view = sender as View;
 
-        //view.X = Pos.Center ();
-        //view.Y = Pos.Center ();
-        if (view.Width == null || view.Frame.Width == 0)
+        if (view is null)
+        {
+            return;
+        }
+
+        if (view.Width is not Dim.DimAuto && (view.Width is null || view.Frame.Width == 0))
         {
             view.Width = Dim.Fill ();
         }
 
-        if (view.Height == null || view.Frame.Height == 0)
+        if (view.Width is not Dim.DimAuto && (view.Height is null || view.Frame.Height == 0))
         {
             view.Height = Dim.Fill ();
         }

+ 0 - 1
UICatalog/Scenarios/CharacterMap.cs

@@ -972,7 +972,6 @@ internal class CharMap : View
         var errorLabel = new Label
         {
             Text = UcdApiClient.BaseUrl,
-            AutoSize = false,
             X = 0,
             Y = 1,
             Width = Dim.Fill (),

+ 0 - 1
UICatalog/Scenarios/Dialogs.cs

@@ -44,7 +44,6 @@ public class Dialogs : Scenario
 
         label = new Label
         {
-            AutoSize = false,
             X = 0,
             Y = Pos.Bottom (label),
             Width = Dim.Width (numButtonsLabel),

+ 0 - 32
UnitTests/View/Layout/Dim.AutoTests.cs

@@ -850,38 +850,6 @@ public class DimAutoTests (ITestOutputHelper output)
 
         Assert.Equal (new Size (5, 1), view.ContentSize);
     }
-    [SetupFakeDriver]
-    [Fact]
-    public void DimAuto_ChangeNonDimAuto_Via_AutoSize_False_Resets_ContentSize ()
-    {
-        View view = new ()
-        {
-            Width = Auto (),
-            Height = Auto (),
-            Text = "01234"
-        };
-
-        Assert.Equal (new Rectangle (0, 0, 5, 1), view.Frame);
-        Assert.Equal (new Size (5, 1), view.ContentSize);
-
-        // Change text to a longer string
-        view.Text = "0123456789";
-
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Frame);
-        Assert.Equal (new Size (10, 1), view.ContentSize);
-
-        // Cause Width/Height to be set to absolute. This should reset ContentSize
-        view.AutoSize = false;
-
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Frame);
-        Assert.Equal (new Size (10, 1), view.ContentSize);
-
-        // If ContentSize was reset, these should cause it to update
-        view.Width = 5;
-        view.Height = 1;
-
-        Assert.Equal (new Size (5, 1), view.ContentSize);
-    }
 
     // DimAutoStyle.Content tests
     [Fact]

+ 0 - 6
UnitTests/View/Layout/Dim.Tests.cs

@@ -406,7 +406,6 @@ public class DimTests
 
         var v1 = new Button
         {
-            AutoSize = false,
             X = Pos.X (f1) + 2,
             Y = Pos.Bottom (f1) + 2,
             Width = Dim.Width (f1) - 2,
@@ -417,7 +416,6 @@ public class DimTests
 
         var v2 = new Button
         {
-            AutoSize = false,
             X = Pos.X (f2) + 2,
             Y = Pos.Bottom (f2) + 2,
             Width = Dim.Width (f2) - 2,
@@ -428,7 +426,6 @@ public class DimTests
 
         var v3 = new Button
         {
-            AutoSize = false,
             Width = Dim.Percent (10),
             Height = Dim.Percent (10),
             ValidatePosDim = true,
@@ -437,7 +434,6 @@ public class DimTests
 
         var v4 = new Button
         {
-            AutoSize = false,
             Width = Dim.Sized (50),
             Height = Dim.Sized (50),
             ValidatePosDim = true,
@@ -446,7 +442,6 @@ public class DimTests
 
         var v5 = new Button
         {
-            AutoSize = false,
             Width = Dim.Width (v1) - Dim.Width (v3),
             Height = Dim.Height (v1) - Dim.Height (v3),
             ValidatePosDim = true,
@@ -455,7 +450,6 @@ public class DimTests
 
         var v6 = new Button
         {
-            AutoSize = false,
             X = Pos.X (f2),
             Y = Pos.Bottom (f2) + 2,
             Width = Dim.Percent (20, true),