Browse Source

Pos / Dim code cleanup

Tig 1 year ago
parent
commit
e28f73f175

+ 283 - 282
Terminal.Gui/View/Layout/Dim.cs

@@ -2,6 +2,70 @@ using System.Diagnostics;
 
 
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
+/// <summary>
+///     Specifies how <see cref="Dim.Auto"/> will compute the dimension.
+/// </summary>
+[Flags]
+public enum DimAutoStyle
+{
+    /// <summary>
+    ///     The dimension will be computed using both the view's <see cref="View.Text"/> and
+    ///     <see cref="View.Subviews"/> (whichever is larger).
+    /// </summary>
+    Auto = Content | Text,
+
+    /// <summary>
+    ///     The dimensions will be computed based on the View's non-Text 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.
+    ///     </para>
+    ///     <para>
+    ///         The corresponding dimension of the view's <see cref="View.Text"/> will be ignored.
+    ///     </para>
+    /// </summary>
+    Content = 1,
+
+    /// <summary>
+    ///     <para>
+    ///         The corresponding dimension of the view's <see cref="View.Text"/>, formatted using the
+    ///         <see cref="View.TextFormatter"/> settings,
+    ///         will be used to determine the dimension.
+    ///     </para>
+    ///     <para>
+    ///         The corresponding dimensions of the <see cref="View.Subviews"/> will be ignored.
+    ///     </para>
+    /// </summary>
+    Text = 2
+}
+
+/// <summary>
+///     Indicates the dimension for <see cref="Dim"/> operations.
+/// </summary>
+public enum Dimension
+{
+    /// <summary>
+    ///     No dimension specified.
+    /// </summary>
+    None = 0,
+
+    /// <summary>
+    ///     The height dimension.
+    /// </summary>
+    Height = 1,
+
+    /// <summary>
+    ///     The width dimension.
+    /// </summary>
+    Width = 2
+}
+
+
 /// <summary>
 /// <summary>
 ///     <para>
 ///     <para>
 ///         A Dim object describes the dimensions of a <see cref="View"/>. Dim is the type of the
 ///         A Dim object describes the dimensions of a <see cref="View"/>. Dim is the type of the
@@ -80,70 +144,6 @@ namespace Terminal.Gui;
 /// </remarks>
 /// </remarks>
 public class Dim
 public class Dim
 {
 {
-    /// <summary>
-    ///     Specifies how <see cref="Dim.Auto"/> will compute the dimension.
-    /// </summary>
-    [Flags]
-    public enum DimAutoStyle
-    {
-        /// <summary>
-        ///     The dimension will be computed using both the view's <see cref="View.Text"/> and
-        ///     <see cref="View.Subviews"/> (whichever is larger).
-        /// </summary>
-        Auto = Content | Text,
-
-        /// <summary>
-        ///     The dimensions will be computed based on the View's non-Text 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.
-        /// </para>
-        /// <para>
-        ///     The corresponding dimension of the view's <see cref="View.Text"/> will be ignored.
-        /// </para>
-        /// </summary>
-        Content = 1,
-
-        /// <summary>
-        /// <para>
-        ///     The corresponding dimension of the view's <see cref="View.Text"/>, formatted using the
-        ///     <see cref="View.TextFormatter"/> settings,
-        ///     will be used to determine the dimension.
-        /// </para>
-        /// <para>
-        ///     The corresponding dimensions of the <see cref="View.Subviews"/> will be ignored.
-        /// </para>
-        /// </summary>
-        Text = 2
-    }
-
-
-    /// <summary>
-    /// 
-    /// </summary>
-    public enum Dimension
-    {
-        /// <summary>
-        /// No dimension specified.
-        /// </summary>
-        None = 0,
-
-        /// <summary>
-        /// The height dimension.
-        /// </summary>
-        Height = 1,
-
-        /// <summary>
-        /// The width dimension.
-        /// </summary>
-        Width = 2
-    }
-
-
     /// <summary>
     /// <summary>
     ///     Creates a <see cref="Dim"/> object that automatically sizes the view to fit all the view's SubViews and/or Text.
     ///     Creates a <see cref="Dim"/> object that automatically sizes the view to fit all the view's SubViews and/or Text.
     /// </summary>
     /// </summary>
@@ -155,7 +155,7 @@ public class Dim
     /// <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.
-    /// <code>
+    ///     <code>
     /// var button = new Button () { Text = "Click Me!", X = 1, Y = 1, Width = 10, Height = 1 };
     /// var button = new Button () { Text = "Click Me!", X = 1, Y = 1, Width = 10, Height = 1 };
     /// var textField = new TextField { Text = "Type here", X = 1, Y = 2, Width = 20, Height = 1 };
     /// var textField = new TextField { Text = "Type here", X = 1, Y = 2, Width = 20, Height = 1 };
     /// var view = new Window () { Title = "MyWindow", X = 0, Y = 0, Width = Dim.Auto (), Height = Dim.Auto () };
     /// var view = new Window () { Title = "MyWindow", X = 0, Y = 0, Width = Dim.Auto (), Height = Dim.Auto () };
@@ -308,7 +308,8 @@ public class Dim
 
 
     /// <summary>
     /// <summary>
     ///     Calculates and returns the dimension of a <see cref="View"/> object. It takes into account the location of the
     ///     Calculates and returns the dimension of a <see cref="View"/> object. It takes into account the location of the
-    ///     <see cref="View"/>, it's SuperView's ContentSize, and whether it should automatically adjust its size based on its content.
+    ///     <see cref="View"/>, it's SuperView's ContentSize, and whether it should automatically adjust its size based on its
+    ///     content.
     /// </summary>
     /// </summary>
     /// <param name="location">
     /// <param name="location">
     ///     The starting point from where the size calculation begins. It could be the left edge for width calculation or the
     ///     The starting point from where the size calculation begins. It could be the left edge for width calculation or the
@@ -327,290 +328,290 @@ public class Dim
     }
     }
 
 
     /// <summary>
     /// <summary>
-    /// Diagnostics API to determine if this Dim object references other views.
+    ///     Diagnostics API to determine if this Dim object references other views.
     /// </summary>
     /// </summary>
     /// <returns></returns>
     /// <returns></returns>
-    internal virtual bool ReferencesOtherViews ()
+    internal virtual bool ReferencesOtherViews () { return false; }
+}
+
+internal class DimAbsolute (int n) : Dim
+{
+    private readonly int _n = n;
+    public override bool Equals (object other) { return other is DimAbsolute abs && abs._n == _n; }
+    public override int GetHashCode () { return _n.GetHashCode (); }
+    public override string ToString () { return $"Absolute({_n})"; }
+    internal override int Anchor (int width) { return _n; }
+
+    internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
     {
     {
-        return false;
+        // DimAbsolute.Anchor (int width) ignores width and returns n
+        return Math.Max (Anchor (0), 0);
     }
     }
+}
 
 
-    internal class DimAbsolute (int n) : Dim
-    {
-        private readonly int _n = n;
-        public override bool Equals (object other) { return other is DimAbsolute abs && abs._n == _n; }
-        public override int GetHashCode () { return _n.GetHashCode (); }
-        public override string ToString () { return $"Absolute({_n})"; }
-        internal override int Anchor (int width) { return _n; }
+/// <summary>
+///     A <see cref="Dim"/> object that automatically sizes the view to fit all the view's SubViews and/or Text.
+/// </summary>
+/// <remarks>
+///     <para>
+///         See <see cref="DimAutoStyle"/>.
+///     </para>
+/// </remarks>
+/// <param name="style">
+///     Specifies how <see cref="DimAuto"/> will compute the dimension. The default is <see cref="DimAutoStyle.Auto"/>.
+/// </param>
+/// <param name="minimumContentDim">The minimum dimension the View's ContentSize will be constrained to.</param>
+/// <param name="maximumContentDim">The maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED.</param>
+public class DimAuto (DimAutoStyle style, Dim minimumContentDim, Dim maximumContentDim) : Dim
+{
+    internal readonly Dim _minContentDim = minimumContentDim;
+    internal readonly Dim _maxContentDim = maximumContentDim;
+    internal readonly DimAutoStyle _style = style;
+    internal int _size;
 
 
-        internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
-        {
-            // DimAbsolute.Anchor (int width) ignores width and returns n
-            return Math.Max (Anchor (0), 0);
-        }
+    /// <inheritdoc/>
+    public override bool Equals (object other)
+    {
+        return other is DimAuto auto && auto._minContentDim == _minContentDim && auto._maxContentDim == _maxContentDim && auto._style == _style;
     }
     }
 
 
-    /// <summary>
-    ///     A <see cref="Dim"/> object that automatically sizes the view to fit all the view's SubViews and/or Text.
-    /// </summary>
-    /// <remarks>
-    ///     <para>
-    ///         See <see cref="Dim.DimAutoStyle"/>.
-    ///     </para>
-    /// </remarks>
-    /// <param name="style">
-    ///     Specifies how <see cref="Dim.DimAuto"/> will compute the dimension. The default is <see cref="Dim.DimAutoStyle.Auto"/>.
-    /// </param>
-    /// <param name="minimumContentDim">The minimum dimension the View's ContentSize will be constrained to.</param>
-    /// <param name="maximumContentDim">The maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED.</param>
-    public class DimAuto (DimAutoStyle style, Dim minimumContentDim, Dim maximumContentDim) : Dim
+    /// <inheritdoc/>
+    public override int GetHashCode () { return HashCode.Combine (base.GetHashCode (), _minContentDim, _maxContentDim, _style); }
+
+    /// <inheritdoc/>
+    public override string ToString () { return $"Auto({_style},{_minContentDim},{_maxContentDim})"; }
+
+    internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
     {
     {
-        internal readonly Dim _minContentDim = minimumContentDim;
-        internal readonly Dim _maxContentDim = maximumContentDim;
-        internal readonly DimAutoStyle _style = style;
-        internal int _size;
-
-        /// <inheritdoc />
-        public override bool Equals (object other) { return other is DimAuto auto && auto._minContentDim == _minContentDim && auto._maxContentDim == _maxContentDim && auto._style == _style; }
-        /// <inheritdoc />
-        public override int GetHashCode () { return HashCode.Combine (base.GetHashCode (), _minContentDim, _maxContentDim, _style); }
-        /// <inheritdoc />
-        public override string ToString () { return $"Auto({_style},{_minContentDim},{_maxContentDim})"; }
-
-        internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
+        if (us == null)
         {
         {
-            if (us == null)
-            {
-                return _maxContentDim?.Anchor (0) ?? 0;
-            }
+            return _maxContentDim?.Anchor (0) ?? 0;
+        }
 
 
-            var textSize = 0;
-            var subviewsSize = 0;
+        var textSize = 0;
+        var subviewsSize = 0;
 
 
-            int autoMin = _minContentDim?.Anchor (superviewContentSize) ?? 0;
+        int autoMin = _minContentDim?.Anchor (superviewContentSize) ?? 0;
 
 
-            if (superviewContentSize < autoMin)
-            {
-                Debug.WriteLine ($"WARNING: DimAuto specifies a min size ({autoMin}), but the SuperView's bounds are smaller ({superviewContentSize}).");
+        if (superviewContentSize < autoMin)
+        {
+            Debug.WriteLine ($"WARNING: DimAuto specifies a min size ({autoMin}), but the SuperView's bounds are smaller ({superviewContentSize}).");
 
 
-                return superviewContentSize;
-            }
+            return superviewContentSize;
+        }
+
+        if (_style.HasFlag (DimAutoStyle.Text))
+        {
+            textSize = int.Max (autoMin, dimension == Dimension.Width ? us.TextFormatter.Size.Width : us.TextFormatter.Size.Height);
+        }
 
 
-            if (_style.HasFlag (Dim.DimAutoStyle.Text))
+        if (_style.HasFlag (DimAutoStyle.Content))
+        {
+            if (us._contentSize is { })
             {
             {
-                textSize = int.Max (autoMin, dimension == Dimension.Width ? us.TextFormatter.Size.Width : us.TextFormatter.Size.Height);
+                subviewsSize = dimension == Dimension.Width ? us.ContentSize.Width : us.ContentSize.Height;
             }
             }
-
-            if (_style.HasFlag (DimAutoStyle.Content))
+            else
             {
             {
-                if (us._contentSize is { })
-                {
-                    subviewsSize = dimension == Dimension.Width ? us.ContentSize.Width : us.ContentSize.Height;
-                }
-                else
+                // TODO: AnchorEnd needs work
+                // TODO: If _min > 0 we can SetRelativeLayout for the subviews?
+                subviewsSize = 0;
+
+                if (us.Subviews.Count > 0)
                 {
                 {
-                    // TODO: AnchorEnd needs work
-                    // TODO: If _min > 0 we can SetRelativeLayout for the subviews?
-                    subviewsSize = 0;
-                    if (us.Subviews.Count > 0)
+                    for (var i = 0; i < us.Subviews.Count; i++)
                     {
                     {
-                        for (int i = 0; i < us.Subviews.Count; i++)
-                        {
-                            var v = us.Subviews [i];
-                            bool isNotPosAnchorEnd = dimension == Dim.Dimension.Width ? v.X is not PosAnchorEnd : v.Y is not PosAnchorEnd;
+                        View v = us.Subviews [i];
+                        bool isNotPosAnchorEnd = dimension == Dimension.Width ? v.X is not PosAnchorEnd : v.Y is not PosAnchorEnd;
+
+                        //if (!isNotPosAnchorEnd)
+                        //{
+                        //    v.SetRelativeLayout(dimension == Dimension.Width ? (new Size (autoMin, 0)) : new Size (0, autoMin));
+                        //}
 
 
-                            //if (!isNotPosAnchorEnd)
-                            //{
-                            //    v.SetRelativeLayout(dimension == Dim.Dimension.Width ? (new Size (autoMin, 0)) : new Size (0, autoMin));
-                            //}
+                        if (isNotPosAnchorEnd)
+                        {
+                            int size = dimension == Dimension.Width ? v.Frame.X + v.Frame.Width : v.Frame.Y + v.Frame.Height;
 
 
-                            if (isNotPosAnchorEnd)
+                            if (size > subviewsSize)
                             {
                             {
-                                int size = dimension == Dim.Dimension.Width ? v.Frame.X + v.Frame.Width : v.Frame.Y + v.Frame.Height;
-                                if (size > subviewsSize)
-                                {
-                                    subviewsSize = size;
-                                }
+                                subviewsSize = size;
                             }
                             }
                         }
                         }
                     }
                     }
-
                 }
                 }
             }
             }
+        }
 
 
-            // All sizes here are content-relative; ignoring adornments.
-            // We take the larger of text and content.
-            int max = int.Max (textSize, subviewsSize);
+        // All sizes here are content-relative; ignoring adornments.
+        // We take the larger of text and content.
+        int max = int.Max (textSize, subviewsSize);
 
 
-            // And, if min: is set, it wins if larger
-            max = int.Max (max, autoMin);
+        // And, if min: is set, it wins if larger
+        max = int.Max (max, autoMin);
 
 
-            // Factor in adornments
-            Thickness thickness = us.GetAdornmentsThickness ();
-            if (dimension == Dimension.Width)
-            {
-                max += thickness.Horizontal;
-            }
-            else
-            {
-                max += thickness.Vertical;
-            }
+        // Factor in adornments
+        Thickness thickness = us.GetAdornmentsThickness ();
 
 
-            // If max: is set, clamp the return - BUGBUG: Not tested
-            return int.Min (max, _maxContentDim?.Anchor (superviewContentSize) ?? superviewContentSize);
+        if (dimension == Dimension.Width)
+        {
+            max += thickness.Horizontal;
         }
         }
-
-        /// <summary>
-        /// Diagnostics API to determine if this Dim object references other views.
-        /// </summary>
-        /// <returns></returns>
-        internal override bool ReferencesOtherViews ()
+        else
         {
         {
-            // BUGBUG: This is not correct. _contentSize may be null.
-            return false;//_style.HasFlag (Dim.DimAutoStyle.Content);
+            max += thickness.Vertical;
         }
         }
 
 
+        // If max: is set, clamp the return - BUGBUG: Not tested
+        return int.Min (max, _maxContentDim?.Anchor (superviewContentSize) ?? superviewContentSize);
     }
     }
-    internal class DimCombine (bool add, Dim left, Dim right) : Dim
+
+    /// <summary>
+    ///     Diagnostics API to determine if this Dim object references other views.
+    /// </summary>
+    /// <returns></returns>
+    internal override bool ReferencesOtherViews ()
     {
     {
-        internal bool _add = add;
-        internal Dim _left = left, _right = right;
+        // BUGBUG: This is not correct. _contentSize may be null.
+        return false; //_style.HasFlag (DimAutoStyle.Content);
+    }
+}
 
 
-        public override string ToString () { return $"Combine({_left}{(_add ? '+' : '-')}{_right})"; }
+internal class DimCombine (bool add, Dim left, Dim right) : Dim
+{
+    internal bool _add = add;
+    internal Dim _left = left, _right = right;
 
 
-        internal override int Anchor (int width)
-        {
-            int la = _left.Anchor (width);
-            int ra = _right.Anchor (width);
+    public override string ToString () { return $"Combine({_left}{(_add ? '+' : '-')}{_right})"; }
 
 
-            if (_add)
-            {
-                return la + ra;
-            }
+    internal override int Anchor (int width)
+    {
+        int la = _left.Anchor (width);
+        int ra = _right.Anchor (width);
 
 
-            return la - ra;
+        if (_add)
+        {
+            return la + ra;
         }
         }
 
 
-        internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
-        {
-            int leftNewDim = _left.Calculate (location, superviewContentSize, us, dimension);
-            int rightNewDim = _right.Calculate (location, superviewContentSize, us, dimension);
+        return la - ra;
+    }
 
 
-            int newDimension;
+    internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
+    {
+        int leftNewDim = _left.Calculate (location, superviewContentSize, us, dimension);
+        int rightNewDim = _right.Calculate (location, superviewContentSize, us, dimension);
 
 
-            if (_add)
-            {
-                newDimension = leftNewDim + rightNewDim;
-            }
-            else
-            {
-                newDimension = Math.Max (0, leftNewDim - rightNewDim);
-            }
+        int newDimension;
 
 
-            return newDimension;
+        if (_add)
+        {
+            newDimension = leftNewDim + rightNewDim;
         }
         }
-
-
-        /// <summary>
-        /// Diagnostics API to determine if this Dim object references other views.
-        /// </summary>
-        /// <returns></returns>
-        internal override bool ReferencesOtherViews ()
+        else
         {
         {
-            if (_left.ReferencesOtherViews ())
-            {
-                return true;
-            }
-
-            if (_right.ReferencesOtherViews ())
-            {
-                return true;
-            }
-
-            return false;
+            newDimension = Math.Max (0, leftNewDim - rightNewDim);
         }
         }
+
+        return newDimension;
     }
     }
 
 
-    internal class DimFactor (float factor, bool remaining = false) : Dim
+    /// <summary>
+    ///     Diagnostics API to determine if this Dim object references other views.
+    /// </summary>
+    /// <returns></returns>
+    internal override bool ReferencesOtherViews ()
     {
     {
-        private readonly float _factor = factor;
-        private readonly bool _remaining = remaining;
-
-        public override bool Equals (object other) { return other is DimFactor f && f._factor == _factor && f._remaining == _remaining; }
-        public override int GetHashCode () { return _factor.GetHashCode (); }
-        public bool IsFromRemaining () { return _remaining; }
-        public override string ToString () { return $"Factor({_factor},{_remaining})"; }
-        internal override int Anchor (int width) { return (int)(width * _factor); }
+        if (_left.ReferencesOtherViews ())
+        {
+            return true;
+        }
 
 
-        internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
+        if (_right.ReferencesOtherViews ())
         {
         {
-            return _remaining ? Math.Max (Anchor (superviewContentSize - location), 0) : Anchor (superviewContentSize);
+            return true;
         }
         }
+
+        return false;
     }
     }
+}
+
+internal class DimFactor (float factor, bool remaining = false) : Dim
+{
+    private readonly float _factor = factor;
+    private readonly bool _remaining = remaining;
+
+    public override bool Equals (object other) { return other is DimFactor f && f._factor == _factor && f._remaining == _remaining; }
+    public override int GetHashCode () { return _factor.GetHashCode (); }
+    public bool IsFromRemaining () { return _remaining; }
+    public override string ToString () { return $"Factor({_factor},{_remaining})"; }
+    internal override int Anchor (int width) { return (int)(width * _factor); }
 
 
-    internal class DimFill (int margin) : Dim
+    internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
     {
     {
-        private readonly int _margin = margin;
-        public override bool Equals (object other) { return other is DimFill fill && fill._margin == _margin; }
-        public override int GetHashCode () { return _margin.GetHashCode (); }
-        public override string ToString () { return $"Fill({_margin})"; }
-        internal override int Anchor (int width) { return width - _margin; }
+        return _remaining ? Math.Max (Anchor (superviewContentSize - location), 0) : Anchor (superviewContentSize);
     }
     }
+}
+
+internal class DimFill (int margin) : Dim
+{
+    private readonly int _margin = margin;
+    public override bool Equals (object other) { return other is DimFill fill && fill._margin == _margin; }
+    public override int GetHashCode () { return _margin.GetHashCode (); }
+    public override string ToString () { return $"Fill({_margin})"; }
+    internal override int Anchor (int width) { return width - _margin; }
+}
+
+// Helper class to provide dynamic value by the execution of a function that returns an integer.
+internal class DimFunc (Func<int> n) : Dim
+{
+    private readonly Func<int> _function = n;
+    public override bool Equals (object other) { return other is DimFunc f && f._function () == _function (); }
+    public override int GetHashCode () { return _function.GetHashCode (); }
+    public override string ToString () { return $"DimFunc({_function ()})"; }
+    internal override int Anchor (int width) { return _function (); }
+}
+
+internal class DimView : Dim
+{
+    private readonly Dimension _side;
 
 
-    // Helper class to provide dynamic value by the execution of a function that returns an integer.
-    internal class DimFunc (Func<int> n) : Dim
+    internal DimView (View view, Dimension side)
     {
     {
-        private readonly Func<int> _function = n;
-        public override bool Equals (object other) { return other is DimFunc f && f._function () == _function (); }
-        public override int GetHashCode () { return _function.GetHashCode (); }
-        public override string ToString () { return $"DimFunc({_function ()})"; }
-        internal override int Anchor (int width) { return _function (); }
+        Target = view;
+        _side = side;
     }
     }
 
 
-    internal class DimView : Dim
-    {
-        private readonly Dimension _side;
+    public View Target { get; init; }
+    public override bool Equals (object other) { return other is DimView abs && abs.Target == Target; }
+    public override int GetHashCode () { return Target.GetHashCode (); }
 
 
-        internal DimView (View view, Dimension side)
+    public override string ToString ()
+    {
+        if (Target == null)
         {
         {
-            Target = view;
-            _side = side;
+            throw new NullReferenceException ();
         }
         }
 
 
-        public View Target { get; init; }
-        public override bool Equals (object other) { return other is DimView abs && abs.Target == Target; }
-        public override int GetHashCode () { return Target.GetHashCode (); }
-
-        public override string ToString ()
-        {
-            if (Target == null)
-            {
-                throw new NullReferenceException ();
-            }
-
-            string sideString = _side switch
-            {
-                Dimension.Height => "Height",
-                Dimension.Width => "Width",
-                _ => "unknown"
-            };
-
-            return $"View({sideString},{Target})";
-        }
+        string sideString = _side switch
+                            {
+                                Dimension.Height => "Height",
+                                Dimension.Width => "Width",
+                                _ => "unknown"
+                            };
 
 
-        internal override int Anchor (int width)
-        {
-            return _side switch
-            {
-                Dimension.Height => Target.Frame.Height,
-                Dimension.Width => Target.Frame.Width,
-                _ => 0
-            };
-        }
+        return $"View({sideString},{Target})";
+    }
 
 
-        internal override bool ReferencesOtherViews ()
-        {
-            return true;
-        }
+    internal override int Anchor (int width)
+    {
+        return _side switch
+               {
+                   Dimension.Height => Target.Frame.Height,
+                   Dimension.Width => Target.Frame.Width,
+                   _ => 0
+               };
     }
     }
-}
+
+    internal override bool ReferencesOtherViews () { return true; }
+}

+ 48 - 54
Terminal.Gui/View/Layout/Pos.cs

@@ -1,7 +1,31 @@
-using System.Diagnostics;
-
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
+/// <summary>
+///     Indicates the side for <see cref="Pos"/> operations.
+/// </summary>
+public enum Side
+{
+    /// <summary>
+    ///     The left (X) side of the view.
+    /// </summary>
+    Left = 0,
+
+    /// <summary>
+    ///     The top (Y) side of the view.
+    /// </summary>
+    Top = 1,
+
+    /// <summary>
+    ///     The right (X + Width) side of the view.
+    /// </summary>
+    Right = 2,
+
+    /// <summary>
+    ///     The bottom (Y + Height) side of the view.
+    /// </summary>
+    Bottom = 3
+}
+
 /// <summary>
 /// <summary>
 ///     Describes the position of a <see cref="View"/> which can be an absolute value, a percentage, centered, or
 ///     Describes the position of a <see cref="View"/> which can be an absolute value, a percentage, centered, or
 ///     relative to the ending dimension. Integer values are implicitly convertible to an absolute <see cref="Pos"/>. These
 ///     relative to the ending dimension. Integer values are implicitly convertible to an absolute <see cref="Pos"/>. These
@@ -346,11 +370,10 @@ public class Pos
     ///     that
     ///     that
     ///     is used.
     ///     is used.
     /// </returns>
     /// </returns>
-    internal virtual int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension) { return Anchor (superviewDimension); }
-
+    internal virtual int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension) { return Anchor (superviewDimension); }
 
 
     /// <summary>
     /// <summary>
-    /// Diagnostics API to determine if this Pos object references other views.
+    ///     Diagnostics API to determine if this Pos object references other views.
     /// </summary>
     /// </summary>
     /// <returns></returns>
     /// <returns></returns>
     internal virtual bool ReferencesOtherViews () { return false; }
     internal virtual bool ReferencesOtherViews () { return false; }
@@ -390,7 +413,7 @@ internal class PosAnchorEnd : Pos
         return width - _offset;
         return width - _offset;
     }
     }
 
 
-    internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension)
+    internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
     {
     {
         int newLocation = Anchor (superviewDimension);
         int newLocation = Anchor (superviewDimension);
 
 
@@ -408,7 +431,7 @@ internal class PosCenter : Pos
     public override string ToString () { return "Center"; }
     public override string ToString () { return "Center"; }
     internal override int Anchor (int width) { return width / 2; }
     internal override int Anchor (int width) { return width / 2; }
 
 
-    internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension)
+    internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
     {
     {
         int newDimension = Math.Max (dim.Calculate (0, superviewDimension, us, dimension), 0);
         int newDimension = Math.Max (dim.Calculate (0, superviewDimension, us, dimension), 0);
 
 
@@ -436,7 +459,7 @@ internal class PosCombine (bool add, Pos left, Pos right) : Pos
         return la - ra;
         return la - ra;
     }
     }
 
 
-    internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension)
+    internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
     {
     {
         int newDimension = dim.Calculate (0, superviewDimension, us, dimension);
         int newDimension = dim.Calculate (0, superviewDimension, us, dimension);
         int left = _left.Calculate (superviewDimension, dim, us, dimension);
         int left = _left.Calculate (superviewDimension, dim, us, dimension);
@@ -451,7 +474,7 @@ internal class PosCombine (bool add, Pos left, Pos right) : Pos
     }
     }
 
 
     /// <summary>
     /// <summary>
-    /// Diagnostics API to determine if this Pos object references other views.
+    ///     Diagnostics API to determine if this Pos object references other views.
     /// </summary>
     /// </summary>
     /// <returns></returns>
     /// <returns></returns>
     internal override bool ReferencesOtherViews ()
     internal override bool ReferencesOtherViews ()
@@ -489,32 +512,6 @@ internal class PosFunc (Func<int> n) : Pos
     internal override int Anchor (int width) { return _function (); }
     internal override int Anchor (int width) { return _function (); }
 }
 }
 
 
-/// <summary>
-/// Describes which side of the view to use for the position.
-/// </summary>
-public enum Side
-{
-    /// <summary>
-    /// The left (X) side of the view.
-    /// </summary>
-    Left = 0,
-
-    /// <summary>
-    /// The top (Y) side of the view.
-    /// </summary>
-    Top = 1,
-
-    /// <summary>
-    /// The right (X + Width) side of the view.
-    /// </summary>
-    Right = 2,
-
-    /// <summary>
-    /// The bottom (Y + Height) side of the view.
-    /// </summary>
-    Bottom = 3
-}
-
 internal class PosView (View view, Side side) : Pos
 internal class PosView (View view, Side side) : Pos
 {
 {
     public readonly View Target = view;
     public readonly View Target = view;
@@ -525,13 +522,13 @@ internal class PosView (View view, Side side) : Pos
     public override string ToString ()
     public override string ToString ()
     {
     {
         string sideString = side switch
         string sideString = side switch
-        {
-            Side.Left => "left",
-            Side.Top => "top",
-            Side.Right => "right",
-            Side.Bottom => "bottom",
-            _ => "unknown"
-        };
+                            {
+                                Side.Left => "left",
+                                Side.Top => "top",
+                                Side.Right => "right",
+                                Side.Bottom => "bottom",
+                                _ => "unknown"
+                            };
 
 
         if (Target == null)
         if (Target == null)
         {
         {
@@ -544,21 +541,18 @@ internal class PosView (View view, Side side) : Pos
     internal override int Anchor (int width)
     internal override int Anchor (int width)
     {
     {
         return side switch
         return side switch
-        {
-            Side.Left => Target.Frame.X,
-            Side.Top => Target.Frame.Y,
-            Side.Right => Target.Frame.Right,
-            Side.Bottom => Target.Frame.Bottom,
-            _ => 0
-        };
+               {
+                   Side.Left => Target.Frame.X,
+                   Side.Top => Target.Frame.Y,
+                   Side.Right => Target.Frame.Right,
+                   Side.Bottom => Target.Frame.Bottom,
+                   _ => 0
+               };
     }
     }
 
 
     /// <summary>
     /// <summary>
-    /// Diagnostics API to determine if this Pos object references other views.
+    ///     Diagnostics API to determine if this Pos object references other views.
     /// </summary>
     /// </summary>
     /// <returns></returns>
     /// <returns></returns>
-    internal override bool ReferencesOtherViews ()
-    {
-        return true;
-    }
+    internal override bool ReferencesOtherViews () { return true; }
 }
 }

+ 29 - 29
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -260,7 +260,7 @@ public partial class View
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
-    ///         <see cref="Dim.DimAbsolute"/> the <see cref="LayoutStyle"/> will change to <see cref="LayoutStyle.Computed"/>.
+    ///         <see cref="DimAbsolute"/> the <see cref="LayoutStyle"/> will change to <see cref="LayoutStyle.Computed"/>.
     ///     </para>
     ///     </para>
     ///     <para>The default value is <c>Dim.Sized (0)</c>.</para>
     ///     <para>The default value is <c>Dim.Sized (0)</c>.</para>
     /// </remarks>
     /// </remarks>
@@ -274,7 +274,7 @@ public partial class View
                 return;
                 return;
             }
             }
 
 
-            if (_height is Dim.DimAuto)
+            if (_height is DimAuto)
             {
             {
                 // Reset ContentSize to Viewport
                 // Reset ContentSize to Viewport
                 _contentSize = null;
                 _contentSize = null;
@@ -306,7 +306,7 @@ public partial class View
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
     ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
-    ///         <see cref="Dim.DimAbsolute"/> the <see cref="LayoutStyle"/> will change to <see cref="LayoutStyle.Computed"/>.
+    ///         <see cref="DimAbsolute"/> the <see cref="LayoutStyle"/> will change to <see cref="LayoutStyle.Computed"/>.
     ///     </para>
     ///     </para>
     ///     <para>The default value is <c>Dim.Sized (0)</c>.</para>
     ///     <para>The default value is <c>Dim.Sized (0)</c>.</para>
     /// </remarks>
     /// </remarks>
@@ -320,7 +320,7 @@ public partial class View
                 return;
                 return;
             }
             }
 
 
-            if (_width is Dim.DimAuto)
+            if (_width is DimAuto)
             {
             {
                 // Reset ContentSize to Viewport
                 // Reset ContentSize to Viewport
                 _contentSize = null;
                 _contentSize = null;
@@ -357,7 +357,7 @@ public partial class View
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
     ///         Setting this property to <see cref="LayoutStyle.Absolute"/> will cause <see cref="Frame"/> to determine the
     ///         Setting this property to <see cref="LayoutStyle.Absolute"/> will cause <see cref="Frame"/> to determine the
-    ///         size and position of the view. <see cref="X"/> and <see cref="Y"/> will be set to <see cref="Dim.DimAbsolute"/>
+    ///         size and position of the view. <see cref="X"/> and <see cref="Y"/> will be set to <see cref="DimAbsolute"/>
     ///         using <see cref="Frame"/>.
     ///         using <see cref="Frame"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
@@ -365,7 +365,7 @@ public partial class View
     ///         <see cref="LayoutSubviews"/> method to size and position of the view. If either of the <see cref="X"/> and
     ///         <see cref="LayoutSubviews"/> method to size and position of the view. If either of the <see cref="X"/> and
     ///         <see cref="Y"/> properties are `null` they will be set to <see cref="PosAbsolute"/> using the current value
     ///         <see cref="Y"/> properties are `null` they will be set to <see cref="PosAbsolute"/> using the current value
     ///         of <see cref="Frame"/>. If either of the <see cref="Width"/> and <see cref="Height"/> properties are `null`
     ///         of <see cref="Frame"/>. If either of the <see cref="Width"/> and <see cref="Height"/> properties are `null`
-    ///         they will be set to <see cref="Dim.DimAbsolute"/> using <see cref="Frame"/>.
+    ///         they will be set to <see cref="DimAbsolute"/> using <see cref="Frame"/>.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
     /// <value>The layout style.</value>
     /// <value>The layout style.</value>
@@ -375,8 +375,8 @@ public partial class View
         {
         {
             if (_x is PosAbsolute
             if (_x is PosAbsolute
                 && _y is PosAbsolute
                 && _y is PosAbsolute
-                && _width is Dim.DimAbsolute
-                && _height is Dim.DimAbsolute)
+                && _width is DimAbsolute
+                && _height is DimAbsolute)
             {
             {
                 return LayoutStyle.Absolute;
                 return LayoutStyle.Absolute;
             }
             }
@@ -806,26 +806,26 @@ public partial class View
         CheckDimAuto ();
         CheckDimAuto ();
         int newX, newW, newY, newH;
         int newX, newW, newY, newH;
 
 
-        if (_width is Dim.DimAuto)
+        if (_width is DimAuto)
         {
         {
-            newW = _width.Calculate (0, superviewContentSize.Width, this, Dim.Dimension.Width);
-            newX = _x.Calculate (superviewContentSize.Width, newW, this, Dim.Dimension.Width);
+            newW = _width.Calculate (0, superviewContentSize.Width, this, Dimension.Width);
+            newX = _x.Calculate (superviewContentSize.Width, newW, this, Dimension.Width);
         }
         }
         else
         else
         {
         {
-            newX = _x.Calculate (superviewContentSize.Width, _width, this, Dim.Dimension.Width);
-            newW = _width.Calculate (newX, superviewContentSize.Width, this, Dim.Dimension.Width);
+            newX = _x.Calculate (superviewContentSize.Width, _width, this, Dimension.Width);
+            newW = _width.Calculate (newX, superviewContentSize.Width, this, Dimension.Width);
         }
         }
 
 
-        if (_height is Dim.DimAuto)
+        if (_height is DimAuto)
         {
         {
-            newH = _height.Calculate (0, superviewContentSize.Height, this, Dim.Dimension.Height);
-            newY = _y.Calculate (superviewContentSize.Height, newH, this, Dim.Dimension.Height);
+            newH = _height.Calculate (0, superviewContentSize.Height, this, Dimension.Height);
+            newY = _y.Calculate (superviewContentSize.Height, newH, this, Dimension.Height);
         }
         }
         else
         else
         {
         {
-            newY = _y.Calculate (superviewContentSize.Height, _height, this, Dim.Dimension.Height);
-            newH = _height.Calculate (newY, superviewContentSize.Height, this, Dim.Dimension.Height);
+            newY = _y.Calculate (superviewContentSize.Height, _height, this, Dimension.Height);
+            newH = _height.Calculate (newY, superviewContentSize.Height, this, Dimension.Height);
         }
         }
 
 
         Rectangle newFrame = new (newX, newY, newW, newH);
         Rectangle newFrame = new (newX, newY, newW, newH);
@@ -846,12 +846,12 @@ public partial class View
                 _y = Frame.Y;
                 _y = Frame.Y;
             }
             }
 
 
-            if (_width is Dim.DimAbsolute)
+            if (_width is DimAbsolute)
             {
             {
                 _width = Frame.Width;
                 _width = Frame.Width;
             }
             }
 
 
-            if (_height is Dim.DimAbsolute)
+            if (_height is DimAbsolute)
             {
             {
                 _height = Frame.Height;
                 _height = Frame.Height;
             }
             }
@@ -889,7 +889,7 @@ public partial class View
     {
     {
         switch (dim)
         switch (dim)
         {
         {
-            case Dim.DimView dv:
+            case DimView dv:
                 // See #2461
                 // See #2461
                 //if (!from.InternalSubviews.Contains (dv.Target)) {
                 //if (!from.InternalSubviews.Contains (dv.Target)) {
                 //	throw new InvalidOperationException ($"View {dv.Target} is not a subview of {from}");
                 //	throw new InvalidOperationException ($"View {dv.Target} is not a subview of {from}");
@@ -900,7 +900,7 @@ public partial class View
                 }
                 }
 
 
                 return;
                 return;
-            case Dim.DimCombine dc:
+            case DimCombine dc:
                 CollectDim (dc._left, from, ref nNodes, ref nEdges);
                 CollectDim (dc._left, from, ref nNodes, ref nEdges);
                 CollectDim (dc._right, from, ref nNodes, ref nEdges);
                 CollectDim (dc._right, from, ref nNodes, ref nEdges);
 
 
@@ -1075,7 +1075,7 @@ public partial class View
     /// <exception cref="InvalidOperationException"></exception>
     /// <exception cref="InvalidOperationException"></exception>
     private void CheckDimAuto ()
     private void CheckDimAuto ()
     {
     {
-        if (!ValidatePosDim || !IsInitialized || (Width is not Dim.DimAuto && Height is not Dim.DimAuto))
+        if (!ValidatePosDim || !IsInitialized || (Width is not DimAuto && Height is not DimAuto))
         {
         {
             return;
             return;
         }
         }
@@ -1083,13 +1083,13 @@ public partial class View
         // Verify none of the subviews are using Dim objects that depend on the SuperView's dimensions.
         // Verify none of the subviews are using Dim objects that depend on the SuperView's dimensions.
         foreach (View view in Subviews)
         foreach (View view in Subviews)
         {
         {
-            if (Width is Dim.DimAuto { _minContentDim: null })
+            if (Width is DimAuto { _minContentDim: null })
             {
             {
                 ThrowInvalid (view, view.Width, nameof (view.Width));
                 ThrowInvalid (view, view.Width, nameof (view.Width));
                 ThrowInvalid (view, view.X, nameof (view.X));
                 ThrowInvalid (view, view.X, nameof (view.X));
             }
             }
 
 
-            if (Height is Dim.DimAuto { _minContentDim: null })
+            if (Height is DimAuto { _minContentDim: null })
             {
             {
                 ThrowInvalid (view, view.Height, nameof (view.Height));
                 ThrowInvalid (view, view.Height, nameof (view.Height));
                 ThrowInvalid (view, view.Y, nameof (view.Y));
                 ThrowInvalid (view, view.Y, nameof (view.Y));
@@ -1116,15 +1116,15 @@ public partial class View
 
 
                     break;
                     break;
 
 
-                case Dim dim and not Dim.DimAbsolute and not Dim.DimView and not Dim.DimCombine:
+                case Dim dim and not DimAbsolute and not DimView and not DimCombine:
                     bad = dim;
                     bad = dim;
 
 
                     break;
                     break;
 
 
-                case Dim dim and Dim.DimCombine:
+                case Dim dim and DimCombine:
                     // Recursively check for not Absolute or not View
                     // Recursively check for not Absolute or not View
-                    ThrowInvalid (view, (dim as Dim.DimCombine)._left, name);
-                    ThrowInvalid (view, (dim as Dim.DimCombine)._right, name);
+                    ThrowInvalid (view, (dim as DimCombine)._left, name);
+                    ThrowInvalid (view, (dim as DimCombine)._right, name);
 
 
                     break;
                     break;
             }
             }

+ 7 - 7
Terminal.Gui/View/ViewContent.cs

@@ -144,7 +144,7 @@ public partial class View
     ///         to the user. This enables virtual scrolling.
     ///         to the user. This enables virtual scrolling.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         If not <see langword="null"/>, <see cref="ContentSize"/> is set to the passed value and the behavior of <see cref="Dim.DimAutoStyle.Content"/> will be to use the ContentSize
+    ///         If not <see langword="null"/>, <see cref="ContentSize"/> is set to the passed value and the behavior of <see cref="DimAutoStyle.Content"/> will be to use the ContentSize
     ///         to determine the size of the view.
     ///         to determine the size of the view.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
@@ -335,11 +335,11 @@ public partial class View
             //    // The Frame has not been set yet (e.g. the view has not been added to a SuperView yet).
             //    // The Frame has not been set yet (e.g. the view has not been added to a SuperView yet).
             //    // 
             //    // 
             //    // Use _width & _height instead of Width & Height to avoid debug spew
             //    // Use _width & _height instead of Width & Height to avoid debug spew
-            //    Dim.DimAuto widthAuto = _width as Dim.DimAuto;
-            //    Dim.DimAuto heightAuto = _height as Dim.DimAuto;
+            //    DimAuto widthAuto = _width as DimAuto;
+            //    DimAuto heightAuto = _height as DimAuto;
 
 
-            //    if ((widthAuto is { } && widthAuto._style.HasFlag (Dim.DimAutoStyle.Text))
-            //        || (heightAuto is { } && heightAuto._style.HasFlag (Dim.DimAutoStyle.Text)))
+            //    if ((widthAuto is { } && widthAuto._style.HasFlag (DimAutoStyle.Text))
+            //        || (heightAuto is { } && heightAuto._style.HasFlag (DimAutoStyle.Text)))
             //    {
             //    {
             //        //if (TextFormatter.NeedsFormat)
             //        //if (TextFormatter.NeedsFormat)
             //        {
             //        {
@@ -347,12 +347,12 @@ public partial class View
             //            TextFormatter.AutoSize = false;
             //            TextFormatter.AutoSize = false;
 
 
             //            var size = TextFormatter.GetAutoSize ();
             //            var size = TextFormatter.GetAutoSize ();
-            //            if (widthAuto is null || !widthAuto._style.HasFlag (Dim.DimAutoStyle.Text))
+            //            if (widthAuto is null || !widthAuto._style.HasFlag (DimAutoStyle.Text))
             //            {
             //            {
             //                size.Width = _width.Anchor (0);
             //                size.Width = _width.Anchor (0);
             //            }
             //            }
 
 
-            //            if (heightAuto is null || !heightAuto._style.HasFlag (Dim.DimAutoStyle.Text))
+            //            if (heightAuto is null || !heightAuto._style.HasFlag (DimAutoStyle.Text))
             //            {
             //            {
             //                size.Height = _height.Anchor (0);
             //                size.Height = _height.Anchor (0);
             //            }
             //            }

+ 10 - 10
Terminal.Gui/View/ViewText.cs

@@ -40,7 +40,7 @@ public partial class View
     ///         The text will word-wrap to additional lines if it does not fit horizontally. If <see cref="ContentSize"/>'s height
     ///         The text will word-wrap to additional lines if it does not fit horizontally. If <see cref="ContentSize"/>'s height
     ///         is 1, the text will be clipped.
     ///         is 1, the text will be clipped.
     ///     </para>
     ///     </para>
-    ///     <para>If <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="Dim.DimAutoStyle.Text"/>,
+    ///     <para>If <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>,
     ///     the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     ///     the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     ///     <para>When the text changes, the <see cref="TextChanged"/> is fired.</para>
     ///     <para>When the text changes, the <see cref="TextChanged"/> is fired.</para>
     /// </remarks>
     /// </remarks>
@@ -84,7 +84,7 @@ public partial class View
     ///     redisplay the <see cref="View"/>.
     ///     redisplay the <see cref="View"/>.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
-    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="Dim.DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
+    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     /// </remarks>
     /// </remarks>
     /// <value>The text alignment.</value>
     /// <value>The text alignment.</value>
     public virtual TextAlignment TextAlignment
     public virtual TextAlignment TextAlignment
@@ -103,7 +103,7 @@ public partial class View
     ///     <see cref="View"/>.
     ///     <see cref="View"/>.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
-    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="Dim.DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
+    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     /// </remarks>
     /// </remarks>
     /// <value>The text alignment.</value>
     /// <value>The text alignment.</value>
     public virtual TextDirection TextDirection
     public virtual TextDirection TextDirection
@@ -127,7 +127,7 @@ public partial class View
     ///     the <see cref="View"/>.
     ///     the <see cref="View"/>.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
-    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="Dim.DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
+    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     /// </remarks>
     /// </remarks>
     /// <value>The text alignment.</value>
     /// <value>The text alignment.</value>
     public virtual VerticalTextAlignment VerticalTextAlignment
     public virtual VerticalTextAlignment VerticalTextAlignment
@@ -184,19 +184,19 @@ public partial class View
 
 
         // TODO: This is a hack. Figure out how to move this into DimDimAuto
         // TODO: This is a hack. Figure out how to move this into DimDimAuto
         // Use _width & _height instead of Width & Height to avoid debug spew
         // Use _width & _height instead of Width & Height to avoid debug spew
-        Dim.DimAuto widthAuto = _width as Dim.DimAuto;
-        Dim.DimAuto heightAuto = _height as Dim.DimAuto;
-        if ((widthAuto is { } && widthAuto._style.HasFlag (Dim.DimAutoStyle.Text))
-            || (heightAuto is { } && heightAuto._style.HasFlag (Dim.DimAutoStyle.Text)))
+        DimAuto widthAuto = _width as DimAuto;
+        DimAuto heightAuto = _height as DimAuto;
+        if ((widthAuto is { } && widthAuto._style.HasFlag (DimAutoStyle.Text))
+            || (heightAuto is { } && heightAuto._style.HasFlag (DimAutoStyle.Text)))
         {
         {
             size = TextFormatter.GetAutoSize ();
             size = TextFormatter.GetAutoSize ();
 
 
-            if (widthAuto is null || !widthAuto._style.HasFlag (Dim.DimAutoStyle.Text))
+            if (widthAuto is null || !widthAuto._style.HasFlag (DimAutoStyle.Text))
             {
             {
                 size.Width = ContentSize.Width;
                 size.Width = ContentSize.Width;
             }
             }
 
 
-            if (heightAuto is null || !heightAuto._style.HasFlag (Dim.DimAutoStyle.Text))
+            if (heightAuto is null || !heightAuto._style.HasFlag (DimAutoStyle.Text))
             {
             {
                 size.Height = ContentSize.Height;
                 size.Height = ContentSize.Height;
             }
             }

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

@@ -45,8 +45,8 @@ public class Button : View
         _leftDefault = Glyphs.LeftDefaultIndicator;
         _leftDefault = Glyphs.LeftDefaultIndicator;
         _rightDefault = Glyphs.RightDefaultIndicator;
         _rightDefault = Glyphs.RightDefaultIndicator;
 
 
-        Width = Dim.Auto (Dim.DimAutoStyle.Text);
-        Height = Dim.Auto (Dim.DimAutoStyle.Text, minimumContentDim: 1);
+        Width = Dim.Auto (DimAutoStyle.Text);
+        Height = Dim.Auto (DimAutoStyle.Text, minimumContentDim: 1);
 
 
         CanFocus = true;
         CanFocus = true;
         HighlightStyle |= HighlightStyle.Pressed;
         HighlightStyle |= HighlightStyle.Pressed;

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

@@ -20,8 +20,8 @@ public class CheckBox : View
         _charChecked = Glyphs.Checked;
         _charChecked = Glyphs.Checked;
         _charUnChecked = Glyphs.UnChecked;
         _charUnChecked = Glyphs.UnChecked;
 
 
-        Width = Dim.Auto (Dim.DimAutoStyle.Text);
-        Height = Dim.Auto (Dim.DimAutoStyle.Text, minimumContentDim: 1);
+        Width = Dim.Auto (DimAutoStyle.Text);
+        Height = Dim.Auto (DimAutoStyle.Text, minimumContentDim: 1);
 
 
         CanFocus = true;
         CanFocus = true;
 
 

+ 1 - 1
Terminal.Gui/Views/ComboBox.cs

@@ -607,7 +607,7 @@ public class ComboBox : View
 
 
     private void ProcessLayout ()
     private void ProcessLayout ()
     {
     {
-        if (Viewport.Height < _minimumHeight && (Height is null || Height is Dim.DimAbsolute))
+        if (Viewport.Height < _minimumHeight && (Height is null || Height is DimAbsolute))
         {
         {
             Height = _minimumHeight;
             Height = _minimumHeight;
         }
         }

+ 3 - 5
Terminal.Gui/Views/Label.cs

@@ -1,6 +1,4 @@
-using System.Reflection.Metadata.Ecma335;
-
-namespace Terminal.Gui;
+namespace Terminal.Gui;
 
 
 /// <summary>
 /// <summary>
 ///     The Label <see cref="View"/> displays a string at a given position and supports multiple lines separated by
 ///     The Label <see cref="View"/> displays a string at a given position and supports multiple lines separated by
@@ -15,8 +13,8 @@ public class Label : View
     /// <inheritdoc/>
     /// <inheritdoc/>
     public Label ()
     public Label ()
     {
     {
-        Height = Dim.Auto (Dim.DimAutoStyle.Text);
-        Width = Dim.Auto (Dim.DimAutoStyle.Text);
+        Height = Dim.Auto (DimAutoStyle.Text);
+        Width = Dim.Auto (DimAutoStyle.Text);
 
 
         // Things this view knows how to do
         // Things this view knows how to do
         AddCommand (Command.HotKey, FocusNext);
         AddCommand (Command.HotKey, FocusNext);

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

@@ -282,8 +282,8 @@ public class ProgressBar : View
 
 
     private void SetInitialProperties ()
     private void SetInitialProperties ()
     {
     {
-        Width = Dim.Auto (Dim.DimAutoStyle.Content);
-        Height = Dim.Auto (Dim.DimAutoStyle.Content, minimumContentDim: 1);
+        Width = Dim.Auto (DimAutoStyle.Content);
+        Height = Dim.Auto (DimAutoStyle.Content, minimumContentDim: 1);
         CanFocus = false;
         CanFocus = false;
         _fraction = 0;
         _fraction = 0;
         Initialized += ProgressBar_Initialized;
         Initialized += ProgressBar_Initialized;

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

@@ -18,8 +18,8 @@ public class RadioGroup : View
     {
     {
         CanFocus = true;
         CanFocus = true;
 
 
-        Width = Dim.Auto (Dim.DimAutoStyle.Content);
-        Height = Dim.Auto (Dim.DimAutoStyle.Content);
+        Width = Dim.Auto (DimAutoStyle.Content);
+        Height = Dim.Auto (DimAutoStyle.Content);
 
 
         // Things this view knows how to do
         // Things this view knows how to do
         AddCommand (
         AddCommand (

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

@@ -242,8 +242,8 @@ public class Slider<T> : View
         Orientation orientation = Orientation.Horizontal
         Orientation orientation = Orientation.Horizontal
     )
     )
     {
     {
-        Width = Dim.Auto (Dim.DimAutoStyle.Content);
-        Height = Dim.Auto (Dim.DimAutoStyle.Content);
+        Width = Dim.Auto (DimAutoStyle.Content);
+        Height = Dim.Auto (DimAutoStyle.Content);
         CanFocus = true;
         CanFocus = true;
         CursorVisibility = CursorVisibility.Default;
         CursorVisibility = CursorVisibility.Default;
 
 
@@ -610,7 +610,7 @@ public class Slider<T> : View
     /// <summary>Adjust the dimensions of the Slider to the best value.</summary>
     /// <summary>Adjust the dimensions of the Slider to the best value.</summary>
     public void SetContentSizeBestFit ()
     public void SetContentSizeBestFit ()
     {
     {
-        if (!IsInitialized || /*!(Height is Dim.DimAuto && Width is Dim.DimAuto) || */_options.Count == 0)
+        if (!IsInitialized || /*!(Height is DimAuto && Width is DimAuto) || */_options.Count == 0)
         {
         {
             return;
             return;
         }
         }

+ 1 - 1
Terminal.Gui/Views/Toplevel.cs

@@ -418,7 +418,7 @@ public partial class Toplevel : View
         if (sb != null
         if (sb != null
             && !top.Subviews.Contains (sb)
             && !top.Subviews.Contains (sb)
             && ny + top.Frame.Height != superView.Frame.Height - (sb.Visible ? 1 : 0)
             && ny + top.Frame.Height != superView.Frame.Height - (sb.Visible ? 1 : 0)
-            && top.Height is Dim.DimFill
+            && top.Height is DimFill
             && -top.Height.Anchor (0) < 1)
             && -top.Height.Anchor (0) < 1)
         {
         {
             top.Height = Dim.Fill (sb.Visible ? 1 : 0);
             top.Height = Dim.Fill (sb.Visible ? 1 : 0);

+ 7 - 7
UICatalog/Scenarios/AllViewsTester.cs

@@ -92,7 +92,7 @@ public class AllViewsTester : Scenario
         {
         {
             X = 0,
             X = 0,
             Y = 0,
             Y = 0,
-            Width = Dim.Auto (Dim.DimAutoStyle.Content),
+            Width = Dim.Auto (DimAutoStyle.Content),
             Height = Dim.Fill (1), // for status bar
             Height = Dim.Fill (1), // for status bar
             CanFocus = false,
             CanFocus = false,
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
@@ -462,7 +462,7 @@ public class AllViewsTester : Scenario
             MessageBox.ErrorQuery ("Exception", e.Message, "Ok");
             MessageBox.ErrorQuery ("Exception", e.Message, "Ok");
         }
         }
 
 
-        if (view.Width is Dim.DimAuto)
+        if (view.Width is DimAuto)
         {
         {
             _wText.Text = $"Auto";
             _wText.Text = $"Auto";
             _wText.Enabled = false;
             _wText.Enabled = false;
@@ -473,7 +473,7 @@ public class AllViewsTester : Scenario
             _wText.Enabled = true;
             _wText.Enabled = true;
         }
         }
 
 
-        if (view.Height is Dim.DimAuto)
+        if (view.Height is DimAuto)
         {
         {
             _hText.Text = $"Auto";
             _hText.Text = $"Auto";
             _hText.Enabled = false;
             _hText.Enabled = false;
@@ -528,7 +528,7 @@ public class AllViewsTester : Scenario
         var h = view.Height.ToString ();
         var h = view.Height.ToString ();
         _wRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.Where (s => w.Contains (s)).First ());
         _wRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.Where (s => w.Contains (s)).First ());
         _hRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.Where (s => h.Contains (s)).First ());
         _hRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.Where (s => h.Contains (s)).First ());
-        if (view.Width is Dim.DimAuto)
+        if (view.Width is DimAuto)
         {
         {
             _wText.Text = $"Auto";
             _wText.Text = $"Auto";
             _wText.Enabled = false;
             _wText.Enabled = false;
@@ -539,7 +539,7 @@ public class AllViewsTester : Scenario
             _wText.Enabled = true;
             _wText.Enabled = true;
         }
         }
 
 
-        if (view.Height is Dim.DimAuto)
+        if (view.Height is DimAuto)
         {
         {
             _hText.Text = $"Auto";
             _hText.Text = $"Auto";
             _hText.Enabled = false;
             _hText.Enabled = false;
@@ -561,12 +561,12 @@ public class AllViewsTester : Scenario
             return;
             return;
         }
         }
 
 
-        if (view.Width is not Dim.DimAuto && (view.Width is null || view.Frame.Width == 0))
+        if (view.Width is not DimAuto && (view.Width is null || view.Frame.Width == 0))
         {
         {
             view.Width = Dim.Fill ();
             view.Width = Dim.Fill ();
         }
         }
 
 
-        if (view.Height is not Dim.DimAuto && (view.Height is null || view.Frame.Height == 0))
+        if (view.Height is not DimAuto && (view.Height is null || view.Frame.Height == 0))
         {
         {
             view.Height = Dim.Fill ();
             view.Height = Dim.Fill ();
         }
         }

+ 6 - 6
UICatalog/Scenarios/Sliders.cs

@@ -186,8 +186,8 @@ public class Sliders : Scenario
 
 
                                          if (e.Options.ContainsKey (3))
                                          if (e.Options.ContainsKey (3))
                                          {
                                          {
-                                             s.Width = Dim.Auto (Dim.DimAutoStyle.Content);
-                                             s.Height = Dim.Auto (Dim.DimAutoStyle.Content);
+                                             s.Width = Dim.Auto (DimAutoStyle.Content);
+                                             s.Height = Dim.Auto (DimAutoStyle.Content);
                                          }
                                          }
                                          else
                                          else
                                          {
                                          {
@@ -277,8 +277,8 @@ public class Sliders : Scenario
 
 
                                                             if (optionsSlider.GetSetOptions ().Contains (3))
                                                             if (optionsSlider.GetSetOptions ().Contains (3))
                                                             {
                                                             {
-                                                                s.Width = Dim.Auto (Dim.DimAutoStyle.Content);
-                                                                s.Height = Dim.Auto (Dim.DimAutoStyle.Content);
+                                                                s.Width = Dim.Auto (DimAutoStyle.Content);
+                                                                s.Height = Dim.Auto (DimAutoStyle.Content);
                                                             }
                                                             }
                                                             else
                                                             else
                                                             {
                                                             {
@@ -334,8 +334,8 @@ public class Sliders : Scenario
 
 
                                                              if (optionsSlider.GetSetOptions ().Contains (3))
                                                              if (optionsSlider.GetSetOptions ().Contains (3))
                                                              {
                                                              {
-                                                                 s.Width = Dim.Auto (Dim.DimAutoStyle.Content);
-                                                                 s.Height = Dim.Auto (Dim.DimAutoStyle.Content);
+                                                                 s.Width = Dim.Auto (DimAutoStyle.Content);
+                                                                 s.Height = Dim.Auto (DimAutoStyle.Content);
                                                              }
                                                              }
                                                              else
                                                              else
                                                              {
                                                              {

+ 2 - 2
UnitTests/UICatalog/ScenarioTests.cs

@@ -482,12 +482,12 @@ public class ScenarioTests : TestsAllViews
                 return null;
                 return null;
             }
             }
 
 
-            if (view.Width is not Dim.DimAuto)
+            if (view.Width is not DimAuto)
             {
             {
                 view.Width = Dim.Percent (75);
                 view.Width = Dim.Percent (75);
             }
             }
 
 
-            if (view.Height is not Dim.DimAuto)
+            if (view.Height is not DimAuto)
             {
             {
                 view.Height = Dim.Percent (75);
                 view.Height = Dim.Percent (75);
             }
             }

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

@@ -451,7 +451,7 @@ public class DimAutoTests (ITestOutputHelper output)
         subView.Height = 0;
         subView.Height = 0;
 
 
         // Tests nested Combine
         // Tests nested Combine
-        subView.Height = 5 + new Dim.DimCombine (true, 3, new Dim.DimCombine (true, Dim.Percent (10), 9));
+        subView.Height = 5 + new DimCombine (true, 3, new DimCombine (true, Dim.Percent (10), 9));
         Assert.Throws<InvalidOperationException> (() => superView.SetRelativeLayout (new (0, 0)));
         Assert.Throws<InvalidOperationException> (() => superView.SetRelativeLayout (new (0, 0)));
     }
     }
 
 
@@ -662,7 +662,7 @@ public class DimAutoTests (ITestOutputHelper output)
             Text = new string ('*', textLen),
             Text = new string ('*', textLen),
             X = subX,
             X = subX,
             Y = 0,
             Y = 0,
-            Width = Dim.Auto (Dim.DimAutoStyle.Text),
+            Width = Dim.Auto (DimAutoStyle.Text),
             Height = 1,
             Height = 1,
             ValidatePosDim = true
             ValidatePosDim = true
         };
         };
@@ -701,7 +701,7 @@ public class DimAutoTests (ITestOutputHelper output)
         {
         {
             X = subX,
             X = subX,
             Y = 0,
             Y = 0,
-            Width = Dim.Auto (Dim.DimAutoStyle.Content),
+            Width = Dim.Auto (DimAutoStyle.Content),
             Height = 1,
             Height = 1,
             ValidatePosDim = true
             ValidatePosDim = true
         };
         };
@@ -965,9 +965,9 @@ public class DimAutoTests (ITestOutputHelper output)
         var view = new View ();
         var view = new View ();
         view.SetContentSize (new (10, 5));
         view.SetContentSize (new (10, 5));
 
 
-        var dim = Dim.Auto (Dim.DimAutoStyle.Content);
+        var dim = Dim.Auto (DimAutoStyle.Content);
 
 
-        int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
+        int calculatedWidth = dim.Calculate (0, 100, view, Dimension.Width);
 
 
         Assert.Equal (10, calculatedWidth);
         Assert.Equal (10, calculatedWidth);
     }
     }
@@ -976,9 +976,9 @@ public class DimAutoTests (ITestOutputHelper output)
     public void DimAutoStyle_Content_IgnoresText_WhenContentSizeNotSet ()
     public void DimAutoStyle_Content_IgnoresText_WhenContentSizeNotSet ()
     {
     {
         var view = new View () { Text = "This is a test" };
         var view = new View () { Text = "This is a test" };
-        var dim = Dim.Auto (Dim.DimAutoStyle.Content);
+        var dim = Dim.Auto (DimAutoStyle.Content);
 
 
-        int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
+        int calculatedWidth = dim.Calculate (0, 100, view, Dimension.Width);
 
 
         Assert.Equal (0, calculatedWidth); // Assuming 0 is the default when no ContentSize or Subviews are set
         Assert.Equal (0, calculatedWidth); // Assuming 0 is the default when no ContentSize or Subviews are set
     }
     }
@@ -990,9 +990,9 @@ public class DimAutoTests (ITestOutputHelper output)
         view.Add (new View () { Frame = new Rectangle (0, 0, 5, 5) }); // Smaller subview
         view.Add (new View () { Frame = new Rectangle (0, 0, 5, 5) }); // Smaller subview
         view.Add (new View () { Frame = new Rectangle (0, 0, 10, 10) }); // Larger subview
         view.Add (new View () { Frame = new Rectangle (0, 0, 10, 10) }); // Larger subview
 
 
-        var dim = Dim.Auto (Dim.DimAutoStyle.Content);
+        var dim = Dim.Auto (DimAutoStyle.Content);
 
 
-        int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
+        int calculatedWidth = dim.Calculate (0, 100, view, Dimension.Width);
 
 
         Assert.Equal (10, calculatedWidth); // Expecting the size of the largest subview
         Assert.Equal (10, calculatedWidth); // Expecting the size of the largest subview
     }
     }
@@ -1016,10 +1016,10 @@ public class DimAutoTests (ITestOutputHelper output)
         };
         };
         view.Add (subview);
         view.Add (subview);
 
 
-        var dim = Dim.Auto (Dim.DimAutoStyle.Content);
+        var dim = Dim.Auto (DimAutoStyle.Content);
 
 
-        int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
-        int calculatedHeight = dim.Calculate (0, 100, view, Dim.Dimension.Height);
+        int calculatedWidth = dim.Calculate (0, 100, view, Dimension.Width);
+        int calculatedHeight = dim.Calculate (0, 100, view, Dimension.Height);
 
 
         Assert.Equal (expectedSize, calculatedWidth);
         Assert.Equal (expectedSize, calculatedWidth);
         Assert.Equal (expectedSize, calculatedHeight);
         Assert.Equal (expectedSize, calculatedHeight);
@@ -1044,10 +1044,10 @@ public class DimAutoTests (ITestOutputHelper output)
 
 
         subview.SetRelativeLayout (new (100, 100));
         subview.SetRelativeLayout (new (100, 100));
 
 
-        var dim = Dim.Auto (Dim.DimAutoStyle.Content);
+        var dim = Dim.Auto (DimAutoStyle.Content);
 
 
-        int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
-        int calculatedHeight = dim.Calculate (0, 100, view, Dim.Dimension.Height);
+        int calculatedWidth = dim.Calculate (0, 100, view, Dimension.Width);
+        int calculatedHeight = dim.Calculate (0, 100, view, Dimension.Height);
 
 
         Assert.Equal (expectedSize, calculatedWidth);
         Assert.Equal (expectedSize, calculatedWidth);
         Assert.Equal (expectedSize, calculatedHeight);
         Assert.Equal (expectedSize, calculatedHeight);
@@ -1072,11 +1072,11 @@ public class DimAutoTests (ITestOutputHelper output)
 
 
         subview.SetRelativeLayout (new (100, 100));
         subview.SetRelativeLayout (new (100, 100));
 
 
-        var dim = Dim.Auto (Dim.DimAutoStyle.Content);
+        var dim = Dim.Auto (DimAutoStyle.Content);
 
 
         // Assuming the view's size is 100x100 for calculation purposes
         // Assuming the view's size is 100x100 for calculation purposes
-        int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
-        int calculatedHeight = dim.Calculate (0, 100, view, Dim.Dimension.Height);
+        int calculatedWidth = dim.Calculate (0, 100, view, Dimension.Width);
+        int calculatedHeight = dim.Calculate (0, 100, view, Dimension.Height);
 
 
         Assert.Equal (expectedSize, calculatedWidth);
         Assert.Equal (expectedSize, calculatedWidth);
         Assert.Equal (expectedSize, calculatedHeight);
         Assert.Equal (expectedSize, calculatedHeight);
@@ -1091,10 +1091,10 @@ public class DimAutoTests (ITestOutputHelper output)
 
 
         subview.SetRelativeLayout (new (100, 100));
         subview.SetRelativeLayout (new (100, 100));
 
 
-        var dim = Dim.Auto (Dim.DimAutoStyle.Content);
+        var dim = Dim.Auto (DimAutoStyle.Content);
 
 
-        int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
-        int calculatedHeight = dim.Calculate (0, 100, view, Dim.Dimension.Height);
+        int calculatedWidth = dim.Calculate (0, 100, view, Dimension.Width);
+        int calculatedHeight = dim.Calculate (0, 100, view, Dimension.Height);
 
 
         Assert.Equal (20, calculatedWidth);
         Assert.Equal (20, calculatedWidth);
         Assert.Equal (25, calculatedHeight);
         Assert.Equal (25, calculatedHeight);
@@ -1111,10 +1111,10 @@ public class DimAutoTests (ITestOutputHelper output)
 
 
         subview.SetRelativeLayout (new (100, 100));
         subview.SetRelativeLayout (new (100, 100));
 
 
-        var dim = Dim.Auto (Dim.DimAutoStyle.Content);
+        var dim = Dim.Auto (DimAutoStyle.Content);
 
 
-        int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
-        int calculatedHeight = dim.Calculate (0, 100, view, Dim.Dimension.Height);
+        int calculatedWidth = dim.Calculate (0, 100, view, Dimension.Width);
+        int calculatedHeight = dim.Calculate (0, 100, view, Dimension.Height);
 
 
         // Expecting the size to match the subview, which is the largest
         // Expecting the size to match the subview, which is the largest
         Assert.Equal (30, calculatedWidth);
         Assert.Equal (30, calculatedWidth);
@@ -1133,8 +1133,8 @@ public class DimAutoTests (ITestOutputHelper output)
         var dimWidth = Dim.Auto ();
         var dimWidth = Dim.Auto ();
         var dimHeight = Dim.Auto ();
         var dimHeight = Dim.Auto ();
 
 
-        int calculatedWidth = dimWidth.Calculate (0, 100, view, Dim.Dimension.Width);
-        int calculatedHeight = dimHeight.Calculate (0, 100, view, Dim.Dimension.Height);
+        int calculatedWidth = dimWidth.Calculate (0, 100, view, Dimension.Width);
+        int calculatedHeight = dimHeight.Calculate (0, 100, view, Dimension.Height);
 
 
         // Expecting the size to include the subview's position and size
         // Expecting the size to include the subview's position and size
         Assert.Equal (30, calculatedWidth); // 10 (X position) + 20 (Width)
         Assert.Equal (30, calculatedWidth); // 10 (X position) + 20 (Width)
@@ -1152,8 +1152,8 @@ public class DimAutoTests (ITestOutputHelper output)
         var dimHeight = Dim.Auto ();
         var dimHeight = Dim.Auto ();
 
 
         // Assuming the calculation is done after layout
         // Assuming the calculation is done after layout
-        int calculatedWidth = dimWidth.Calculate (0, 100, view, Dim.Dimension.Width);
-        int calculatedHeight = dimHeight.Calculate (0, 100, view, Dim.Dimension.Height);
+        int calculatedWidth = dimWidth.Calculate (0, 100, view, Dimension.Width);
+        int calculatedHeight = dimHeight.Calculate (0, 100, view, Dimension.Height);
 
 
         // Expecting the size to include the subview's position as a percentage of the parent view's size plus the subview's size
         // Expecting the size to include the subview's position as a percentage of the parent view's size plus the subview's size
         Assert.Equal (70, calculatedWidth); // 50% of 100 (Width) + 20
         Assert.Equal (70, calculatedWidth); // 50% of 100 (Width) + 20
@@ -1171,8 +1171,8 @@ public class DimAutoTests (ITestOutputHelper output)
         var dimHeight = Dim.Auto ();
         var dimHeight = Dim.Auto ();
 
 
         // Assuming the calculation is done after layout
         // Assuming the calculation is done after layout
-        int calculatedWidth = dimWidth.Calculate (0, 100, view, Dim.Dimension.Width);
-        int calculatedHeight = dimHeight.Calculate (0, 100, view, Dim.Dimension.Height);
+        int calculatedWidth = dimWidth.Calculate (0, 100, view, Dimension.Width);
+        int calculatedHeight = dimHeight.Calculate (0, 100, view, Dimension.Height);
 
 
         // Expecting the size to include the subview's position at the center of the parent view plus the subview's size
         // Expecting the size to include the subview's position at the center of the parent view plus the subview's size
         Assert.Equal (70, calculatedWidth); // Centered in 100 (Width) + 20
         Assert.Equal (70, calculatedWidth); // Centered in 100 (Width) + 20
@@ -1201,8 +1201,8 @@ public class DimAutoTests (ITestOutputHelper output)
         view.Add (subview);
         view.Add (subview);
 
 
         // Assuming the calculation is done after layout
         // Assuming the calculation is done after layout
-        int calculatedWidth = dimWidth.Calculate (0, 100, view, Dim.Dimension.Width);
-        int calculatedHeight = dimHeight.Calculate (0, 100, view, Dim.Dimension.Height);
+        int calculatedWidth = dimWidth.Calculate (0, 100, view, Dimension.Width);
+        int calculatedHeight = dimHeight.Calculate (0, 100, view, Dimension.Height);
 
 
         // Expecting the size to include the subview's position at the end of the parent view minus the offset plus the subview's size
         // Expecting the size to include the subview's position at the end of the parent view minus the offset plus the subview's size
         Assert.Equal (100, calculatedWidth);
         Assert.Equal (100, calculatedWidth);

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

@@ -14,7 +14,7 @@ public class DimCombineTests (ITestOutputHelper output)
         var dim1 = new DimAbsolute (10);
         var dim1 = new DimAbsolute (10);
         var dim2 = new DimAbsolute (20);
         var dim2 = new DimAbsolute (20);
         var dim = dim1 + dim2;
         var dim = dim1 + dim2;
-        var result = dim.Calculate (0, 100, null, Dim.Dimension.None);
+        var result = dim.Calculate (0, 100, null, Dimension.None);
         Assert.Equal (30, result);
         Assert.Equal (30, result);
     }
     }
 
 

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

@@ -141,7 +141,7 @@ public class DimFillTests (ITestOutputHelper output)
     public void DimFill_Calculate_ReturnsCorrectValue ()
     public void DimFill_Calculate_ReturnsCorrectValue ()
     {
     {
         var dim = Dim.Fill ();
         var dim = Dim.Fill ();
-        var result = dim.Calculate (0, 100, null, Dim.Dimension.None);
+        var result = dim.Calculate (0, 100, null, Dimension.None);
         Assert.Equal (100, result);
         Assert.Equal (100, result);
     }
     }
 
 

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

@@ -42,7 +42,7 @@ public class DimFunctionTests (ITestOutputHelper output)
     public void DimFunction_Calculate_ReturnsCorrectValue ()
     public void DimFunction_Calculate_ReturnsCorrectValue ()
     {
     {
         var dim = new DimFunc (() => 10);
         var dim = new DimFunc (() => 10);
-        var result = dim.Calculate (0, 100, null, Dim.Dimension.None);
+        var result = dim.Calculate (0, 100, null, Dimension.None);
         Assert.Equal (10, result);
         Assert.Equal (10, result);
     }
     }
 }
 }

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

@@ -13,7 +13,7 @@ public class DimPercentTests
     public void DimFactor_Calculate_ReturnsCorrectValue ()
     public void DimFactor_Calculate_ReturnsCorrectValue ()
     {
     {
         var dim = new DimFactor (0.5f);
         var dim = new DimFactor (0.5f);
-        var result = dim.Calculate (0, 100, null, Dim.Dimension.None);
+        var result = dim.Calculate (0, 100, null, Dimension.None);
         Assert.Equal (50, result);
         Assert.Equal (50, result);
     }
     }
 
 

+ 10 - 10
UnitTests/View/Layout/Dim.Tests.cs

@@ -28,7 +28,7 @@ public class DimTests
     public void DimAbsolute_Calculate_ReturnsCorrectValue ()
     public void DimAbsolute_Calculate_ReturnsCorrectValue ()
     {
     {
         var dim = new DimAbsolute (10);
         var dim = new DimAbsolute (10);
-        var result = dim.Calculate (0, 100, null, Dim.Dimension.None);
+        var result = dim.Calculate (0, 100, null, Dimension.None);
         Assert.Equal (10, result);
         Assert.Equal (10, result);
     }
     }
 
 
@@ -38,7 +38,7 @@ public class DimTests
     {
     {
         var view = new View { Width = 10 };
         var view = new View { Width = 10 };
         var dim = new DimView (view, Dimension.Width);
         var dim = new DimView (view, Dimension.Width);
-        var result = dim.Calculate (0, 100, null, Dim.Dimension.None);
+        var result = dim.Calculate (0, 100, null, Dimension.None);
         Assert.Equal (10, result);
         Assert.Equal (10, result);
     }
     }
 
 
@@ -345,24 +345,24 @@ public class DimTests
     [TestRespondersDisposed]
     [TestRespondersDisposed]
     public void Internal_Tests ()
     public void Internal_Tests ()
     {
     {
-        var dimFactor = new Dim.DimFactor (0.10F);
+        var dimFactor = new DimFactor (0.10F);
         Assert.Equal (10, dimFactor.Anchor (100));
         Assert.Equal (10, dimFactor.Anchor (100));
 
 
-        var dimAbsolute = new Dim.DimAbsolute (10);
+        var dimAbsolute = new DimAbsolute (10);
         Assert.Equal (10, dimAbsolute.Anchor (0));
         Assert.Equal (10, dimAbsolute.Anchor (0));
 
 
-        var dimFill = new Dim.DimFill (1);
+        var dimFill = new DimFill (1);
         Assert.Equal (99, dimFill.Anchor (100));
         Assert.Equal (99, dimFill.Anchor (100));
 
 
-        var dimCombine = new Dim.DimCombine (true, dimFactor, dimAbsolute);
+        var dimCombine = new DimCombine (true, dimFactor, dimAbsolute);
         Assert.Equal (dimCombine._left, dimFactor);
         Assert.Equal (dimCombine._left, dimFactor);
         Assert.Equal (dimCombine._right, dimAbsolute);
         Assert.Equal (dimCombine._right, dimAbsolute);
         Assert.Equal (20, dimCombine.Anchor (100));
         Assert.Equal (20, dimCombine.Anchor (100));
 
 
         var view = new View { Frame = new Rectangle (20, 10, 20, 1) };
         var view = new View { Frame = new Rectangle (20, 10, 20, 1) };
-        var dimViewHeight = new Dim.DimView (view, Dimension.Height);
+        var dimViewHeight = new DimView (view, Dimension.Height);
         Assert.Equal (1, dimViewHeight.Anchor (0));
         Assert.Equal (1, dimViewHeight.Anchor (0));
-        var dimViewWidth = new Dim.DimView (view, Dimension.Width);
+        var dimViewWidth = new DimView (view, Dimension.Width);
         Assert.Equal (20, dimViewWidth.Anchor (0));
         Assert.Equal (20, dimViewWidth.Anchor (0));
 
 
         view.Dispose ();
         view.Dispose ();
@@ -584,8 +584,8 @@ public class DimTests
                        v4.Height = Auto (DimAutoStyle.Text);
                        v4.Height = Auto (DimAutoStyle.Text);
                        Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Width);
                        Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Width);
                        Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Height);
                        Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Height);
-                       Assert.Equal (11, v4.Frame.Width); // 11 is the text length and because is Dim.DimAbsolute
-                       Assert.Equal (1, v4.Frame.Height); // 1 because is Dim.DimAbsolute
+                       Assert.Equal (11, v4.Frame.Width); // 11 is the text length and because is DimAbsolute
+                       Assert.Equal (1, v4.Frame.Height); // 1 because is DimAbsolute
 
 
                        v5.Text = "Button5";
                        v5.Text = "Button5";
 
 

+ 5 - 5
UnitTests/View/TextTests.cs

@@ -1207,8 +1207,8 @@ Y
         {
         {
             Text = "01234",
             Text = "01234",
             TextDirection = TextDirection.LeftRight_TopBottom,
             TextDirection = TextDirection.LeftRight_TopBottom,
-            Width = Dim.Auto (Dim.DimAutoStyle.Text),
-            Height = Dim.Auto (Dim.DimAutoStyle.Text)
+            Width = Dim.Auto (DimAutoStyle.Text),
+            Height = Dim.Auto (DimAutoStyle.Text)
         };
         };
         Assert.Equal (new (0, 0, 5, 1), view.Frame);
         Assert.Equal (new (0, 0, 5, 1), view.Frame);
         Assert.Equal (new (0, 0, 5, 1), view.Viewport);
         Assert.Equal (new (0, 0, 5, 1), view.Viewport);
@@ -1229,7 +1229,7 @@ Y
             TextDirection = TextDirection.LeftRight_TopBottom,
             TextDirection = TextDirection.LeftRight_TopBottom,
             TextAlignment = TextAlignment.Centered,
             TextAlignment = TextAlignment.Centered,
             Width = 10,
             Width = 10,
-            Height = Dim.Auto (Dim.DimAutoStyle.Text)
+            Height = Dim.Auto (DimAutoStyle.Text)
         };
         };
         view.BeginInit ();
         view.BeginInit ();
         view.EndInit ();
         view.EndInit ();
@@ -1247,8 +1247,8 @@ Y
         {
         {
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
             Text = "01234",
             Text = "01234",
-            Width = Dim.Auto (Dim.DimAutoStyle.Text),
-            Height = Dim.Auto (Dim.DimAutoStyle.Text)
+            Width = Dim.Auto (DimAutoStyle.Text),
+            Height = Dim.Auto (DimAutoStyle.Text)
         };
         };
         Assert.Equal (new (0, 0, 1, 5), view.Frame);
         Assert.Equal (new (0, 0, 1, 5), view.Frame);
         Assert.Equal (new (0, 0, 1, 5), view.Viewport);
         Assert.Equal (new (0, 0, 1, 5), view.Viewport);

+ 8 - 8
UnitTests/Views/CheckBoxTests.cs

@@ -136,8 +136,8 @@ public class CheckBoxTests
     public void Constructors_Defaults ()
     public void Constructors_Defaults ()
     {
     {
         var ckb = new CheckBox ();
         var ckb = new CheckBox ();
-        Assert.True (ckb.Width is Dim.DimAuto);
-        Assert.True (ckb.Height is Dim.DimAuto);
+        Assert.True (ckb.Width is DimAuto);
+        Assert.True (ckb.Height is DimAuto);
         Assert.False (ckb.Checked);
         Assert.False (ckb.Checked);
         Assert.False (ckb.AllowNullChecked);
         Assert.False (ckb.AllowNullChecked);
         Assert.Equal (string.Empty, ckb.Text);
         Assert.Equal (string.Empty, ckb.Text);
@@ -146,8 +146,8 @@ public class CheckBoxTests
         Assert.Equal (new Rectangle (0, 0, 2, 1), ckb.Frame);
         Assert.Equal (new Rectangle (0, 0, 2, 1), ckb.Frame);
 
 
         ckb = new CheckBox { Text = "Test", Checked = true };
         ckb = new CheckBox { Text = "Test", Checked = true };
-        Assert.True (ckb.Width is Dim.DimAuto);
-        Assert.True (ckb.Height is Dim.DimAuto);
+        Assert.True (ckb.Width is DimAuto);
+        Assert.True (ckb.Height is DimAuto);
         Assert.True (ckb.Checked);
         Assert.True (ckb.Checked);
         Assert.False (ckb.AllowNullChecked);
         Assert.False (ckb.AllowNullChecked);
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ("Test", ckb.Text);
@@ -156,8 +156,8 @@ public class CheckBoxTests
         Assert.Equal (new Rectangle (0, 0, 6, 1), ckb.Frame);
         Assert.Equal (new Rectangle (0, 0, 6, 1), ckb.Frame);
 
 
         ckb = new CheckBox { Text = "Test", X = 1, Y = 2 };
         ckb = new CheckBox { Text = "Test", X = 1, Y = 2 };
-        Assert.True (ckb.Width is Dim.DimAuto);
-        Assert.True (ckb.Height is Dim.DimAuto);
+        Assert.True (ckb.Width is DimAuto);
+        Assert.True (ckb.Height is DimAuto);
         Assert.False (ckb.Checked);
         Assert.False (ckb.Checked);
         Assert.False (ckb.AllowNullChecked);
         Assert.False (ckb.AllowNullChecked);
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ("Test", ckb.Text);
@@ -166,8 +166,8 @@ public class CheckBoxTests
         Assert.Equal (new Rectangle (1, 2, 6, 1), ckb.Frame);
         Assert.Equal (new Rectangle (1, 2, 6, 1), ckb.Frame);
 
 
         ckb = new CheckBox { Text = "Test", X = 3, Y = 4, Checked = true };
         ckb = new CheckBox { Text = "Test", X = 3, Y = 4, Checked = true };
-        Assert.True (ckb.Width is Dim.DimAuto);
-        Assert.True (ckb.Height is Dim.DimAuto);
+        Assert.True (ckb.Width is DimAuto);
+        Assert.True (ckb.Height is DimAuto);
         Assert.True (ckb.Checked);
         Assert.True (ckb.Checked);
         Assert.False (ckb.AllowNullChecked);
         Assert.False (ckb.AllowNullChecked);
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ("Test", ckb.Text);

+ 2 - 2
UnitTests/Views/MenuBarTests.cs

@@ -180,7 +180,7 @@ public class MenuBarTests
         menuBar = new MenuBar ();
         menuBar = new MenuBar ();
         Assert.Equal (0, menuBar.X);
         Assert.Equal (0, menuBar.X);
         Assert.Equal (0, menuBar.Y);
         Assert.Equal (0, menuBar.Y);
-        Assert.IsType<Dim.DimFill> (menuBar.Width);
+        Assert.IsType<DimFill> (menuBar.Width);
         Assert.Equal (1, menuBar.Height);
         Assert.Equal (1, menuBar.Height);
         Assert.Empty (menuBar.Menus);
         Assert.Empty (menuBar.Menus);
         Assert.Equal (Colors.ColorSchemes ["Menu"], menuBar.ColorScheme);
         Assert.Equal (Colors.ColorSchemes ["Menu"], menuBar.ColorScheme);
@@ -190,7 +190,7 @@ public class MenuBarTests
         menuBar = new MenuBar { Menus = [] };
         menuBar = new MenuBar { Menus = [] };
         Assert.Equal (0, menuBar.X);
         Assert.Equal (0, menuBar.X);
         Assert.Equal (0, menuBar.Y);
         Assert.Equal (0, menuBar.Y);
-        Assert.IsType<Dim.DimFill> (menuBar.Width);
+        Assert.IsType<DimFill> (menuBar.Width);
         Assert.Equal (1, menuBar.Height);
         Assert.Equal (1, menuBar.Height);
         Assert.Empty (menuBar.Menus);
         Assert.Empty (menuBar.Menus);
         Assert.Equal (Colors.ColorSchemes ["Menu"], menuBar.ColorScheme);
         Assert.Equal (Colors.ColorSchemes ["Menu"], menuBar.ColorScheme);

+ 2 - 2
UnitTests/Views/ScrollViewTests.cs

@@ -394,8 +394,8 @@ public class ScrollViewTests
         var view = new View
         var view = new View
         {
         {
             ColorScheme = new ColorScheme { Normal = new Attribute (Color.Blue, Color.Yellow) },
             ColorScheme = new ColorScheme { Normal = new Attribute (Color.Blue, Color.Yellow) },
-            Width = Dim.Auto (Dim.DimAutoStyle.Text),
-            Height = Dim.Auto (Dim.DimAutoStyle.Text),
+            Width = Dim.Auto (DimAutoStyle.Text),
+            Height = Dim.Auto (DimAutoStyle.Text),
             Text = text
             Text = text
         };
         };
         sv.Add (view);
         sv.Add (view);

+ 6 - 6
UnitTests/Views/SliderTests.cs

@@ -156,8 +156,8 @@ public class SliderTests
         Assert.False (slider.ShowEndSpacing);
         Assert.False (slider.ShowEndSpacing);
         Assert.Equal (SliderType.Single, slider.Type);
         Assert.Equal (SliderType.Single, slider.Type);
         Assert.Equal (0, slider.InnerSpacing);
         Assert.Equal (0, slider.InnerSpacing);
-        Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Content), slider.Width);
-        Assert.Equal (Dim.Auto (Dim.DimAutoStyle.Content), slider.Height);
+        Assert.Equal (Dim.Auto (DimAutoStyle.Content), slider.Width);
+        Assert.Equal (Dim.Auto (DimAutoStyle.Content), slider.Height);
         Assert.Equal (0, slider.FocusedOption);
         Assert.Equal (0, slider.FocusedOption);
     }
     }
 
 
@@ -503,8 +503,8 @@ public class SliderTests
         {
         {
             Orientation = Orientation.Vertical,
             Orientation = Orientation.Vertical,
             Type = SliderType.Multiple,
             Type = SliderType.Multiple,
-            Width = Dim.Auto (Dim.DimAutoStyle.Content),
-            Height = Dim.Auto (Dim.DimAutoStyle.Content)
+            Width = Dim.Auto (DimAutoStyle.Content),
+            Height = Dim.Auto (DimAutoStyle.Content)
         };
         };
         view.Add (slider);
         view.Add (slider);
         view.BeginInit ();
         view.BeginInit ();
@@ -537,7 +537,7 @@ public class SliderTests
         {
         {
             Orientation = Orientation.Vertical,
             Orientation = Orientation.Vertical,
             Type = SliderType.Multiple,
             Type = SliderType.Multiple,
-            Width = Dim.Auto (Dim.DimAutoStyle.Content),
+            Width = Dim.Auto (DimAutoStyle.Content),
             Height = 10
             Height = 10
         };
         };
         view.Add (slider);
         view.Add (slider);
@@ -572,7 +572,7 @@ public class SliderTests
             Orientation = Orientation.Vertical,
             Orientation = Orientation.Vertical,
             Type = SliderType.Multiple,
             Type = SliderType.Multiple,
             Width = 10,
             Width = 10,
-            Height = Dim.Auto (Dim.DimAutoStyle.Content)
+            Height = Dim.Auto (DimAutoStyle.Content)
         };
         };
         view.Add (slider);
         view.Add (slider);
         view.BeginInit ();
         view.BeginInit ();