Tig 1 gadu atpakaļ
vecāks
revīzija
6c07532bce
2 mainītis faili ar 375 papildinājumiem un 329 dzēšanām
  1. 100 70
      Terminal.Gui/View/Layout/DimAuto.cs
  2. 275 259
      Terminal.Gui/View/Layout/ViewLayout.cs

+ 100 - 70
Terminal.Gui/View/Layout/DimAuto.cs

@@ -1,6 +1,5 @@
 #nullable enable
 #nullable enable
 using System.Diagnostics;
 using System.Diagnostics;
-using System.Drawing;
 
 
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
@@ -16,13 +15,32 @@ namespace Terminal.Gui;
 ///         methods on the <see cref="Dim"/> class to create <see cref="Dim"/> objects instead.
 ///         methods on the <see cref="Dim"/> class to create <see cref="Dim"/> objects instead.
 ///     </para>
 ///     </para>
 /// </remarks>
 /// </remarks>
-public class DimAuto () : Dim
+public class DimAuto : Dim
 {
 {
     private readonly Dim? _maximumContentDim;
     private readonly Dim? _maximumContentDim;
 
 
+    private readonly Dim? _minimumContentDim;
+
+    private readonly DimAutoStyle _style;
+
+    /// <inheritdoc/>
+    public override bool Equals (object? other)
+    {
+        if (other is not DimAuto auto)
+        {
+            return false;
+        }
+
+        return auto.MinimumContentDim == MinimumContentDim && auto.MaximumContentDim == MaximumContentDim && auto.Style == Style;
+    }
+
+    /// <inheritdoc/>
+    public override int GetHashCode () { return HashCode.Combine (MinimumContentDim, MaximumContentDim, Style); }
+
     /// <summary>
     /// <summary>
     ///     Gets the maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED.
     ///     Gets the maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED.
     /// </summary>
     /// </summary>
+
     // ReSharper disable once ConvertToAutoProperty
     // ReSharper disable once ConvertToAutoProperty
     public required Dim? MaximumContentDim
     public required Dim? MaximumContentDim
     {
     {
@@ -30,11 +48,10 @@ public class DimAuto () : Dim
         init => _maximumContentDim = value;
         init => _maximumContentDim = value;
     }
     }
 
 
-    private readonly Dim? _minimumContentDim;
-
     /// <summary>
     /// <summary>
     ///     Gets the minimum dimension the View's ContentSize will be constrained to.
     ///     Gets the minimum dimension the View's ContentSize will be constrained to.
     /// </summary>
     /// </summary>
+
     // ReSharper disable once ConvertToAutoProperty
     // ReSharper disable once ConvertToAutoProperty
     public required Dim? MinimumContentDim
     public required Dim? MinimumContentDim
     {
     {
@@ -42,11 +59,10 @@ public class DimAuto () : Dim
         init => _minimumContentDim = value;
         init => _minimumContentDim = value;
     }
     }
 
 
-    private readonly DimAutoStyle _style;
-
     /// <summary>
     /// <summary>
     ///     Gets the style of the DimAuto.
     ///     Gets the style of the DimAuto.
     /// </summary>
     /// </summary>
+
     // ReSharper disable once ConvertToAutoProperty
     // ReSharper disable once ConvertToAutoProperty
     public required DimAutoStyle Style
     public required DimAutoStyle Style
     {
     {
@@ -97,8 +113,7 @@ public class DimAuto () : Dim
             }
             }
         }
         }
 
 
-        List<View> viewsNeedingLayout = new List<View> ();
-
+        List<View> viewsNeedingLayout = new ();
 
 
         if (Style.FastHasFlags (DimAutoStyle.Content))
         if (Style.FastHasFlags (DimAutoStyle.Content))
         {
         {
@@ -110,7 +125,8 @@ public class DimAuto () : Dim
             else
             else
             {
             {
                 maxCalculatedSize = textSize;
                 maxCalculatedSize = textSize;
-                // ContentSize was NOT explicitly set. Use `us.Subviews` to determine size.
+
+                // TOOD: All the below is a naive implementation. It may be possible to optimize this.
 
 
                 List<View> includedSubviews = us.Subviews.ToList ();
                 List<View> includedSubviews = us.Subviews.ToList ();
 
 
@@ -156,9 +172,11 @@ public class DimAuto () : Dim
                 // [ ] DimAbsolute  - Dimension is fixed
                 // [ ] DimAbsolute  - Dimension is fixed
                 // [ ] DimFunc      - Dimension is internally calculated
                 // [ ] DimFunc      - Dimension is internally calculated
                 List<View> notDependentSubViews;
                 List<View> notDependentSubViews;
+
                 if (dimension == Dimension.Width)
                 if (dimension == Dimension.Width)
                 {
                 {
-                    notDependentSubViews = includedSubviews.Where (v => v.Width is { }
+                    notDependentSubViews = includedSubviews.Where (
+                                                                   v => v.Width is { }
                                                                         && (v.X is PosAbsolute or PosFunc || v.Width is DimAuto or DimAbsolute or DimFunc)
                                                                         && (v.X is PosAbsolute or PosFunc || v.Width is DimAuto or DimAbsolute or DimFunc)
                                                                         && !v.X.Has (typeof (PosAnchorEnd), out _)
                                                                         && !v.X.Has (typeof (PosAnchorEnd), out _)
                                                                         && !v.X.Has (typeof (PosAlign), out _)
                                                                         && !v.X.Has (typeof (PosAlign), out _)
@@ -167,11 +185,13 @@ public class DimAuto () : Dim
                                                                         && !v.Width.Has (typeof (DimView), out _)
                                                                         && !v.Width.Has (typeof (DimView), out _)
                                                                         && !v.Width.Has (typeof (DimFill), out _)
                                                                         && !v.Width.Has (typeof (DimFill), out _)
                                                                         && !v.Width.Has (typeof (DimPercent), out _)
                                                                         && !v.Width.Has (typeof (DimPercent), out _)
-                                                                        ).ToList ();
+                                                                  )
+                                                           .ToList ();
                 }
                 }
                 else
                 else
                 {
                 {
-                    notDependentSubViews = includedSubviews.Where (v => v.Height is { }
+                    notDependentSubViews = includedSubviews.Where (
+                                                                   v => v.Height is { }
                                                                         && (v.Y is PosAbsolute or PosFunc || v.Height is DimAuto or DimAbsolute or DimFunc)
                                                                         && (v.Y is PosAbsolute or PosFunc || v.Height is DimAuto or DimAbsolute or DimFunc)
                                                                         && !v.Y.Has (typeof (PosAnchorEnd), out _)
                                                                         && !v.Y.Has (typeof (PosAnchorEnd), out _)
                                                                         && !v.Y.Has (typeof (PosAlign), out _)
                                                                         && !v.Y.Has (typeof (PosAlign), out _)
@@ -180,14 +200,15 @@ public class DimAuto () : Dim
                                                                         && !v.Height.Has (typeof (DimView), out _)
                                                                         && !v.Height.Has (typeof (DimView), out _)
                                                                         && !v.Height.Has (typeof (DimFill), out _)
                                                                         && !v.Height.Has (typeof (DimFill), out _)
                                                                         && !v.Height.Has (typeof (DimPercent), out _)
                                                                         && !v.Height.Has (typeof (DimPercent), out _)
-                                                                        ).ToList ();
+                                                                  )
+                                                           .ToList ();
                 }
                 }
 
 
                 for (var i = 0; i < notDependentSubViews.Count; i++)
                 for (var i = 0; i < notDependentSubViews.Count; i++)
                 {
                 {
                     View v = notDependentSubViews [i];
                     View v = notDependentSubViews [i];
 
 
-                    int size = 0;
+                    var size = 0;
 
 
                     if (dimension == Dimension.Width)
                     if (dimension == Dimension.Width)
                     {
                     {
@@ -209,8 +230,10 @@ public class DimAuto () : Dim
                 // ************** We now have some idea of `us.ContentSize` ***************
                 // ************** We now have some idea of `us.ContentSize` ***************
 
 
                 #region Centered
                 #region Centered
+
                 // [ ] PosCenter    - Position is dependent `us.ContentSize` AND `subview.Frame`
                 // [ ] PosCenter    - Position is dependent `us.ContentSize` AND `subview.Frame`
                 List<View> centeredSubViews;
                 List<View> centeredSubViews;
+
                 if (dimension == Dimension.Width)
                 if (dimension == Dimension.Width)
                 {
                 {
                     centeredSubViews = us.Subviews.Where (v => v.X.Has (typeof (PosCenter), out _)).ToList ();
                     centeredSubViews = us.Subviews.Where (v => v.X.Has (typeof (PosCenter), out _)).ToList ();
@@ -222,7 +245,7 @@ public class DimAuto () : Dim
 
 
                 viewsNeedingLayout.AddRange (centeredSubViews);
                 viewsNeedingLayout.AddRange (centeredSubViews);
 
 
-                int maxCentered = 0;
+                var maxCentered = 0;
 
 
                 for (var i = 0; i < centeredSubViews.Count; i++)
                 for (var i = 0; i < centeredSubViews.Count; i++)
                 {
                 {
@@ -231,25 +254,31 @@ public class DimAuto () : Dim
                     if (dimension == Dimension.Width)
                     if (dimension == Dimension.Width)
                     {
                     {
                         int width = v.Width!.Calculate (0, screenX4, v, dimension);
                         int width = v.Width!.Calculate (0, screenX4, v, dimension);
-                        maxCentered = (v.X.GetAnchor (0) + width);
+                        maxCentered = v.X.GetAnchor (0) + width;
                     }
                     }
                     else
                     else
                     {
                     {
                         int height = v.Height!.Calculate (0, screenX4, v, dimension);
                         int height = v.Height!.Calculate (0, screenX4, v, dimension);
-                        maxCentered = (v.Y.GetAnchor (0) + height);
+                        maxCentered = v.Y.GetAnchor (0) + height;
                     }
                     }
                 }
                 }
+
                 maxCalculatedSize = int.Max (maxCalculatedSize, maxCentered);
                 maxCalculatedSize = int.Max (maxCalculatedSize, maxCentered);
+
                 #endregion Centered
                 #endregion Centered
 
 
                 #region Percent
                 #region Percent
+
                 // [ ] DimPercent   - Dimension is dependent on `us.ContentSize`
                 // [ ] DimPercent   - Dimension is dependent on `us.ContentSize`
                 // No need to do anything.
                 // No need to do anything.
+
                 #endregion Percent
                 #endregion Percent
 
 
                 #region Aligned
                 #region Aligned
+
                 // [ ] PosAlign     - Position is dependent on other views with `GroupId` AND `us.ContentSize`
                 // [ ] PosAlign     - Position is dependent on other views with `GroupId` AND `us.ContentSize`
-                int maxAlign = 0;
+                var maxAlign = 0;
+
                 // Use Linq to get a list of distinct GroupIds from the subviews
                 // Use Linq to get a list of distinct GroupIds from the subviews
                 List<int> groupIds = includedSubviews.Select (
                 List<int> groupIds = includedSubviews.Select (
                                                               v =>
                                                               v =>
@@ -268,24 +297,29 @@ public class DimAuto () : Dim
                                                                           return ((PosAlign)posAlign).GroupId;
                                                                           return ((PosAlign)posAlign).GroupId;
                                                                       }
                                                                       }
                                                                   }
                                                                   }
+
                                                                   return -1;
                                                                   return -1;
-                                                              }).Distinct ().ToList ();
+                                                              })
+                                                     .Distinct ()
+                                                     .ToList ();
 
 
-                foreach (var groupId in groupIds.Where (g => g != -1))
+                foreach (int groupId in groupIds.Where (g => g != -1))
                 {
                 {
                     // PERF: If this proves a perf issue, consider caching a ref to this list in each item
                     // PERF: If this proves a perf issue, consider caching a ref to this list in each item
                     List<PosAlign?> posAlignsInGroup = includedSubviews.Where (
                     List<PosAlign?> posAlignsInGroup = includedSubviews.Where (
-                        v =>
-                        {
-                            return dimension switch
-                            {
-                                Dimension.Width when v.X is PosAlign alignX => alignX.GroupId == groupId,
-                                Dimension.Height when v.Y is PosAlign alignY => alignY.GroupId == groupId,
-                                _ => false
-                            };
-                        })
-                        .Select (v => dimension == Dimension.Width ? v.X as PosAlign : v.Y as PosAlign)
-                        .ToList ();
+                                                                               v =>
+                                                                               {
+                                                                                   return dimension switch
+                                                                                          {
+                                                                                              Dimension.Width when v.X is PosAlign alignX => alignX.GroupId
+                                                                                                  == groupId,
+                                                                                              Dimension.Height when v.Y is PosAlign alignY => alignY.GroupId
+                                                                                                  == groupId,
+                                                                                              _ => false
+                                                                                          };
+                                                                               })
+                                                                       .Select (v => dimension == Dimension.Width ? v.X as PosAlign : v.Y as PosAlign)
+                                                                       .ToList ();
 
 
                     if (posAlignsInGroup.Count == 0)
                     if (posAlignsInGroup.Count == 0)
                     {
                     {
@@ -296,11 +330,14 @@ public class DimAuto () : Dim
                 }
                 }
 
 
                 maxCalculatedSize = int.Max (maxCalculatedSize, maxAlign);
                 maxCalculatedSize = int.Max (maxCalculatedSize, maxAlign);
+
                 #endregion Aligned
                 #endregion Aligned
 
 
                 #region Anchored
                 #region Anchored
+
                 // [x] PosAnchorEnd - Position is dependent on `us.ContentSize` AND `subview.Frame` 
                 // [x] PosAnchorEnd - Position is dependent on `us.ContentSize` AND `subview.Frame` 
                 List<View> anchoredSubViews;
                 List<View> anchoredSubViews;
+
                 if (dimension == Dimension.Width)
                 if (dimension == Dimension.Width)
                 {
                 {
                     anchoredSubViews = includedSubviews.Where (v => v.X.Has (typeof (PosAnchorEnd), out _)).ToList ();
                     anchoredSubViews = includedSubviews.Where (v => v.X.Has (typeof (PosAnchorEnd), out _)).ToList ();
@@ -312,7 +349,8 @@ public class DimAuto () : Dim
 
 
                 viewsNeedingLayout.AddRange (anchoredSubViews);
                 viewsNeedingLayout.AddRange (anchoredSubViews);
 
 
-                int maxAnchorEnd = 0;
+                var maxAnchorEnd = 0;
+
                 for (var i = 0; i < anchoredSubViews.Count; i++)
                 for (var i = 0; i < anchoredSubViews.Count; i++)
                 {
                 {
                     View v = anchoredSubViews [i];
                     View v = anchoredSubViews [i];
@@ -320,21 +358,27 @@ public class DimAuto () : Dim
                     // Need to set the relative layout for PosAnchorEnd subviews to calculate the size
                     // Need to set the relative layout for PosAnchorEnd subviews to calculate the size
                     if (dimension == Dimension.Width)
                     if (dimension == Dimension.Width)
                     {
                     {
-                        v.SetRelativeLayout (new Size (maxCalculatedSize, screenX4));
+                        v.SetRelativeLayout (new (maxCalculatedSize, screenX4));
                     }
                     }
                     else
                     else
                     {
                     {
-                        v.SetRelativeLayout (new Size (screenX4, maxCalculatedSize));
+                        v.SetRelativeLayout (new (screenX4, maxCalculatedSize));
                     }
                     }
-                    maxAnchorEnd = dimension == Dimension.Width ? v.X.GetAnchor (maxCalculatedSize + v.Frame.Width) : v.Y.GetAnchor (maxCalculatedSize + v.Frame.Height);
+
+                    maxAnchorEnd = dimension == Dimension.Width
+                                       ? v.X.GetAnchor (maxCalculatedSize + v.Frame.Width)
+                                       : v.Y.GetAnchor (maxCalculatedSize + v.Frame.Height);
                 }
                 }
 
 
                 maxCalculatedSize = Math.Max (maxCalculatedSize, maxAnchorEnd);
                 maxCalculatedSize = Math.Max (maxCalculatedSize, maxAnchorEnd);
+
                 #endregion Anchored
                 #endregion Anchored
 
 
                 #region PosView
                 #region PosView
+
                 // [x] PosView      - Position is dependent on `subview.Target` - it can cause a change in `us.ContentSize`
                 // [x] PosView      - Position is dependent on `subview.Target` - it can cause a change in `us.ContentSize`
                 List<View> posViewSubViews;
                 List<View> posViewSubViews;
+
                 if (dimension == Dimension.Width)
                 if (dimension == Dimension.Width)
                 {
                 {
                     posViewSubViews = includedSubviews.Where (v => v.X.Has (typeof (PosView), out _)).ToList ();
                     posViewSubViews = includedSubviews.Where (v => v.X.Has (typeof (PosView), out _)).ToList ();
@@ -351,12 +395,13 @@ public class DimAuto () : Dim
                     // BUGBUG: The order may not be correct. May need to call TopologicalSort?
                     // BUGBUG: The order may not be correct. May need to call TopologicalSort?
                     if (dimension == Dimension.Width)
                     if (dimension == Dimension.Width)
                     {
                     {
-                        v.SetRelativeLayout (new Size (maxCalculatedSize, 0));
+                        v.SetRelativeLayout (new (maxCalculatedSize, 0));
                     }
                     }
                     else
                     else
                     {
                     {
-                        v.SetRelativeLayout (new Size (0, maxCalculatedSize));
+                        v.SetRelativeLayout (new (0, maxCalculatedSize));
                     }
                     }
+
                     int maxPosView = dimension == Dimension.Width ? v.Frame.X + v.Frame.Width : v.Frame.Y + v.Frame.Height;
                     int maxPosView = dimension == Dimension.Width ? v.Frame.X + v.Frame.Width : v.Frame.Y + v.Frame.Height;
 
 
                     if (maxPosView > maxCalculatedSize)
                     if (maxPosView > maxCalculatedSize)
@@ -364,13 +409,16 @@ public class DimAuto () : Dim
                         maxCalculatedSize = maxPosView;
                         maxCalculatedSize = maxPosView;
                     }
                     }
                 }
                 }
+
                 #endregion PosView
                 #endregion PosView
 
 
                 // [x] PosCombine   - Position is dependent if `Pos.Has ([one of the above]` - it can cause a change in `us.ContentSize`
                 // [x] PosCombine   - Position is dependent if `Pos.Has ([one of the above]` - it can cause a change in `us.ContentSize`
 
 
                 #region DimView
                 #region DimView
+
                 // [x] DimView      - Dimension is dependent on `subview.Target` - it can cause a change in `us.ContentSize`
                 // [x] DimView      - Dimension is dependent on `subview.Target` - it can cause a change in `us.ContentSize`
                 List<View> dimViewSubViews;
                 List<View> dimViewSubViews;
+
                 if (dimension == Dimension.Width)
                 if (dimension == Dimension.Width)
                 {
                 {
                     dimViewSubViews = includedSubviews.Where (v => v.Width is { } && v.Width.Has (typeof (DimView), out _)).ToList ();
                     dimViewSubViews = includedSubviews.Where (v => v.Width is { } && v.Width.Has (typeof (DimView), out _)).ToList ();
@@ -387,11 +435,11 @@ public class DimAuto () : Dim
                     // BUGBUG: The order may not be correct. May need to call TopologicalSort?
                     // BUGBUG: The order may not be correct. May need to call TopologicalSort?
                     if (dimension == Dimension.Width)
                     if (dimension == Dimension.Width)
                     {
                     {
-                        v.SetRelativeLayout (new Size (maxCalculatedSize, 0));
+                        v.SetRelativeLayout (new (maxCalculatedSize, 0));
                     }
                     }
                     else
                     else
                     {
                     {
-                        v.SetRelativeLayout (new Size (0, maxCalculatedSize));
+                        v.SetRelativeLayout (new (0, maxCalculatedSize));
                     }
                     }
 
 
                     int maxDimView = dimension == Dimension.Width ? v.Frame.X + v.Frame.Width : v.Frame.Y + v.Frame.Height;
                     int maxDimView = dimension == Dimension.Width ? v.Frame.X + v.Frame.Width : v.Frame.Y + v.Frame.Height;
@@ -401,6 +449,7 @@ public class DimAuto () : Dim
                         maxCalculatedSize = maxDimView;
                         maxCalculatedSize = maxDimView;
                     }
                     }
                 }
                 }
+
                 #endregion DimView
                 #endregion DimView
             }
             }
         }
         }
@@ -420,50 +469,31 @@ public class DimAuto () : Dim
         int oppositeScreen = dimension == Dimension.Width ? Application.Screen.Height * 4 : Application.Screen.Width * 4;
         int oppositeScreen = dimension == Dimension.Width ? Application.Screen.Height * 4 : Application.Screen.Width * 4;
 
 
         // TODO: Double-check that we really do need to SetRelativeLayout on these views!
         // TODO: Double-check that we really do need to SetRelativeLayout on these views!
-        foreach (var v in viewsNeedingLayout)
+        foreach (View v in viewsNeedingLayout)
         {
         {
             if (dimension == Dimension.Width)
             if (dimension == Dimension.Width)
             {
             {
-                v.SetRelativeLayout (new Size (max, oppositeScreen));
+                v.SetRelativeLayout (new (max, oppositeScreen));
             }
             }
             else
             else
             {
             {
-                v.SetRelativeLayout (new Size (oppositeScreen, max));
+                v.SetRelativeLayout (new (oppositeScreen, max));
             }
             }
         }
         }
 
 
         // Factor in adornments
         // Factor in adornments
         Thickness thickness = us.GetAdornmentsThickness ();
         Thickness thickness = us.GetAdornmentsThickness ();
-        var adornmentThickness = dimension switch
-        {
-            Dimension.Width => thickness.Horizontal,
-            Dimension.Height => thickness.Vertical,
-            Dimension.None => 0,
-            _ => throw new ArgumentOutOfRangeException (nameof (dimension), dimension, null)
-        };
+
+        int adornmentThickness = dimension switch
+                                 {
+                                     Dimension.Width => thickness.Horizontal,
+                                     Dimension.Height => thickness.Vertical,
+                                     Dimension.None => 0,
+                                     _ => throw new ArgumentOutOfRangeException (nameof (dimension), dimension, null)
+                                 };
 
 
         max += adornmentThickness;
         max += adornmentThickness;
 
 
         return max;
         return max;
     }
     }
-
-    /// <inheritdoc/>
-    public override bool Equals (object? other)
-    {
-        if (other is not DimAuto auto)
-        {
-            return false;
-        }
-
-        return auto.MinimumContentDim == MinimumContentDim &&
-               auto.MaximumContentDim == MaximumContentDim &&
-               auto.Style == Style;
-    }
-
-    /// <inheritdoc/>
-    public override int GetHashCode ()
-    {
-        return HashCode.Combine (MinimumContentDim, MaximumContentDim, Style);
-    }
-
-}
+}

+ 275 - 259
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -5,6 +5,240 @@ namespace Terminal.Gui;
 
 
 public partial class View
 public partial class View
 {
 {
+    /// <summary>
+    ///     Indicates whether the specified SuperView-relative coordinates are within the View's <see cref="Frame"/>.
+    /// </summary>
+    /// <param name="location">SuperView-relative coordinate</param>
+    /// <returns><see langword="true"/> if the specified SuperView-relative coordinates are within the View.</returns>
+    public virtual bool Contains (in Point location) { return Frame.Contains (location); }
+
+    /// <summary>Finds the first Subview of <paramref name="start"/> that is visible at the provided location.</summary>
+    /// <remarks>
+    ///     <para>
+    ///         Used to determine what view the mouse is over.
+    ///     </para>
+    /// </remarks>
+    /// <param name="start">The view to scope the search by.</param>
+    /// <param name="location"><paramref name="start"/>.SuperView-relative coordinate.</param>
+    /// <returns>
+    ///     The view that was found at the <paramref name="location"/> coordinate.
+    ///     <see langword="null"/> if no view was found.
+    /// </returns>
+
+    // CONCURRENCY: This method is not thread-safe. Undefined behavior and likely program crashes are exposed by unsynchronized access to InternalSubviews.
+    internal static View? FindDeepestView (View? start, in Point location)
+    {
+        Point currentLocation = location;
+
+        while (start is { Visible: true } && start.Contains (currentLocation))
+        {
+            Adornment? found = null;
+
+            if (start.Margin.Contains (currentLocation))
+            {
+                found = start.Margin;
+            }
+            else if (start.Border.Contains (currentLocation))
+            {
+                found = start.Border;
+            }
+            else if (start.Padding.Contains (currentLocation))
+            {
+                found = start.Padding;
+            }
+
+            Point viewportOffset = start.GetViewportOffsetFromFrame ();
+
+            if (found is { })
+            {
+                start = found;
+                viewportOffset = found.Parent.Frame.Location;
+            }
+
+            int startOffsetX = currentLocation.X - (start.Frame.X + viewportOffset.X);
+            int startOffsetY = currentLocation.Y - (start.Frame.Y + viewportOffset.Y);
+
+            View? subview = null;
+
+            for (int i = start.InternalSubviews.Count - 1; i >= 0; i--)
+            {
+                if (start.InternalSubviews [i].Visible
+                    && start.InternalSubviews [i].Contains (new (startOffsetX + start.Viewport.X, startOffsetY + start.Viewport.Y)))
+                {
+                    subview = start.InternalSubviews [i];
+                    currentLocation.X = startOffsetX + start.Viewport.X;
+                    currentLocation.Y = startOffsetY + start.Viewport.Y;
+
+                    // start is the deepest subview under the mouse; stop searching the subviews
+                    break;
+                }
+            }
+
+            if (subview is null)
+            {
+                // No subview was found that's under the mouse, so we're done
+                return start;
+            }
+
+            // We found a subview of start that's under the mouse, continue...
+            start = subview;
+        }
+
+        return null;
+    }
+
+    /// <summary>
+    ///     Gets a new location of the <see cref="View"/> that is within the Viewport of the <paramref name="viewToMove"/>'s
+    ///     <see cref="View.SuperView"/> (e.g. for dragging a Window). The `out` parameters are the new X and Y coordinates.
+    /// </summary>
+    /// <remarks>
+    ///     If <paramref name="viewToMove"/> does not have a <see cref="View.SuperView"/> or it's SuperView is not
+    ///     <see cref="Application.Top"/> the position will be bound by the <see cref="ConsoleDriver.Cols"/> and
+    ///     <see cref="ConsoleDriver.Rows"/>.
+    /// </remarks>
+    /// <param name="viewToMove">The View that is to be moved.</param>
+    /// <param name="targetX">The target x location.</param>
+    /// <param name="targetY">The target y location.</param>
+    /// <param name="nx">The new x location that will ensure <paramref name="viewToMove"/> will be fully visible.</param>
+    /// <param name="ny">The new y location that will ensure <paramref name="viewToMove"/> will be fully visible.</param>
+    /// <param name="statusBar">The new top most statusBar</param>
+    /// <returns>
+    ///     Either <see cref="Application.Top"/> (if <paramref name="viewToMove"/> does not have a Super View) or
+    ///     <paramref name="viewToMove"/>'s SuperView. This can be used to ensure LayoutSubviews is called on the correct View.
+    /// </returns>
+    internal static View GetLocationEnsuringFullVisibility (
+        View viewToMove,
+        int targetX,
+        int targetY,
+        out int nx,
+        out int ny,
+        out StatusBar statusBar
+    )
+    {
+        int maxDimension;
+        View superView;
+        statusBar = null!;
+
+        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
+        {
+            maxDimension = Driver.Cols;
+            superView = Application.Top;
+        }
+        else
+        {
+            // Use the SuperView's Viewport, not Frame
+            maxDimension = viewToMove!.SuperView.Viewport.Width;
+            superView = viewToMove.SuperView;
+        }
+
+        if (superView?.Margin is { } && superView == viewToMove!.SuperView)
+        {
+            maxDimension -= superView.GetAdornmentsThickness ().Left + superView.GetAdornmentsThickness ().Right;
+        }
+
+        if (viewToMove!.Frame.Width <= maxDimension)
+        {
+            nx = Math.Max (targetX, 0);
+            nx = nx + viewToMove.Frame.Width > maxDimension ? Math.Max (maxDimension - viewToMove.Frame.Width, 0) : nx;
+
+            if (nx > viewToMove.Frame.X + viewToMove.Frame.Width)
+            {
+                nx = Math.Max (viewToMove.Frame.Right, 0);
+            }
+        }
+        else
+        {
+            nx = targetX;
+        }
+
+        //System.Diagnostics.Debug.WriteLine ($"nx:{nx}, rWidth:{rWidth}");
+        var menuVisible = false;
+        var statusVisible = false;
+
+        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
+        {
+            menuVisible = Application.Top?.MenuBar?.Visible == true;
+        }
+        else
+        {
+            View t = viewToMove!.SuperView;
+
+            while (t is { } and not Toplevel)
+            {
+                t = t.SuperView;
+            }
+
+            if (t is Toplevel topLevel)
+            {
+                menuVisible = topLevel.MenuBar?.Visible == true;
+            }
+        }
+
+        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
+        {
+            maxDimension = menuVisible ? 1 : 0;
+        }
+        else
+        {
+            maxDimension = 0;
+        }
+
+        ny = Math.Max (targetY, maxDimension);
+
+        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
+        {
+            statusVisible = Application.Top?.StatusBar?.Visible == true;
+            statusBar = Application.Top?.StatusBar!;
+        }
+        else
+        {
+            View t = viewToMove!.SuperView;
+
+            while (t is { } and not Toplevel)
+            {
+                t = t.SuperView;
+            }
+
+            if (t is Toplevel topLevel)
+            {
+                statusVisible = topLevel.StatusBar?.Visible == true;
+                statusBar = topLevel.StatusBar!;
+            }
+        }
+
+        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
+        {
+            maxDimension = statusVisible ? Driver.Rows - 1 : Driver.Rows;
+        }
+        else
+        {
+            maxDimension = statusVisible ? viewToMove!.SuperView.Viewport.Height - 1 : viewToMove!.SuperView.Viewport.Height;
+        }
+
+        if (superView?.Margin is { } && superView == viewToMove?.SuperView)
+        {
+            maxDimension -= superView.GetAdornmentsThickness ().Top + superView.GetAdornmentsThickness ().Bottom;
+        }
+
+        ny = Math.Min (ny, maxDimension);
+
+        if (viewToMove?.Frame.Height <= maxDimension)
+        {
+            ny = ny + viewToMove.Frame.Height > maxDimension
+                     ? Math.Max (maxDimension - viewToMove.Frame.Height, menuVisible ? 1 : 0)
+                     : ny;
+
+            if (ny > viewToMove.Frame.Y + viewToMove.Frame.Height)
+            {
+                ny = Math.Max (viewToMove.Frame.Bottom, 0);
+            }
+        }
+
+        //System.Diagnostics.Debug.WriteLine ($"ny:{ny}, rHeight:{rHeight}");
+
+        return superView!;
+    }
+
     #region Frame
     #region Frame
 
 
     private Rectangle _frame;
     private Rectangle _frame;
@@ -15,7 +249,10 @@ public partial class View
     ///     <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>.
     ///     <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>.
     /// </value>
     /// </value>
     /// <remarks>
     /// <remarks>
-    ///     <para>Frame is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>.</para>
+    ///     <para>
+    ///         Frame is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>
+    ///         .
+    ///     </para>
     ///     <para>
     ///     <para>
     ///         Setting Frame will set <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> to the
     ///         Setting Frame will set <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> to the
     ///         values of the corresponding properties of the <paramref name="value"/> parameter.
     ///         values of the corresponding properties of the <paramref name="value"/> parameter.
@@ -131,7 +368,8 @@ public partial class View
     /// <value>The <see cref="Pos"/> object representing the X position.</value>
     /// <value>The <see cref="Pos"/> object representing the X position.</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>.
+    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by
+    ///         <see cref="GetContentSize ()"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
@@ -169,7 +407,8 @@ public partial class View
     /// <value>The <see cref="Pos"/> object representing the Y position.</value>
     /// <value>The <see cref="Pos"/> object representing the Y position.</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>.
+    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by
+    ///         <see cref="GetContentSize ()"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
@@ -206,7 +445,8 @@ public partial class View
     /// <value>The <see cref="Dim"/> object representing the height of the view (the number of rows).</value>
     /// <value>The <see cref="Dim"/> object representing the height of the view (the number of rows).</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>
+    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by
+    ///         <see cref="GetContentSize ()"/>
     ///         .
     ///         .
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
@@ -254,7 +494,8 @@ public partial class View
     /// <value>The <see cref="Dim"/> object representing the width of the view (the number of columns).</value>
     /// <value>The <see cref="Dim"/> object representing the width of the view (the number of columns).</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>
+    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by
+    ///         <see cref="GetContentSize ()"/>
     ///         .
     ///         .
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
@@ -300,241 +541,6 @@ public partial class View
 
 
     #region Layout Engine
     #region Layout Engine
 
 
-    #endregion Layout Engine
-
-    /// <summary>
-    ///     Indicates whether the specified SuperView-relative coordinates are within the View's <see cref="Frame"/>.
-    /// </summary>
-    /// <param name="location">SuperView-relative coordinate</param>
-    /// <returns><see langword="true"/> if the specified SuperView-relative coordinates are within the View.</returns>
-    public virtual bool Contains (in Point location) { return Frame.Contains (location); }
-
-    /// <summary>Finds the first Subview of <paramref name="start"/> that is visible at the provided location.</summary>
-    /// <remarks>
-    ///     <para>
-    ///         Used to determine what view the mouse is over.
-    ///     </para>
-    /// </remarks>
-    /// <param name="start">The view to scope the search by.</param>
-    /// <param name="location"><paramref name="start"/>.SuperView-relative coordinate.</param>
-    /// <returns>
-    ///     The view that was found at the <paramref name="location"/> coordinate.
-    ///     <see langword="null"/> if no view was found.
-    /// </returns>
-
-    // CONCURRENCY: This method is not thread-safe. Undefined behavior and likely program crashes are exposed by unsynchronized access to InternalSubviews.
-    internal static View? FindDeepestView (View? start, in Point location)
-    {
-        Point currentLocation = location;
-        while (start is { Visible: true } && start.Contains (currentLocation))
-        {
-            Adornment? found = null;
-
-            if (start.Margin.Contains (currentLocation))
-            {
-                found = start.Margin;
-            }
-            else if (start.Border.Contains (currentLocation))
-            {
-                found = start.Border;
-            }
-            else if (start.Padding.Contains (currentLocation))
-            {
-                found = start.Padding;
-            }
-
-            Point viewportOffset = start.GetViewportOffsetFromFrame ();
-
-            if (found is { })
-            {
-                start = found;
-                viewportOffset = found.Parent.Frame.Location;
-            }
-
-            int startOffsetX = currentLocation.X - (start.Frame.X + viewportOffset.X);
-            int startOffsetY = currentLocation.Y - (start.Frame.Y + viewportOffset.Y);
-
-            View? subview = null;
-
-            for (int i = start.InternalSubviews.Count - 1; i >= 0; i--)
-            {
-                if (start.InternalSubviews [i].Visible
-                    && start.InternalSubviews [i].Contains (new (startOffsetX + start.Viewport.X, startOffsetY + start.Viewport.Y)))
-                {
-                    subview = start.InternalSubviews [i];
-                    currentLocation.X = startOffsetX + start.Viewport.X;
-                    currentLocation.Y = startOffsetY + start.Viewport.Y;
-
-                    // start is the deepest subview under the mouse; stop searching the subviews
-                    break;
-                }
-            }
-
-            if (subview is null)
-            {
-                // No subview was found that's under the mouse, so we're done
-                return start;
-            }
-
-            // We found a subview of start that's under the mouse, continue...
-            start = subview;
-        }
-
-        return null;
-    }
-
-    /// <summary>
-    ///     Gets a new location of the <see cref="View"/> that is within the Viewport of the <paramref name="viewToMove"/>'s
-    ///     <see cref="View.SuperView"/> (e.g. for dragging a Window). The `out` parameters are the new X and Y coordinates.
-    /// </summary>
-    /// <remarks>
-    ///     If <paramref name="viewToMove"/> does not have a <see cref="View.SuperView"/> or it's SuperView is not
-    ///     <see cref="Application.Top"/> the position will be bound by the <see cref="ConsoleDriver.Cols"/> and
-    ///     <see cref="ConsoleDriver.Rows"/>.
-    /// </remarks>
-    /// <param name="viewToMove">The View that is to be moved.</param>
-    /// <param name="targetX">The target x location.</param>
-    /// <param name="targetY">The target y location.</param>
-    /// <param name="nx">The new x location that will ensure <paramref name="viewToMove"/> will be fully visible.</param>
-    /// <param name="ny">The new y location that will ensure <paramref name="viewToMove"/> will be fully visible.</param>
-    /// <param name="statusBar">The new top most statusBar</param>
-    /// <returns>
-    ///     Either <see cref="Application.Top"/> (if <paramref name="viewToMove"/> does not have a Super View) or
-    ///     <paramref name="viewToMove"/>'s SuperView. This can be used to ensure LayoutSubviews is called on the correct View.
-    /// </returns>
-    internal static View GetLocationEnsuringFullVisibility (
-        View viewToMove,
-        int targetX,
-        int targetY,
-        out int nx,
-        out int ny,
-        out StatusBar statusBar
-    )
-    {
-        int maxDimension;
-        View superView;
-        statusBar = null!;
-
-        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
-        {
-            maxDimension = Driver.Cols;
-            superView = Application.Top;
-        }
-        else
-        {
-            // Use the SuperView's Viewport, not Frame
-            maxDimension = viewToMove!.SuperView.Viewport.Width;
-            superView = viewToMove.SuperView;
-        }
-
-        if (superView?.Margin is { } && superView == viewToMove!.SuperView)
-        {
-            maxDimension -= superView.GetAdornmentsThickness ().Left + superView.GetAdornmentsThickness ().Right;
-        }
-
-        if (viewToMove!.Frame.Width <= maxDimension)
-        {
-            nx = Math.Max (targetX, 0);
-            nx = nx + viewToMove.Frame.Width > maxDimension ? Math.Max (maxDimension - viewToMove.Frame.Width, 0) : nx;
-
-            if (nx > viewToMove.Frame.X + viewToMove.Frame.Width)
-            {
-                nx = Math.Max (viewToMove.Frame.Right, 0);
-            }
-        }
-        else
-        {
-            nx = targetX;
-        }
-
-        //System.Diagnostics.Debug.WriteLine ($"nx:{nx}, rWidth:{rWidth}");
-        var menuVisible = false;
-        var statusVisible = false;
-
-        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
-        {
-            menuVisible = Application.Top?.MenuBar?.Visible == true;
-        }
-        else
-        {
-            View t = viewToMove!.SuperView;
-
-            while (t is { } and not Toplevel)
-            {
-                t = t.SuperView;
-            }
-
-            if (t is Toplevel topLevel)
-            {
-                menuVisible = topLevel.MenuBar?.Visible == true;
-            }
-        }
-
-        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
-        {
-            maxDimension = menuVisible ? 1 : 0;
-        }
-        else
-        {
-            maxDimension = 0;
-        }
-
-        ny = Math.Max (targetY, maxDimension);
-
-        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
-        {
-            statusVisible = Application.Top?.StatusBar?.Visible == true;
-            statusBar = Application.Top?.StatusBar!;
-        }
-        else
-        {
-            View t = viewToMove!.SuperView;
-
-            while (t is { } and not Toplevel)
-            {
-                t = t.SuperView;
-            }
-
-            if (t is Toplevel topLevel)
-            {
-                statusVisible = topLevel.StatusBar?.Visible == true;
-                statusBar = topLevel.StatusBar!;
-            }
-        }
-
-        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
-        {
-            maxDimension = statusVisible ? Driver.Rows - 1 : Driver.Rows;
-        }
-        else
-        {
-            maxDimension = statusVisible ? viewToMove!.SuperView.Viewport.Height - 1 : viewToMove!.SuperView.Viewport.Height;
-        }
-
-        if (superView?.Margin is { } && superView == viewToMove?.SuperView)
-        {
-            maxDimension -= superView.GetAdornmentsThickness ().Top + superView.GetAdornmentsThickness ().Bottom;
-        }
-
-        ny = Math.Min (ny, maxDimension);
-
-        if (viewToMove?.Frame.Height <= maxDimension)
-        {
-            ny = ny + viewToMove.Frame.Height > maxDimension
-                     ? Math.Max (maxDimension - viewToMove.Frame.Height, menuVisible ? 1 : 0)
-                     : ny;
-
-            if (ny > viewToMove.Frame.Y + viewToMove.Frame.Height)
-            {
-                ny = Math.Max (viewToMove.Frame.Bottom, 0);
-            }
-        }
-
-        //System.Diagnostics.Debug.WriteLine ($"ny:{ny}, rHeight:{rHeight}");
-
-        return superView!;
-    }
-
     /// <summary>Fired after the View's <see cref="LayoutSubviews"/> method has completed.</summary>
     /// <summary>Fired after the View's <see cref="LayoutSubviews"/> method has completed.</summary>
     /// <remarks>
     /// <remarks>
     ///     Subscribe to this event to perform tasks when the <see cref="View"/> has been resized or the layout has
     ///     Subscribe to this event to perform tasks when the <see cref="View"/> has been resized or the layout has
@@ -562,7 +568,8 @@ public partial class View
     ///         are left unchanged.
     ///         are left unchanged.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         If any of the view's subviews have a position or dimension dependent on either <see cref="GetContentSize"/> or other subviews, <see cref="LayoutSubview"/> on
+    ///         If any of the view's subviews have a position or dimension dependent on either <see cref="GetContentSize"/> or
+    ///         other subviews, <see cref="LayoutSubview"/> on
     ///         will be called for that subview.
     ///         will be called for that subview.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
@@ -650,12 +657,11 @@ public partial class View
         {
         {
             TextFormatter.Height = GetContentSize ().Height;
             TextFormatter.Height = GetContentSize ().Height;
         }
         }
-
     }
     }
 
 
-
     /// <summary>
     /// <summary>
-    ///     Invoked when the dimensions of the view have changed, for example in response to the container view or terminal resizing.
+    ///     Invoked when the dimensions of the view have changed, for example in response to the container view or terminal
+    ///     resizing.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
@@ -678,7 +684,7 @@ public partial class View
 
 
         CheckDimAuto ();
         CheckDimAuto ();
 
 
-        var contentSize = GetContentSize ();
+        Size contentSize = GetContentSize ();
         OnLayoutStarted (new (contentSize));
         OnLayoutStarted (new (contentSize));
 
 
         LayoutAdornments ();
         LayoutAdornments ();
@@ -756,8 +762,8 @@ public partial class View
         //  First try SuperView.Viewport, then Application.Top, then Driver.Viewport.
         //  First try SuperView.Viewport, then Application.Top, then Driver.Viewport.
         //  Finally, if none of those are valid, use 2048 (for Unit tests).
         //  Finally, if none of those are valid, use 2048 (for Unit tests).
         Size superViewContentSize = SuperView is { IsInitialized: true } ? SuperView.GetContentSize () :
         Size superViewContentSize = SuperView is { IsInitialized: true } ? SuperView.GetContentSize () :
-                           Application.Top is { } && Application.Top != this && Application.Top.IsInitialized ? Application.Top.GetContentSize () :
-                           Application.Screen.Size;
+                                    Application.Top is { } && Application.Top != this && Application.Top.IsInitialized ? Application.Top.GetContentSize () :
+                                    Application.Screen.Size;
 
 
         SetRelativeLayout (superViewContentSize);
         SetRelativeLayout (superViewContentSize);
 
 
@@ -795,12 +801,15 @@ public partial class View
     }
     }
 
 
     /// <summary>
     /// <summary>
-    /// Collects all views and their dependencies from a given starting view for layout purposes. Used by <see cref="TopologicalSort"/> to create an ordered list of views to layout.
+    ///     Collects all views and their dependencies from a given starting view for layout purposes. Used by
+    ///     <see cref="TopologicalSort"/> to create an ordered list of views to layout.
     /// </summary>
     /// </summary>
     /// <param name="from">The starting view from which to collect dependencies.</param>
     /// <param name="from">The starting view from which to collect dependencies.</param>
     /// <param name="nNodes">A reference to a set of views representing nodes in the layout graph.</param>
     /// <param name="nNodes">A reference to a set of views representing nodes in the layout graph.</param>
-    /// <param name="nEdges">A reference to a set of tuples representing edges in the layout graph, where each tuple consists of a pair of views indicating a dependency.</param>
-
+    /// <param name="nEdges">
+    ///     A reference to a set of tuples representing edges in the layout graph, where each tuple consists of a pair of views
+    ///     indicating a dependency.
+    /// </param>
     internal void CollectAll (View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
     internal void CollectAll (View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
     {
     {
         foreach (View? v in from.InternalSubviews)
         foreach (View? v in from.InternalSubviews)
@@ -812,14 +821,17 @@ public partial class View
             CollectDim (v.Height, v, ref nNodes, ref nEdges);
             CollectDim (v.Height, v, ref nNodes, ref nEdges);
         }
         }
     }
     }
+
     /// <summary>
     /// <summary>
-    /// Collects dimension (where Width or Height is `DimView`) dependencies for a given view.
+    ///     Collects dimension (where Width or Height is `DimView`) dependencies for a given view.
     /// </summary>
     /// </summary>
     /// <param name="dim">The dimension (width or height) to collect dependencies for.</param>
     /// <param name="dim">The dimension (width or height) to collect dependencies for.</param>
     /// <param name="from">The view for which to collect dimension dependencies.</param>
     /// <param name="from">The view for which to collect dimension dependencies.</param>
     /// <param name="nNodes">A reference to a set of views representing nodes in the layout graph.</param>
     /// <param name="nNodes">A reference to a set of views representing nodes in the layout graph.</param>
-    /// <param name="nEdges">A reference to a set of tuples representing edges in the layout graph, where each tuple consists of a pair of views indicating a dependency.</param>
-
+    /// <param name="nEdges">
+    ///     A reference to a set of tuples representing edges in the layout graph, where each tuple consists of a pair of views
+    ///     indicating a dependency.
+    /// </param>
     internal void CollectDim (Dim? dim, View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
     internal void CollectDim (Dim? dim, View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
     {
     {
         switch (dim)
         switch (dim)
@@ -844,12 +856,15 @@ public partial class View
     }
     }
 
 
     /// <summary>
     /// <summary>
-    /// Collects position (where X or Y is `PosView`) dependencies for a given view.
+    ///     Collects position (where X or Y is `PosView`) dependencies for a given view.
     /// </summary>
     /// </summary>
     /// <param name="pos">The position (X or Y) to collect dependencies for.</param>
     /// <param name="pos">The position (X or Y) to collect dependencies for.</param>
     /// <param name="from">The view for which to collect position dependencies.</param>
     /// <param name="from">The view for which to collect position dependencies.</param>
     /// <param name="nNodes">A reference to a set of views representing nodes in the layout graph.</param>
     /// <param name="nNodes">A reference to a set of views representing nodes in the layout graph.</param>
-    /// <param name="nEdges">A reference to a set of tuples representing edges in the layout graph, where each tuple consists of a pair of views indicating a dependency.</param>
+    /// <param name="nEdges">
+    ///     A reference to a set of tuples representing edges in the layout graph, where each tuple consists of a pair of views
+    ///     indicating a dependency.
+    /// </param>
     internal void CollectPos (Pos pos, View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
     internal void CollectPos (Pos pos, View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
     {
     {
         switch (pos)
         switch (pos)
@@ -1008,7 +1023,6 @@ public partial class View
     /// </remarks>
     /// </remarks>
     public bool ValidatePosDim { get; set; }
     public bool ValidatePosDim { get; set; }
 
 
-
     // TODO: Move this logic into the Pos/Dim classes
     // TODO: Move this logic into the Pos/Dim classes
     /// <summary>
     /// <summary>
     ///     Throws an <see cref="InvalidOperationException"/> if any SubViews are using Dim objects that depend on this
     ///     Throws an <see cref="InvalidOperationException"/> if any SubViews are using Dim objects that depend on this
@@ -1022,8 +1036,8 @@ public partial class View
             return;
             return;
         }
         }
 
 
-        DimAuto? widthAuto = Width as DimAuto;
-        DimAuto? heightAuto = Height as DimAuto;
+        var widthAuto = Width as DimAuto;
+        var heightAuto = Height as DimAuto;
 
 
         // 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)
@@ -1088,8 +1102,10 @@ public partial class View
                 throw new InvalidOperationException (
                 throw new InvalidOperationException (
                                                      $"{view.GetType ().Name}.{name} = {bad.GetType ().Name} "
                                                      $"{view.GetType ().Name}.{name} = {bad.GetType ().Name} "
                                                      + $"which depends on the SuperView's dimensions and the SuperView uses Dim.Auto."
                                                      + $"which depends on the SuperView's dimensions and the SuperView uses Dim.Auto."
-                                                     );
+                                                    );
             }
             }
         }
         }
     }
     }
+
+    #endregion Layout Engine
 }
 }