Tig пре 9 месеци
родитељ
комит
2d48bc9d49

+ 2 - 2
Terminal.Gui/Application/Application.Run.cs

@@ -492,7 +492,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
     public static void Wakeup () { MainLoop?.Wakeup (); }
 
     /// <summary>
-    /// Refreshes layout and the display. Only Views that need to be laid out (see <see cref="View.IsLayoutNeeded()"/>) will be laid out.
+    /// Refreshes layout and the display. Only Views that need to be laid out (see <see cref="View.NeedsLayout"/>) will be laid out.
     /// Only Views that need to be drawn (see <see cref="View.NeedsDisplay"/>) will be drawn.
     /// </summary>
     /// <param name="forceRedraw">If <see langword="true"/> the entire View hierarchy will be redrawn. The default is <see langword="false"/> and should only be overriden for testing.</param>
@@ -501,7 +501,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
         bool clear = false;
         foreach (Toplevel tl in TopLevels.Reverse ())
         {
-            if (tl.IsLayoutNeeded ())
+            if (tl.NeedsLayout)
             {
                 clear = true;
                 tl.Layout (Screen.Size);

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

@@ -110,7 +110,7 @@ public record PosAlign : Pos
 
     internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
     {
-        if (_cachedLocation.HasValue && Aligner.ContainerSize == superviewDimension && !us.IsLayoutNeeded())
+        if (_cachedLocation.HasValue && Aligner.ContainerSize == superviewDimension && !us.NeedsLayout)
         {
             return _cachedLocation.Value;
         }

+ 3 - 3
Terminal.Gui/View/View.Drawing.cs

@@ -195,7 +195,7 @@ public partial class View // Drawing APIs
             return;
         }
 
-        if (IsLayoutNeeded ())
+        if (NeedsLayout)
         {
             //Debug.WriteLine ($"Layout should be de-coupled from drawing: {this}");
         }
@@ -541,7 +541,7 @@ public partial class View // Drawing APIs
 
             foreach (View view in subviewsNeedingDraw)
             {
-                if (view.IsLayoutNeeded ())
+                if (view.NeedsLayout)
                 {
                     //Debug.WriteLine ($"Layout should be de-coupled from drawing: {view}");
                     //view.LayoutSubviews ();
@@ -638,7 +638,7 @@ public partial class View // Drawing APIs
     /// <summary>Gets or sets whether the view needs to be redrawn.</summary>
     public bool NeedsDisplay
     {
-        get => _needsDisplayRect != Rectangle.Empty || IsLayoutNeeded ();
+        get => _needsDisplayRect != Rectangle.Empty || NeedsLayout;
         set
         {
             if (value)

+ 84 - 75
Terminal.Gui/View/View.Layout.cs

@@ -184,21 +184,18 @@ public partial class View // Layout APIs
     ///         .
     ///     </para>
     ///     <para>
-    ///         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.
+    ///         Setting Frame will set <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> to absoulte values.
     ///     </para>
     ///     <para>
-    ///         Altering the Frame will eventually (when the view hierarchy is next laid out via  see
-    ///         cref="LayoutSubviews"/>) cause <see cref="Layout"/> and
-    ///         <see cref="OnDrawContent(Rectangle)"/>
-    ///         methods to be called.
+    ///         Changing this property will result in <see cref="NeedsLayout"/> and <see cref="NeedsDisplay"/> to be set, resulting in the
+    ///         view being laid out and redrawn as appropriate in the next iteration of the <see cref="MainLoop"/>.
     ///     </para>
     /// </remarks>
     public Rectangle Frame
     {
         get
         {
-            if (_layoutNeeded)
+            if (_needsLayout)
             {
                 //Debug.WriteLine("Frame_get with _layoutNeeded");
             }
@@ -326,12 +323,11 @@ public partial class View // Layout APIs
     ///     </para>
     ///     <para>
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
-    ///         initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout"/> has been
-    ///         called.
+    ///         laid out (e.g. <see cref="Layout(System.Drawing.Size)"/> has been called).
     ///     </para>
     ///     <para>
-    ///         Changing this property will eventually (when the view is next drawn) cause the
-    ///         <see cref="Layout"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
+    ///         Changing this property will result in <see cref="NeedsLayout"/> and <see cref="NeedsDisplay"/> to be set, resulting in the
+    ///         view being laid out and redrawn as appropriate in the next iteration of the <see cref="MainLoop"/>.
     ///     </para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated.
@@ -367,6 +363,7 @@ public partial class View // Layout APIs
 
     private Pos _y = Pos.Absolute (0);
 
+
     /// <summary>Gets or sets the Y position for the view (the row).</summary>
     /// <value>The <see cref="Pos"/> object representing the Y position.</value>
     /// <remarks>
@@ -380,12 +377,11 @@ public partial class View // Layout APIs
     ///     </para>
     ///     <para>
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
-    ///         initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout"/> has been
-    ///         called.
+    ///         laid out (e.g. <see cref="Layout(System.Drawing.Size)"/> has been called).
     ///     </para>
     ///     <para>
-    ///         Changing this property will eventually (when the view is next drawn) cause the
-    ///         <see cref="Layout"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
+    ///         Changing this property will result in <see cref="NeedsLayout"/> and <see cref="NeedsDisplay"/> to be set, resulting in the
+    ///         view being laid out and redrawn as appropriate in the next iteration of the <see cref="MainLoop"/>.
     ///     </para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated.
@@ -425,17 +421,15 @@ public partial class View // Layout APIs
     ///     </para>
     ///     <para>
     ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by
-    ///         <see cref="GetContentSize ()"/>
-    ///         .
+    ///         <see cref="GetContentSize ()"/>         .
     ///     </para>
     ///     <para>
-    ///         If set to a relative value (e.g. <see cref="Dim.Fill(Dim)"/>) the value is indeterminate until the view has
-    ///         been initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout"/> has been
-    ///         called.
+    ///         If set to a relative value (e.g. <see cref="DimFill"/>) the value is indeterminate until the view has been
+    ///         laid out (e.g. <see cref="Layout(System.Drawing.Size)"/> has been called).
     ///     </para>
     ///     <para>
-    ///         Changing this property will eventually (when the view is next drawn) cause the
-    ///         <see cref="Layout"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
+    ///         Changing this property will result in <see cref="NeedsLayout"/> and <see cref="NeedsDisplay"/> to be set, resulting in the
+    ///         view being laid out and redrawn as appropriate in the next iteration of the <see cref="MainLoop"/>.
     ///     </para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated.
@@ -488,13 +482,12 @@ public partial class View // Layout APIs
     ///         .
     ///     </para>
     ///     <para>
-    ///         If set to a relative value (e.g. <see cref="Dim.Fill(Dim)"/>) the value is indeterminate until the view has
-    ///         been initialized ( <see cref="IsInitialized"/> is true) and <see cref="SetRelativeLayout"/> has been
-    ///         called.
+    ///         If set to a relative value (e.g. <see cref="DimFill"/>) the value is indeterminate until the view has been
+    ///         laid out (e.g. <see cref="Layout(System.Drawing.Size)"/> has been called).
     ///     </para>
     ///     <para>
-    ///         Changing this property will eventually (when the view is next drawn) cause the
-    ///         <see cref="Layout"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
+    ///         Changing this property will result in <see cref="NeedsLayout"/> and <see cref="NeedsDisplay"/> to be set, resulting in the
+    ///         view being laid out and redrawn as appropriate in the next iteration of the <see cref="MainLoop"/>.
     ///     </para>
     ///     <para>
     ///         Changing this property will cause <see cref="Frame"/> to be updated.
@@ -536,6 +529,53 @@ public partial class View // Layout APIs
 
     #region Layout Engine
 
+    /// <summary>
+    ///     Performs layout of the view and its subviews within the specified content size.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         See the View Layout Deep Dive for more information:
+    ///         <see href="https://gui-cs.github.io/Terminal.GuiV2Docs/docs/layout.html"/>
+    ///     </para>
+    ///     <para>
+    ///         This method is intended to be called by the layout engine to
+    ///         prepare the view for layout and is exposed as a public API primarily for testing purposes.
+    ///     </para>
+    /// </remarks>
+    /// <param name="contentSize"></param>
+    /// <returns><see langword="false"/>If the view could not be laid out (typically because a dependencies was not ready). </returns>
+    public bool Layout (Size contentSize)
+    {
+        // Note, SetRelativeLayout calls SetTextFormatterSize
+        if (SetRelativeLayout (contentSize))
+        {
+            LayoutSubviews ();
+
+            return true;
+        }
+
+        return false;
+    }
+
+    /// <summary>
+    ///     Performs layout of the view and its subviews using the content size of either the <see cref="SuperView"/> or <see cref="Application.Screen"/>.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         See the View Layout Deep Dive for more information:
+    ///         <see href="https://gui-cs.github.io/Terminal.GuiV2Docs/docs/layout.html"/>
+    ///     </para>
+    ///     <para>
+    ///         This method is intended to be called by the layout engine to
+    ///         prepare the view for layout and is exposed as a public API primarily for testing purposes.
+    ///     </para>
+    /// </remarks>
+    /// <returns><see langword="false"/>If the view could not be laid out (typically because dependency was not ready). </returns>
+    public bool Layout ()
+    {
+        return Layout (GetBestGuessSuperViewContentSize ());
+    }
+
     /// <summary>Fired after the View's <see cref="LayoutSubviews"/> method has completed.</summary>
     /// <remarks>
     ///     Subscribe to this event to perform tasks when the <see cref="View"/> has been resized or the layout has
@@ -551,10 +591,9 @@ public partial class View // Layout APIs
     public event EventHandler<LayoutEventArgs>? LayoutStarted;
 
     /// <summary>
-    ///     Adjusts <see cref="Frame"/> given the SuperView's ContentSize (nominally the same as
-    ///     <c>this.SuperView.GetContentSize ()</c>)
-    ///     and the position (<see cref="X"/>, <see cref="Y"/>) and dimension (<see cref="Width"/>, and
-    ///     <see cref="Height"/>).
+    ///     Sets the position and size of this view, relative to the SuperView's ContentSize (nominally the same as
+    ///     <c>this.SuperView.GetContentSize ()</c>) based on the values of <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>,
+    ///     and <see cref="Height"/>.
     /// </summary>
     /// <remarks>
     ///     <para>
@@ -563,9 +602,8 @@ public partial class View // Layout APIs
     ///         are left unchanged.
     ///     </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="Layout"/> on
-    ///         will be called for that subview.
+    ///         This method does not arrange subviews or adornments. It is intended to be called by the layout engine to
+    ///         prepare the view for layout and is exposed as a public API primarily for testing purposes.
     ///     </para>
     ///     <para>
     ///         Some subviews may have SetRelativeLayout called on them as a side effect, particularly in DimAuto scenarios.
@@ -694,12 +732,7 @@ public partial class View // Layout APIs
     /// </remarks>
     internal void LayoutSubviews ()
     {
-        if (!IsInitialized)
-        {
-            Debug.WriteLine ($"WARNING: LayoutSubviews called before view has been initialized. This is likely a bug in {this}");
-        }
-
-        if (!IsLayoutNeeded ())
+        if (!NeedsLayout)
         {
             return;
         }
@@ -750,37 +783,11 @@ public partial class View // Layout APIs
             }
         }
 
-        _layoutNeeded = layoutStillNeeded;
+        _needsLayout = layoutStillNeeded;
 
         OnLayoutComplete (new (contentSize));
     }
 
-    /// <summary>
-    ///     Performs layout of the view and its subviews within the specified content size.
-    /// </summary>
-    /// <param name="contentSize"></param>
-    /// <returns><see langword="false"/>If the view could not be laid out (typically because a dependencies was not ready). </returns>
-    public bool Layout (Size contentSize)
-    {
-        // Note, SetRelativeLayout calls SetTextFormatterSize
-        if (SetRelativeLayout (contentSize))
-        {
-            LayoutSubviews ();
-
-            return true;
-        }
-
-        return false;
-    }
-
-    /// <summary>
-    ///     Performs layout of the view and its subviews using the content size of either the <see cref="SuperView"/> or <see cref="Application.Screen"/>.
-    /// </summary>
-    /// <returns><see langword="false"/>If the view could not be laid out (typically because dependency was not ready). </returns>
-    public bool Layout ()
-    {
-        return Layout (GetBestGuessSuperViewContentSize ());
-    }
 
     /// <summary>
     ///     Raises the <see cref="LayoutComplete"/> event. Called from  <see cref="LayoutSubviews"/> before all sub-views
@@ -796,7 +803,7 @@ public partial class View // Layout APIs
 
 
     // We expose no setter for this to ensure that the ONLY place it's changed is in SetNeedsLayout
-    private bool _layoutNeeded = false;
+    private bool _needsLayout = false;
 
     /// <summary>
     ///     Indicates the View's Frame or the layout of the View's subviews (including Adornments) have
@@ -807,11 +814,13 @@ public partial class View // Layout APIs
     ///     layout.
     /// </para>
     /// </remarks>
-    /// <returns><see langword="true"/> if layout is needed.</returns>
-    public bool IsLayoutNeeded () { return _layoutNeeded; }
+    /// <value>
+    ///     <see langword="true"/> if layout is needed.
+    /// </value>
+    public bool NeedsLayout => _needsLayout;
 
     /// <summary>
-    ///     Sets <see cref="IsLayoutNeeded"/> to return <see langword="true"/>, indicating this View and all of it's subviews (including adornments) need to be laid out in the next Application iteration.
+    ///     Sets <see cref="NeedsLayout"/> to return <see langword="true"/>, indicating this View and all of it's subviews (including adornments) need to be laid out in the next Application iteration.
     /// </summary>
     /// <remarks>
     ///     <para>
@@ -821,13 +830,13 @@ public partial class View // Layout APIs
 
     public void SetLayoutNeeded ()
     {
-        if (IsLayoutNeeded ())
+        if (NeedsLayout)
         {
             // Prevent infinite recursion
             return;
         }
 
-        _layoutNeeded = true;
+        _needsLayout = true;
 
         Margin?.SetLayoutNeeded ();
         Border?.SetLayoutNeeded ();
@@ -839,9 +848,9 @@ public partial class View // Layout APIs
         while (stack.Count > 0)
         {
             View current = stack.Pop ();
-            if (!current.IsLayoutNeeded ())
+            if (!current.NeedsLayout)
             {
-                current._layoutNeeded = true;
+                current._needsLayout = true;
                 current.Margin?.SetLayoutNeeded ();
                 current.Border?.SetLayoutNeeded ();
                 current.Padding?.SetLayoutNeeded ();

+ 1 - 4
Terminal.Gui/Views/Shortcut.cs

@@ -127,9 +127,6 @@ public class Shortcut : View, IOrientation, IDesignable
         Key = key;
         Title = commandText ?? string.Empty;
         Action = action;
-
-        return;
-
     }
 
     // Helper to set Width consistently
@@ -140,7 +137,7 @@ public class Shortcut : View, IOrientation, IDesignable
                          DimAutoStyle.Content,
                          Dim.Func (() =>
                                    {
-                                       if (Subviews [0].IsLayoutNeeded ())
+                                       if (Subviews [0].NeedsLayout)
                                        {
                                            // throw new Exception ();
                                        }

+ 2 - 2
UICatalog/UICatalog.cs

@@ -562,7 +562,7 @@ public class UICatalogApp
                 Width = Dim.Auto (),
                 Height = Dim.Fill (Dim.Func (() =>
                                              {
-                                                 if (_statusBar.IsLayoutNeeded ())
+                                                 if (_statusBar.NeedsLayout)
                                                  {
                                                     // throw new Exception ("DimFunc.Fn aborted because dependent View needs layout.");
                                                  }
@@ -588,7 +588,7 @@ public class UICatalogApp
                 Width = Dim.Fill (),
                 Height = Dim.Fill (Dim.Func (() =>
                                              {
-                                                 if (_statusBar.IsLayoutNeeded ())
+                                                 if (_statusBar.NeedsLayout)
                                                  {
                                                     // throw new Exception ("DimFunc.Fn aborted because dependent View needs layout.");
                                                  }

+ 2 - 2
UnitTests/Application/ApplicationTests.cs

@@ -859,10 +859,10 @@ public class ApplicationTests
                                          Application.RaiseMouseEvent (new () { Flags = MouseFlags.ReportMousePosition });
                                          Assert.False (top.NeedsDisplay);
                                          Assert.False (top.SubViewNeedsDisplay);
-                                         Assert.False (top.IsLayoutNeeded ());
+                                         Assert.False (top.NeedsLayout);
                                          Assert.False (d.NeedsDisplay);
                                          Assert.False (d.SubViewNeedsDisplay);
-                                         Assert.False (d.IsLayoutNeeded ());
+                                         Assert.False (d.NeedsLayout);
                                      }
                                      else
                                      {

+ 4 - 4
UnitTests/View/Adornment/AdornmentTests.cs

@@ -354,8 +354,8 @@ public class AdornmentTests (ITestOutputHelper output)
 
         parent.LayoutStarted += LayoutStarted;
         parent.Margin.Thickness = new Thickness (1, 2, 3, 4);
-        Assert.True (parent.IsLayoutNeeded());
-        Assert.True (parent.Margin.IsLayoutNeeded ());
+        Assert.True (parent.NeedsLayout);
+        Assert.True (parent.Margin.NeedsLayout);
         parent.Layout ();
         Assert.True (raised);
 
@@ -377,8 +377,8 @@ public class AdornmentTests (ITestOutputHelper output)
 
         parent.Margin.LayoutStarted += LayoutStarted;
         parent.Margin.Thickness = new Thickness (1, 2, 3, 4);
-        Assert.True (parent.IsLayoutNeeded ());
-        Assert.True (parent.Margin.IsLayoutNeeded ());
+        Assert.True (parent.NeedsLayout);
+        Assert.True (parent.Margin.NeedsLayout);
         parent.Layout ();
         Assert.True (raised);
 

+ 1 - 1
UnitTests/View/Draw/DrawTests.cs

@@ -405,7 +405,7 @@ public class DrawTests (ITestOutputHelper _output)
     public void Draw_Minimum_Full_Border_With_Empty_Viewport ()
     {
         var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
-        Assert.True (view.IsLayoutNeeded());
+        Assert.True (view.NeedsLayout);
         Assert.True (view.NeedsDisplay);
         view.Layout ();
 

+ 5 - 5
UnitTests/View/Draw/NeedsDisplayTests.cs

@@ -104,15 +104,15 @@ public class NeedsDisplayTests ()
     {
         var view = new View { Width = 2, Height = 2 };
         Assert.True (view.NeedsDisplay);
-        Assert.False (view.IsLayoutNeeded ());
+        Assert.False (view.NeedsLayout);
 
         view.Draw ();
         Assert.False (view.NeedsDisplay);
-        Assert.False (view.IsLayoutNeeded ());
+        Assert.False (view.NeedsLayout);
 
         view.SetLayoutNeeded ();
         Assert.True (view.NeedsDisplay);
-        Assert.True (view.IsLayoutNeeded ());
+        Assert.True (view.NeedsLayout);
     }
 
     [Fact]
@@ -120,11 +120,11 @@ public class NeedsDisplayTests ()
     {
         var view = new View { Width = 2, Height = 2 };
         Assert.True (view.NeedsDisplay);
-        Assert.False (view.IsLayoutNeeded ());
+        Assert.False (view.NeedsLayout);
 
         view.Draw ();
         Assert.False (view.NeedsDisplay);
-        Assert.False (view.IsLayoutNeeded ());
+        Assert.False (view.NeedsLayout);
 
         // SRL won't change anything since the view is Absolute
         view.SetRelativeLayout (Application.Screen.Size);

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

@@ -254,7 +254,7 @@ public class DimTests
                        Assert.Equal (18, v6.Frame.Height); // 89*20%=18
 
                        w.Width = 200;
-                       Assert.True (t.IsLayoutNeeded ());
+                       Assert.True (t.NeedsLayout);
                        w.Height = 200;
                        t.LayoutSubviews ();
 

+ 50 - 50
UnitTests/View/Layout/SetLayoutTests.cs

@@ -296,27 +296,27 @@ public class SetLayoutTests (ITestOutputHelper output)
     public void Set_X_PosAbsolute_Layout_Is_Implicit ()
     {
         var v = new View ();
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (0, v.Frame.X);
 
         v.X = 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (1, v.Frame.X);
 
         v.X = 2;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (2, v.Frame.X);
 
         v.X = Pos.Absolute (3);
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (3, v.Frame.X);
 
         v.X = Pos.Absolute (3) + 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (4, v.Frame.X);
 
         v.X = 1 + Pos.Absolute (1) + 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (3, v.Frame.X);
 
     }
@@ -325,31 +325,31 @@ public class SetLayoutTests (ITestOutputHelper output)
     public void Set_X_Non_PosAbsolute_Explicit_Layout_Required ()
     {
         var v = new View ();
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (0, v.Frame.X);
 
         v.X = Pos.Center ();
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.X);
 
         v.X = Pos.Percent (50);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.X);
 
         v.X = Pos.Align (Alignment.Center);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.X);
 
         v.X = Pos.Func (() => 10);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.X);
 
         v.X = Pos.AnchorEnd ();
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.X);
 
         v.X = Pos.Top (new View ());
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.X);
     }
 
@@ -358,27 +358,27 @@ public class SetLayoutTests (ITestOutputHelper output)
     public void Set_Y_PosAbsolute_Layout_Is_Implicit ()
     {
         var v = new View ();
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Y);
 
         v.Y = 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (1, v.Frame.Y);
 
         v.Y = 2;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (2, v.Frame.Y);
 
         v.Y = Pos.Absolute (3);
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (3, v.Frame.Y);
 
         v.Y = Pos.Absolute (3) + 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (4, v.Frame.Y);
 
         v.Y = 1 + Pos.Absolute (1) + 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (3, v.Frame.Y);
 
     }
@@ -387,31 +387,31 @@ public class SetLayoutTests (ITestOutputHelper output)
     public void Set_Y_Non_PosAbsolute_Explicit_Layout_Required ()
     {
         var v = new View ();
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Y);
 
         v.Y = Pos.Center ();
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Y);
 
         v.Y = Pos.Percent (50);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Y);
 
         v.Y = Pos.Align (Alignment.Center);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Y);
 
         v.Y = Pos.Func (() => 10);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Y);
 
         v.Y = Pos.AnchorEnd ();
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Y);
 
         v.Y = Pos.Top (new View ());
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Y);
     }
 
@@ -420,27 +420,27 @@ public class SetLayoutTests (ITestOutputHelper output)
     public void Set_Width_DimAbsolute_Layout_Is_Implicit ()
     {
         var v = new View ();
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Width);
 
         v.Width = 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (1, v.Frame.Width);
 
         v.Width = 2;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (2, v.Frame.Width);
 
         v.Width = Dim.Absolute (3);
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (3, v.Frame.Width);
 
         v.Width = Dim.Absolute (3) + 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (4, v.Frame.Width);
 
         v.Width = 1 + Dim.Absolute (1) + 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (3, v.Frame.Width);
 
     }
@@ -449,27 +449,27 @@ public class SetLayoutTests (ITestOutputHelper output)
     public void Set_Width_Non_DimAbsolute_Explicit_Layout_Required ()
     {
         var v = new View ();
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Width);
 
         v.Width = Dim.Auto();
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Width);
 
         v.Width = Dim.Percent (50);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Width);
 
         v.Width = Dim.Fill ();
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Width);
 
         v.Width = Dim.Func (() => 10);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Width);
 
         v.Width = Dim.Width(new View ());
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Width);
     }
 
@@ -477,27 +477,27 @@ public class SetLayoutTests (ITestOutputHelper output)
     public void Set_Height_DimAbsolute_Layout_Is_Implicit ()
     {
         var v = new View ();
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Height);
 
         v.Height = 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (1, v.Frame.Height);
 
         v.Height = 2;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (2, v.Frame.Height);
 
         v.Height = Dim.Absolute (3);
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (3, v.Frame.Height);
 
         v.Height = Dim.Absolute (3) + 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (4, v.Frame.Height);
 
         v.Height = 1 + Dim.Absolute (1) + 1;
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (3, v.Frame.Height);
 
     }
@@ -506,27 +506,27 @@ public class SetLayoutTests (ITestOutputHelper output)
     public void Set_Height_Non_DimAbsolute_Explicit_Layout_Required ()
     {
         var v = new View ();
-        Assert.False (v.IsLayoutNeeded ());
+        Assert.False (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Height);
 
         v.Height = Dim.Auto ();
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Height);
 
         v.Height = Dim.Percent (50);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Height);
 
         v.Height = Dim.Fill ();
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Height);
 
         v.Height = Dim.Func (() => 10);
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Height);
 
         v.Height = Dim.Height (new View ());
-        Assert.True (v.IsLayoutNeeded ());
+        Assert.True (v.NeedsLayout);
         Assert.Equal (0, v.Frame.Height);
     }
 

+ 2 - 2
UnitTests/View/TextTests.cs

@@ -715,7 +715,7 @@ w ";
         Assert.Equal (new (0, 0, 2, 1), lbl.Frame);
         Assert.Equal (new (0, 0, 2, 1), lbl._needsDisplayRect);
         Assert.Equal (new (0, 0, 80, 25), lbl.SuperView._needsDisplayRect);
-        Assert.True (lbl.SuperView.IsLayoutNeeded ());
+        Assert.True (lbl.SuperView.NeedsLayout);
         Application.RunIteration (ref rs);
 
         Assert.Equal ("12  ", GetContents ());
@@ -1127,7 +1127,7 @@ w ";
             Width = Dim.Auto (DimAutoStyle.Text),
             Height = Dim.Auto (DimAutoStyle.Text)
         };
-        Assert.True (view.IsLayoutNeeded ());
+        Assert.True (view.NeedsLayout);
         view.Layout ();
         Assert.Equal (new (0, 0, 5, 1), view.Frame);
         Assert.Equal (new (0, 0, 5, 1), view.Viewport);

+ 3 - 0
UnitTests/Views/DateFieldTests.cs

@@ -10,6 +10,7 @@ public class DateFieldTests
     public void Constructors_Defaults ()
     {
         var df = new DateField ();
+        df.Layout ();
         Assert.Equal (DateTime.MinValue, df.Date);
         Assert.Equal (1, df.CursorPosition);
         Assert.Equal (new Rectangle (0, 0, 12, 1), df.Frame);
@@ -17,12 +18,14 @@ public class DateFieldTests
 
         DateTime date = DateTime.Now;
         df = new DateField (date);
+        df.Layout ();
         Assert.Equal (date, df.Date);
         Assert.Equal (1, df.CursorPosition);
         Assert.Equal (new Rectangle (0, 0, 12, 1), df.Frame);
         Assert.Equal ($" {date.ToString (CultureInfo.InvariantCulture.DateTimeFormat.ShortDatePattern)}", df.Text);
 
         df = new DateField (date) { X = 1, Y = 2 };
+        df.Layout ();
         Assert.Equal (date, df.Date);
         Assert.Equal (1, df.CursorPosition);
         Assert.Equal (new Rectangle (1, 2, 12, 1), df.Frame);

+ 2 - 2
UnitTests/Views/HexViewTests.cs

@@ -22,7 +22,7 @@ public class HexViewTests
     public void BytesPerLine_Calculates_Correctly (int width, int expectedBpl)
     {
         var hv = new HexView (LoadStream (null, out long _)) { Width = width, Height = 10, AddressWidth = 0 };
-        hv.LayoutSubviews ();
+        hv.Layout ();
 
         Assert.Equal (expectedBpl, hv.BytesPerLine);
     }
@@ -370,7 +370,7 @@ public class HexViewTests
         Application.Top = new Toplevel ();
         Application.Top.Add (hv);
 
-        hv.LayoutSubviews ();
+        hv.Layout ();
 
         Assert.True (hv.NewKeyDownEvent (Key.End));
         Assert.Equal (MEM_STRING_LENGTH - 1, hv.DisplayStart);

+ 4 - 2
UnitTests/Views/LabelTests.cs

@@ -211,11 +211,11 @@ This TextFormatter (tf2) with fill will be cleared on rewritten.       ",
                                                      );
 
         Assert.False (label.NeedsDisplay);
-        Assert.False (label.IsLayoutNeeded ());
+        Assert.False (label.NeedsLayout);
         Assert.False (label.SubViewNeedsDisplay);
         label.Text = "This label is rewritten.";
         Assert.True (label.NeedsDisplay);
-        Assert.True (label.IsLayoutNeeded ());
+        Assert.True (label.NeedsLayout);
         //Assert.False (label.SubViewNeedsDisplay);
         label.Draw ();
 
@@ -1360,6 +1360,7 @@ e
         Application.Navigation = new ();
         Application.Top = new ();
         Application.Top.Add (otherView, label, nextView);
+        Application.Top.Layout ();
 
         Application.Top.SetFocus ();
 
@@ -1432,6 +1433,7 @@ e
         };
         Application.Top.Add (label, otherView);
         Application.Top.SetFocus ();
+        Application.Top.Layout ();
 
         Assert.True (label.CanFocus);
         Assert.True (label.HasFocus);

+ 3 - 0
UnitTests/Views/LineViewTests.cs

@@ -10,6 +10,7 @@ public class LineViewTests
 
         Assert.Equal (Orientation.Horizontal, horizontal.Orientation);
         Assert.Equal (Dim.Fill (), horizontal.Width);
+        horizontal.Layout ();
         Assert.Equal (1, horizontal.Frame.Height);
     }
 
@@ -21,6 +22,7 @@ public class LineViewTests
 
         Assert.Equal (Orientation.Horizontal, horizontal.Orientation);
         Assert.Equal (Dim.Fill (), horizontal.Width);
+        horizontal.Layout ();
         Assert.Equal (1, horizontal.Frame.Height);
     }
 
@@ -32,6 +34,7 @@ public class LineViewTests
 
         Assert.Equal (Orientation.Vertical, vert.Orientation);
         Assert.Equal (Dim.Fill (), vert.Height);
+        vert.Layout ();
         Assert.Equal (1, vert.Frame.Width);
     }
 }

+ 2 - 0
UnitTests/Views/MenuBarTests.cs

@@ -879,6 +879,7 @@ public class MenuBarTests (ITestOutputHelper output)
                 new (new MenuItem [] { new ("One", "", null), new ("Two", "", null) })
             ]
         };
+        menu.Layout ();
 
         Assert.Equal (new (-1, -1), new Point (menu.Frame.X, menu.Frame.Y));
 
@@ -958,6 +959,7 @@ public class MenuBarTests (ITestOutputHelper output)
                 new (new MenuItem [] { new ("One", "", null), new ("Two", "", null) })
             ]
         };
+        menu.Layout ();
 
         Assert.Equal (new (-2, -1), new Point (menu.Frame.X, menu.Frame.Y));
 

+ 6 - 0
UnitTests/Views/ProgressBarTests.cs

@@ -105,16 +105,20 @@ public class ProgressBarTests
         var pb2 = new ProgressBar { ProgressBarStyle = ProgressBarStyle.MarqueeContinuous };
 
         pb1.ProgressBarFormat = ProgressBarFormat.Simple;
+        pb1.Layout ();
         Assert.Equal (ProgressBarFormat.Simple, pb1.ProgressBarFormat);
         Assert.Equal (1, pb1.Frame.Height);
         pb2.ProgressBarFormat = ProgressBarFormat.Simple;
+        pb2.Layout ();
         Assert.Equal (ProgressBarFormat.Simple, pb2.ProgressBarFormat);
         Assert.Equal (1, pb2.Frame.Height);
 
         pb1.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
+        pb1.Layout ();
         Assert.Equal (ProgressBarFormat.SimplePlusPercentage, pb1.ProgressBarFormat);
         Assert.Equal (1, pb1.Frame.Height);
         pb2.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
+        pb2.Layout ();
         Assert.Equal (ProgressBarFormat.SimplePlusPercentage, pb2.ProgressBarFormat);
         Assert.Equal (1, pb2.Frame.Height);
     }
@@ -126,9 +130,11 @@ public class ProgressBarTests
         var pb = new ProgressBar ();
 
         pb.ProgressBarFormat = ProgressBarFormat.Simple;
+        pb.Layout ();
         Assert.Equal (1, pb.Frame.Height);
 
         pb.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
+        pb.Layout ();
         Assert.Equal (1, pb.Frame.Height);
     }
 

+ 3 - 0
UnitTests/Views/ScrollViewTests.cs

@@ -65,6 +65,7 @@ public class ScrollViewTests (ITestOutputHelper output)
         Assert.False (sv.AutoHideScrollBars);
         Assert.False (sv.ShowHorizontalScrollIndicator);
         Assert.True (sv.ShowVerticalScrollIndicator);
+        top.Layout ();
         sv.Draw ();
 
         TestHelpers.AssertDriverContentsAre (
@@ -89,6 +90,7 @@ public class ScrollViewTests (ITestOutputHelper output)
         Assert.False (sv.AutoHideScrollBars);
         Assert.True (sv.ShowHorizontalScrollIndicator);
         Assert.False (sv.ShowVerticalScrollIndicator);
+        top.Layout ();
         sv.Draw ();
 
         TestHelpers.AssertDriverContentsAre (
@@ -113,6 +115,7 @@ public class ScrollViewTests (ITestOutputHelper output)
         Assert.False (sv.AutoHideScrollBars);
         Assert.False (sv.ShowHorizontalScrollIndicator);
         Assert.False (sv.ShowVerticalScrollIndicator);
+        top.Layout ();
         sv.Draw ();
 
         TestHelpers.AssertDriverContentsAre (

+ 5 - 3
UnitTests/Views/ShortcutTests.cs

@@ -20,8 +20,10 @@ public class ShortcutTests
     public void Size_Defaults ()
     {
         var shortcut = new Shortcut ();
+        shortcut.BeginInit();
+        shortcut.EndInit();
 
-        shortcut.SetRelativeLayout (new (100, 100));
+        shortcut.Layout ();
         Assert.Equal (2, shortcut.Frame.Width);
         Assert.Equal (1, shortcut.Frame.Height);
         Assert.Equal (2, shortcut.Viewport.Width);
@@ -31,10 +33,10 @@ public class ShortcutTests
         Assert.Equal (1, shortcut.CommandView.Viewport.Height);
 
         Assert.Equal (0, shortcut.HelpView.Viewport.Width);
-        Assert.Equal (1, shortcut.HelpView.Viewport.Height);
+        Assert.Equal (0, shortcut.HelpView.Viewport.Height);
 
         Assert.Equal (0, shortcut.KeyView.Viewport.Width);
-        Assert.Equal (1, shortcut.KeyView.Viewport.Height);
+        Assert.Equal (0, shortcut.KeyView.Viewport.Height);
 
         //  0123456789
         // "   0  A "