瀏覽代碼

Dim.DimAutoStyle.Subviews -> Content

Tig 1 年之前
父節點
當前提交
30a540a088

+ 24 - 5
Terminal.Gui/View/Layout/PosDim.cs

@@ -657,20 +657,33 @@ public class Dim
         ///     The dimension will be computed using both the view's <see cref="View.Text"/> and
         ///     The dimension will be computed using both the view's <see cref="View.Text"/> and
         ///     <see cref="View.Subviews"/> (whichever is larger).
         ///     <see cref="View.Subviews"/> (whichever is larger).
         /// </summary>
         /// </summary>
-        Auto = Subviews | Text,
+        Auto = Content | Text,
 
 
         /// <summary>
         /// <summary>
-        ///     The Subview in <see cref="View.Subviews"/> with the largest corresponding position plus dimension
+        ///     The dimensions will be computed based on the View's content.
+        /// <para>
+        ///     If <see cref="View.ContentSize"/> is explicitly set (is not <see langword="null"/>) then <see cref="View.ContentSize"/>
+        ///     will be used to determine the dimension.
+        /// </para>
+        /// <para>
+        ///     Otherwise, the Subview in <see cref="View.Subviews"/> with the largest corresponding position plus dimension
         ///     will determine the dimension.
         ///     will determine the dimension.
+        /// </para>
+        /// <para>
         ///     The corresponding dimension of the view's <see cref="View.Text"/> will be ignored.
         ///     The corresponding dimension of the view's <see cref="View.Text"/> will be ignored.
+        /// </para>
         /// </summary>
         /// </summary>
-        Subviews = 1,
+        Content = 1,
 
 
         /// <summary>
         /// <summary>
+        /// <para>
         ///     The corresponding dimension of the view's <see cref="View.Text"/>, formatted using the
         ///     The corresponding dimension of the view's <see cref="View.Text"/>, formatted using the
         ///     <see cref="View.TextFormatter"/> settings,
         ///     <see cref="View.TextFormatter"/> settings,
         ///     will be used to determine the dimension.
         ///     will be used to determine the dimension.
+        /// </para>
+        /// <para>
         ///     The corresponding dimensions of the <see cref="View.Subviews"/> will be ignored.
         ///     The corresponding dimensions of the <see cref="View.Subviews"/> will be ignored.
+        /// </para>
         /// </summary>
         /// </summary>
         Text = 2
         Text = 2
     }
     }
@@ -701,6 +714,12 @@ public class Dim
     /// <summary>
     /// <summary>
     ///     Creates a <see cref="Dim"/> object that automatically sizes the view to fit all of the view's SubViews and/or Text.
     ///     Creates a <see cref="Dim"/> object that automatically sizes the view to fit all of the view's SubViews and/or Text.
     /// </summary>
     /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         Tthe behavior of <see cref="DimAutoStyle.Content"/> is overridden and the size of the
+    ///         view will be based on ContentSize.
+    ///     </para>
+    /// </remarks>
     /// <example>
     /// <example>
     ///     This initializes a <see cref="View"/> with two SubViews. The view will be automatically sized to fit the two
     ///     This initializes a <see cref="View"/> with two SubViews. The view will be automatically sized to fit the two
     ///     SubViews.
     ///     SubViews.
@@ -934,7 +953,7 @@ public class Dim
                 textSize = int.Max (autoMin, dimension == Dimension.Width ? us.TextFormatter.Size.Width : us.TextFormatter.Size.Height);
                 textSize = int.Max (autoMin, dimension == Dimension.Width ? us.TextFormatter.Size.Width : us.TextFormatter.Size.Height);
             }
             }
 
 
-            if (_style.HasFlag (DimAutoStyle.Subviews))
+            if (_style.HasFlag (DimAutoStyle.Content))
             {
             {
                 if (us._contentSize is { })
                 if (us._contentSize is { })
                 {
                 {
@@ -974,7 +993,7 @@ public class Dim
         internal override bool ReferencesOtherViews ()
         internal override bool ReferencesOtherViews ()
         {
         {
             // BUGBUG: This is not correct. _contentSize may be null.
             // BUGBUG: This is not correct. _contentSize may be null.
-            return _style.HasFlag (Dim.DimAutoStyle.Subviews);
+            return _style.HasFlag (Dim.DimAutoStyle.Content);
         }
         }
 
 
     }
     }

+ 5 - 1
Terminal.Gui/View/ViewContent.cs

@@ -128,10 +128,14 @@ public partial class View
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         If a positive size is provided, <see cref="Viewport"/> describes the portion of the content currently visible
+    ///         If a size is provided, <see cref="Viewport"/> describes the portion of the content currently visible
     ///         to the view. This enables virtual scrolling.
     ///         to the view. This enables virtual scrolling.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
+    ///         If a size is provided, the behavior of <see cref="Dim.DimAutoStyle.Content"/> is overridden and the size of the
+    ///         view will be based on ContentSize.
+    ///     </para>
+    ///     <para>
     ///         Negative sizes are not supported.
     ///         Negative sizes are not supported.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>

+ 2 - 2
Terminal.Gui/Views/Slider.cs

@@ -395,8 +395,8 @@ public class Slider<T> : View
 
 
             if (value)
             if (value)
             {
             {
-                Width = Dim.Auto (Dim.DimAutoStyle.Subviews);
-                Height = Dim.Auto (Dim.DimAutoStyle.Subviews);
+                Width = Dim.Auto (Dim.DimAutoStyle.Content);
+                Height = Dim.Auto (Dim.DimAutoStyle.Content);
             }
             }
             else
             else
             {
             {

+ 2 - 2
UICatalog/Scenarios/DimAutoDemo.cs

@@ -22,8 +22,8 @@ public class DimAutoDemo : Scenario
             Title = "Type to make View grow",
             Title = "Type to make View grow",
             X = 1,
             X = 1,
             Y = 1,
             Y = 1,
-            Width = Auto (DimAutoStyle.Subviews, 40),
-            Height = Auto (DimAutoStyle.Subviews, 10)
+            Width = Auto (DimAutoStyle.Content, 40),
+            Height = Auto (DimAutoStyle.Content, 10)
         };
         };
         view.ValidatePosDim = true;
         view.ValidatePosDim = true;
 
 

+ 1 - 1
UnitTests/View/Layout/Dim.AutoTests.cs

@@ -611,7 +611,7 @@ public class DimAutoTests (ITestOutputHelper output)
         {
         {
             X = subX,
             X = subX,
             Y = 0,
             Y = 0,
-            Width = Dim.Auto (Dim.DimAutoStyle.Subviews),
+            Width = Dim.Auto (Dim.DimAutoStyle.Content),
             Height = 1,
             Height = 1,
             ValidatePosDim = true
             ValidatePosDim = true
         };
         };

+ 2 - 2
UnitTests/Views/SliderTests.cs

@@ -500,8 +500,8 @@ public class SliderTests
         {
         {
             Orientation = Orientation.Vertical,
             Orientation = Orientation.Vertical,
             Type = SliderType.Multiple,
             Type = SliderType.Multiple,
-            Width = Dim.Auto (Dim.DimAutoStyle.Subviews),
-            Height = Dim.Auto (Dim.DimAutoStyle.Subviews),
+            Width = Dim.Auto (Dim.DimAutoStyle.Content),
+            Height = Dim.Auto (Dim.DimAutoStyle.Content),
         };
         };
         view.Add (slider);
         view.Add (slider);
         view.BeginInit ();
         view.BeginInit ();