ソースを参照

Merge pull request #3716 from tig/v2_3715-Pos-Has

Fixes #3715 - `Pos.Has (Type, out Pos)` -> `Pos.Has<T> (out Pos)`
Tig 11 ヶ月 前
コミット
0626da3011

+ 7 - 1
Terminal.Gui/View/Layout/Dim.cs

@@ -119,12 +119,18 @@ public abstract record Dim : IEqualityOperators<Dim, Dim, bool>
                             Style: style);
                             Style: style);
     }
     }
 
 
+    /// <summary>
+    ///     Creates a <see cref="Dim"/> object that fills the dimension, leaving no margin.
+    /// </summary>
+    /// <returns>The Fill dimension.</returns>
+    public static Dim? Fill () { return new DimFill (0); }
+
     /// <summary>
     /// <summary>
     ///     Creates a <see cref="Dim"/> object that fills the dimension, leaving the specified margin.
     ///     Creates a <see cref="Dim"/> object that fills the dimension, leaving the specified margin.
     /// </summary>
     /// </summary>
     /// <returns>The Fill dimension.</returns>
     /// <returns>The Fill dimension.</returns>
     /// <param name="margin">Margin to use.</param>
     /// <param name="margin">Margin to use.</param>
-    public static Dim? Fill (int margin = 0) { return new DimFill (margin); }
+    public static Dim? Fill (Dim margin) { return new DimFill (margin); }
 
 
     /// <summary>
     /// <summary>
     ///     Creates a function <see cref="Dim"/> object that computes the dimension by executing the provided function.
     ///     Creates a function <see cref="Dim"/> object that computes the dimension by executing the provided function.

+ 14 - 14
Terminal.Gui/View/Layout/DimAuto.cs

@@ -131,9 +131,9 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
                     notDependentSubViews = includedSubviews.Where (
                     notDependentSubViews = includedSubviews.Where (
                                                                    v => v.Width is { }
                                                                    v => v.Width is { }
                                                                         && (v.X is PosAbsolute or PosFunc || v.Width is DimAuto or DimAbsolute or DimFunc) // BUGBUG: We should use v.X.Has and v.Width.Has?
                                                                         && (v.X is PosAbsolute or PosFunc || v.Width is DimAuto or DimAbsolute or DimFunc) // BUGBUG: We should use v.X.Has and v.Width.Has?
-                                                                        && !v.X.Has (typeof (PosAnchorEnd), out _)
-                                                                        && !v.X.Has (typeof (PosAlign), out _)
-                                                                        && !v.X.Has (typeof (PosCenter), out _)
+                                                                        && !v.X.Has<PosAnchorEnd> (out _)
+                                                                        && !v.X.Has<PosAlign> (out _)
+                                                                        && !v.X.Has<PosCenter> (out _)
                                                                         && !v.Width.Has<DimFill> (out _)
                                                                         && !v.Width.Has<DimFill> (out _)
                                                                         && !v.Width.Has<DimPercent> (out _)
                                                                         && !v.Width.Has<DimPercent> (out _)
                                                                   )
                                                                   )
@@ -144,9 +144,9 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
                     notDependentSubViews = includedSubviews.Where (
                     notDependentSubViews = includedSubviews.Where (
                                                                    v => v.Height is { }
                                                                    v => v.Height is { }
                                                                         && (v.Y is PosAbsolute or PosFunc || v.Height is DimAuto or DimAbsolute or DimFunc) // BUGBUG: We should use v.Y.Has and v.Height.Has?
                                                                         && (v.Y is PosAbsolute or PosFunc || v.Height is DimAuto or DimAbsolute or DimFunc) // BUGBUG: We should use v.Y.Has and v.Height.Has?
-                                                                        && !v.Y.Has (typeof (PosAnchorEnd), out _)
-                                                                        && !v.Y.Has (typeof (PosAlign), out _)
-                                                                        && !v.Y.Has (typeof (PosCenter), out _)
+                                                                        && !v.Y.Has<PosAnchorEnd> (out _)
+                                                                        && !v.Y.Has<PosAlign> (out _)
+                                                                        && !v.Y.Has<PosCenter> (out _)
                                                                         && !v.Height.Has<DimFill> (out _)
                                                                         && !v.Height.Has<DimFill> (out _)
                                                                         && !v.Height.Has<DimPercent> (out _)
                                                                         && !v.Height.Has<DimPercent> (out _)
                                                                   )
                                                                   )
@@ -190,11 +190,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
 
                 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<PosCenter> (out _)).ToList ();
                 }
                 }
                 else
                 else
                 {
                 {
-                    centeredSubViews = us.Subviews.Where (v => v.Y.Has (typeof (PosCenter), out _)).ToList ();
+                    centeredSubViews = us.Subviews.Where (v => v.Y.Has<PosCenter> (out _)).ToList ();
                 }
                 }
 
 
                 viewsNeedingLayout.AddRange (centeredSubViews);
                 viewsNeedingLayout.AddRange (centeredSubViews);
@@ -239,14 +239,14 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
                                                               {
                                                               {
                                                                   if (dimension == Dimension.Width)
                                                                   if (dimension == Dimension.Width)
                                                                   {
                                                                   {
-                                                                      if (v.X.Has (typeof (PosAlign), out Pos posAlign))
+                                                                      if (v.X.Has<PosAlign> (out Pos posAlign))
                                                                       {
                                                                       {
                                                                           return ((PosAlign)posAlign).GroupId;
                                                                           return ((PosAlign)posAlign).GroupId;
                                                                       }
                                                                       }
                                                                   }
                                                                   }
                                                                   else
                                                                   else
                                                                   {
                                                                   {
-                                                                      if (v.Y.Has (typeof (PosAlign), out Pos posAlign))
+                                                                      if (v.Y.Has<PosAlign> (out Pos posAlign))
                                                                       {
                                                                       {
                                                                           return ((PosAlign)posAlign).GroupId;
                                                                           return ((PosAlign)posAlign).GroupId;
                                                                       }
                                                                       }
@@ -294,11 +294,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
 
                 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<PosAnchorEnd> (out _)).ToList ();
                 }
                 }
                 else
                 else
                 {
                 {
-                    anchoredSubViews = includedSubviews.Where (v => v.Y.Has (typeof (PosAnchorEnd), out _)).ToList ();
+                    anchoredSubViews = includedSubviews.Where (v => v.Y.Has<PosAnchorEnd> (out _)).ToList ();
                 }
                 }
 
 
                 viewsNeedingLayout.AddRange (anchoredSubViews);
                 viewsNeedingLayout.AddRange (anchoredSubViews);
@@ -336,11 +336,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
 
                 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<PosView> (out _)).ToList ();
                 }
                 }
                 else
                 else
                 {
                 {
-                    posViewSubViews = includedSubviews.Where (v => v.Y.Has (typeof (PosView), out _)).ToList ();
+                    posViewSubViews = includedSubviews.Where (v => v.Y.Has<PosView> (out _)).ToList ();
                 }
                 }
 
 
                 for (var i = 0; i < posViewSubViews.Count; i++)
                 for (var i = 0; i < posViewSubViews.Count; i++)

+ 2 - 2
Terminal.Gui/View/Layout/DimFill.cs

@@ -9,10 +9,10 @@ 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.
 /// </remarks>
 /// </remarks>
 /// <param name="Margin">The margin to not fill.</param>
 /// <param name="Margin">The margin to not fill.</param>
-public record DimFill (int Margin) : Dim
+public record DimFill (Dim Margin) : Dim
 {
 {
     /// <inheritdoc/>
     /// <inheritdoc/>
     public override string ToString () { return $"Fill({Margin})"; }
     public override string ToString () { return $"Fill({Margin})"; }
 
 
-    internal override int GetAnchor (int size) { return size - Margin; }
+    internal override int GetAnchor (int size) { return size - Margin.GetAnchor(0); }
 }
 }

+ 9 - 16
Terminal.Gui/View/Layout/Pos.cs

@@ -331,27 +331,20 @@ public abstract record Pos
     internal virtual bool ReferencesOtherViews () { return false; }
     internal virtual bool ReferencesOtherViews () { return false; }
 
 
     /// <summary>
     /// <summary>
-    ///     Indicates whether the specified type is in the hierarchy of this Pos object.
+    ///     Indicates whether the specified type <typeparamref name="T"/> is in the hierarchy of this Pos object.
     /// </summary>
     /// </summary>
-    /// <param name="type"></param>
-    /// <param name="pos"></param>
+    /// <param name="pos">A reference to this <see cref="Pos}"/> instance.</param>
     /// <returns></returns>
     /// <returns></returns>
-    public bool Has (Type type, out Pos pos)
+    public bool Has<T> (out Pos pos) where T : Pos
     {
     {
         pos = this;
         pos = this;
-        if (type == GetType ())
-        {
-            return true;
-        }
-
-        // If we are a PosCombine, we have to check the left and right
-        // to see if they are of the type we are looking for.
-        if (this is PosCombine { } combine && (combine.Left.Has (type, out pos) || combine.Right.Has (type, out pos)))
-        {
-            return true;
-        }
 
 
-        return false;
+        return this switch
+               {
+                   PosCombine combine => combine.Left.Has<T> (out pos) || combine.Right.Has<T> (out pos),
+                   T => true,
+                   _ => false
+               };
     }
     }
 
 
     #endregion virtual methods
     #endregion virtual methods

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

@@ -67,11 +67,11 @@ public record PosAlign : Pos
                                                v =>
                                                v =>
                                                {
                                                {
                                                    return dimension switch
                                                    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
-                                                          };
+                                                   {
+                                                       Dimension.Width when v.X is PosAlign alignX => alignX.GroupId == groupId,
+                                                       Dimension.Height when v.Y is PosAlign alignY => alignY.GroupId == groupId,
+                                                       _ => false
+                                                   };
                                                })
                                                })
                                        .ToList ();
                                        .ToList ();
 
 
@@ -150,7 +150,7 @@ public record PosAlign : Pos
                                                   {
                                                   {
                                                       switch (dimension)
                                                       switch (dimension)
                                                       {
                                                       {
-                                                          case Dimension.Width when v.X.Has (typeof (PosAlign), out Pos pos):
+                                                          case Dimension.Width when v.X.Has<PosAlign> (out Pos pos):
 
 
                                                               if (pos is PosAlign posAlignX && posAlignX.GroupId == groupId)
                                                               if (pos is PosAlign posAlignX && posAlignX.GroupId == groupId)
                                                               {
                                                               {
@@ -158,7 +158,7 @@ public record PosAlign : Pos
                                                               }
                                                               }
 
 
                                                               break;
                                                               break;
-                                                          case Dimension.Height when v.Y.Has (typeof (PosAlign), out Pos pos):
+                                                          case Dimension.Height when v.Y.Has<PosAlign> (out Pos pos):
                                                               if (pos is PosAlign posAlignY && posAlignY.GroupId == groupId)
                                                               if (pos is PosAlign posAlignY && posAlignY.GroupId == groupId)
                                                               {
                                                               {
                                                                   return posAlignY;
                                                                   return posAlignY;

+ 11 - 9
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -70,16 +70,18 @@ public class Wizard : Dialog
         ButtonAlignmentModes |= AlignmentModes.IgnoreFirstOrLast;
         ButtonAlignmentModes |= AlignmentModes.IgnoreFirstOrLast;
         BorderStyle = LineStyle.Double;
         BorderStyle = LineStyle.Double;
 
 
+        BackButton = new () { Text = Strings.wzBack };
+        NextFinishButton = new ()
+        {
+            Text = Strings.wzFinish,
+            IsDefault = true
+        };
+
         //// Add a horiz separator
         //// Add a horiz separator
-        var separator = new LineView (Orientation.Horizontal) { Y = Pos.AnchorEnd (2) };
-        Add (separator);
+        var separator = new LineView (Orientation.Horizontal) { Y = Pos.Top (BackButton) - 1 };
 
 
-        // BUGBUG: Space is to work around https://github.com/gui-cs/Terminal.Gui/issues/1812
-        BackButton = new () { Text = Strings.wzBack };
+        Add (separator);
         AddButton (BackButton);
         AddButton (BackButton);
-
-        NextFinishButton = new () { Text = Strings.wzFinish };
-        NextFinishButton.IsDefault = true;
         AddButton (NextFinishButton);
         AddButton (NextFinishButton);
 
 
         BackButton.Accept += BackBtn_Clicked;
         BackButton.Accept += BackBtn_Clicked;
@@ -495,14 +497,14 @@ public class Wizard : Dialog
             // If we're modal, then we expand the WizardStep so that the top and side 
             // If we're modal, then we expand the WizardStep so that the top and side 
             // borders and not visible. The bottom border is the separator above the buttons.
             // borders and not visible. The bottom border is the separator above the buttons.
             step.X = step.Y = 0;
             step.X = step.Y = 0;
-            step.Height = Dim.Fill (2); // for button frame
+            step.Height = Dim.Fill (Dim.Func (() => IsInitialized ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height + 1 : 1)); // for button frame (+1 for lineView)
             step.Width = Dim.Fill ();
             step.Width = Dim.Fill ();
         }
         }
         else
         else
         {
         {
             // If we're not a modal, then we show the border around the WizardStep
             // If we're not a modal, then we show the border around the WizardStep
             step.X = step.Y = 0;
             step.X = step.Y = 0;
-            step.Height = Dim.Fill (1); // for button frame
+            step.Height = Dim.Fill (Dim.Func (() => IsInitialized ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height + 1 : 2)); // for button frame (+1 for lineView)
             step.Width = Dim.Fill ();
             step.Width = Dim.Fill ();
         }
         }
     }
     }

+ 2 - 1
Terminal.Gui/Views/Wizard/WizardStep.cs

@@ -60,6 +60,7 @@ public class WizardStep : View
         TabStop = TabBehavior.TabStop;
         TabStop = TabBehavior.TabStop;
         CanFocus = true;
         CanFocus = true;
         BorderStyle = LineStyle.None;
         BorderStyle = LineStyle.None;
+
         base.Add (_contentView);
         base.Add (_contentView);
 
 
         base.Add (_helpTextView);
         base.Add (_helpTextView);
@@ -191,7 +192,7 @@ public class WizardStep : View
     internal void ShowHide ()
     internal void ShowHide ()
     {
     {
         _contentView.Height = Dim.Fill ();
         _contentView.Height = Dim.Fill ();
-        _helpTextView.Height = Dim.Fill ();
+        _helpTextView.Height = Dim.Height(_contentView);
         _helpTextView.Width = Dim.Fill ();
         _helpTextView.Width = Dim.Fill ();
 
 
         if (_contentView.InternalSubviews?.Count > 0)
         if (_contentView.InternalSubviews?.Count > 0)

+ 3 - 3
UICatalog/KeyBindingsDialog.cs

@@ -19,8 +19,8 @@ internal class KeyBindingsDialog : Dialog
     {
     {
         Title = "Keybindings";
         Title = "Keybindings";
 
 
-        Height = Dim.Percent(80);
-        Width = Dim.Percent(80);
+        Height = Dim.Percent (80);
+        Width = Dim.Percent (80);
         if (ViewTracker.Instance == null)
         if (ViewTracker.Instance == null)
         {
         {
             ViewTracker.Initialize ();
             ViewTracker.Initialize ();
@@ -32,7 +32,7 @@ internal class KeyBindingsDialog : Dialog
         _commandsListView = new ListView
         _commandsListView = new ListView
         {
         {
             Width = Dim.Percent (50),
             Width = Dim.Percent (50),
-            Height = Dim.Fill () - 1,
+            Height = Dim.Fill (Dim.Func (() => IsInitialized ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height : 1)),
             Source = new ListWrapper<Command> (_commands),
             Source = new ListWrapper<Command> (_commands),
             SelectedItem = 0
             SelectedItem = 0
         };
         };

+ 8 - 1
UICatalog/Scenarios/WizardAsView.cs

@@ -57,7 +57,14 @@ public class WizardAsView : Scenario
         topLevel.Add (menu);
         topLevel.Add (menu);
 
 
         // No need for a Title because the border is disabled
         // No need for a Title because the border is disabled
-        var wizard = new Wizard { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () };
+        var wizard = new Wizard
+        {
+            X = 0,
+            Y = 0,
+            Width = Dim.Fill (),
+            Height = Dim.Fill (),
+            ShadowStyle = ShadowStyle.None
+        };
 
 
         // Set Mdoal to false to cause the Wizard class to render without a frame and
         // Set Mdoal to false to cause the Wizard class to render without a frame and
         // behave like an non-modal View (vs. a modal/pop-up Window).
         // behave like an non-modal View (vs. a modal/pop-up Window).

+ 12 - 2
UICatalog/Scenarios/Wizards.cs

@@ -1,4 +1,5 @@
 using System;
 using System;
+using System.Linq;
 using Terminal.Gui;
 using Terminal.Gui;
 
 
 namespace UICatalog.Scenarios;
 namespace UICatalog.Scenarios;
@@ -276,17 +277,26 @@ public class Wizards : Scenario
                                                X = 0,
                                                X = 0,
                                                Y = 0,
                                                Y = 0,
                                                Width = Dim.Fill (),
                                                Width = Dim.Fill (),
-                                               Height = Dim.Fill (1),
                                                WordWrap = true,
                                                WordWrap = true,
                                                AllowsTab = false,
                                                AllowsTab = false,
                                                ColorScheme = Colors.ColorSchemes ["Base"]
                                                ColorScheme = Colors.ColorSchemes ["Base"]
                                            };
                                            };
+
+                                           someText.Height = Dim.Fill (
+                                                                       Dim.Func (
+                                                                                 () => someText.SuperView is { IsInitialized: true }
+                                                                                           ? someText.SuperView.Subviews
+                                                                                                     .First (view => view.Y.Has<PosAnchorEnd> (out _))
+                                                                                                     .Frame.Height
+                                                                                           : 1));
                                            var help = "This is helpful.";
                                            var help = "This is helpful.";
                                            fourthStep.Add (someText);
                                            fourthStep.Add (someText);
 
 
                                            var hideHelpBtn = new Button
                                            var hideHelpBtn = new Button
                                            {
                                            {
-                                               Text = "Press me to show/hide help", X = Pos.Center (), Y = Pos.AnchorEnd (1)
+                                               Text = "Press me to show/hide help",
+                                               X = Pos.Center (),
+                                               Y = Pos.AnchorEnd ()
                                            };
                                            };
 
 
                                            hideHelpBtn.Accept += (s, e) =>
                                            hideHelpBtn.Accept += (s, e) =>

+ 2 - 2
UICatalog/UICatalog.cs

@@ -477,7 +477,7 @@ public class UICatalogApp
                 ShVersion = new ()
                 ShVersion = new ()
                 {
                 {
                     Title = "Version Info",
                     Title = "Version Info",
-                    CanFocus = false
+                    CanFocus = false,
                 };
                 };
 
 
                 var statusBarShortcut = new Shortcut
                 var statusBarShortcut = new Shortcut
@@ -546,7 +546,7 @@ public class UICatalogApp
                 X = 0,
                 X = 0,
                 Y = 1,
                 Y = 1,
                 Width = Dim.Auto (),
                 Width = Dim.Auto (),
-                Height = Dim.Fill (1),
+                Height = Dim.Fill (Dim.Func (() => IsInitialized ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height : 1)),
                 AllowsMarking = false,
                 AllowsMarking = false,
                 CanFocus = true,
                 CanFocus = true,
                 Title = "_Categories",
                 Title = "_Categories",

+ 16 - 3
UnitTests/View/Layout/Dim.FillTests.cs

@@ -127,15 +127,28 @@ public class DimFillTests (ITestOutputHelper output)
     {
     {
         var testMargin = 0;
         var testMargin = 0;
         Dim dim = Dim.Fill ();
         Dim dim = Dim.Fill ();
-        Assert.Equal ($"Fill({testMargin})", dim.ToString ());
+        Assert.Equal (testMargin, dim!.GetAnchor(0));
 
 
         testMargin = 0;
         testMargin = 0;
         dim = Dim.Fill (testMargin);
         dim = Dim.Fill (testMargin);
-        Assert.Equal ($"Fill({testMargin})", dim.ToString ());
+        Assert.Equal (testMargin, dim!.GetAnchor (0));
 
 
         testMargin = 5;
         testMargin = 5;
         dim = Dim.Fill (testMargin);
         dim = Dim.Fill (testMargin);
-        Assert.Equal ($"Fill({testMargin})", dim.ToString ());
+        Assert.Equal (-testMargin, dim!.GetAnchor (0));
+    }
+
+    [Fact]
+    public void DimFill_Margin_Is_Dim_SetsValue ()
+    {
+        Dim testMargin = Dim.Func (() => 0);
+        Dim dim = Dim.Fill (testMargin);
+        Assert.Equal (0, dim!.GetAnchor (0));
+
+
+        testMargin = Dim.Func (() => 5);
+        dim = Dim.Fill (testMargin);
+        Assert.Equal (-5, dim!.GetAnchor (0));
     }
     }
 
 
     [Fact]
     [Fact]

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

@@ -315,7 +315,7 @@ public class DimTests
                        Assert.Equal (49, f1.Frame.Width); // 50-1=49
                        Assert.Equal (49, f1.Frame.Width); // 50-1=49
                        Assert.Equal (5, f1.Frame.Height);
                        Assert.Equal (5, f1.Frame.Height);
 
 
-                       Assert.Equal ("Fill(0)", f2.Width.ToString ());
+                       Assert.Equal ("Fill(Absolute(0))", f2.Width.ToString ());
                        Assert.Equal ("Absolute(5)", f2.Height.ToString ());
                        Assert.Equal ("Absolute(5)", f2.Height.ToString ());
                        Assert.Equal (49, f2.Frame.Width); // 50-1=49
                        Assert.Equal (49, f2.Frame.Width); // 50-1=49
                        Assert.Equal (5, f2.Frame.Height);
                        Assert.Equal (5, f2.Frame.Height);
@@ -325,7 +325,7 @@ public class DimTests
 #else
 #else
                        Assert.Equal ($"Combine(View(Width,FrameView(){f1.Border.Frame})-Absolute(2))", v1.Width.ToString ());
                        Assert.Equal ($"Combine(View(Width,FrameView(){f1.Border.Frame})-Absolute(2))", v1.Width.ToString ());
 #endif
 #endif
-                       Assert.Equal ("Combine(Fill(0)-Absolute(2))", v1.Height.ToString ());
+                       Assert.Equal ("Combine(Fill(Absolute(0))-Absolute(2))", v1.Height.ToString ());
                        Assert.Equal (47, v1.Frame.Width); // 49-2=47
                        Assert.Equal (47, v1.Frame.Width); // 49-2=47
                        Assert.Equal (89, v1.Frame.Height); // 98-5-2-2=89
                        Assert.Equal (89, v1.Frame.Height); // 98-5-2-2=89
 
 
@@ -340,7 +340,7 @@ public class DimTests
 #endif
 #endif
                                     );
                                     );
 #if DEBUG
 #if DEBUG
-                       Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ());
+                       Assert.Equal ("Combine(Fill(Absolute(0))-Absolute(2))", v2.Height.ToString ());
 #else
 #else
                        Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ());
                        Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ());
 #endif
 #endif
@@ -380,7 +380,7 @@ public class DimTests
                        Assert.Equal (5, f1.Frame.Height);
                        Assert.Equal (5, f1.Frame.Height);
 
 
                        f2.Text = "Frame2";
                        f2.Text = "Frame2";
-                       Assert.Equal ("Fill(0)", f2.Width.ToString ());
+                       Assert.Equal ("Fill(Absolute(0))", f2.Width.ToString ());
                        Assert.Equal ("Absolute(5)", f2.Height.ToString ());
                        Assert.Equal ("Absolute(5)", f2.Height.ToString ());
                        Assert.Equal (99, f2.Frame.Width); // 100-1=99
                        Assert.Equal (99, f2.Frame.Width); // 100-1=99
                        Assert.Equal (5, f2.Frame.Height);
                        Assert.Equal (5, f2.Frame.Height);
@@ -391,7 +391,7 @@ public class DimTests
 #else
 #else
                        Assert.Equal ($"Combine(View(Width,FrameView(){f1.Frame})-Absolute(2))", v1.Width.ToString ());
                        Assert.Equal ($"Combine(View(Width,FrameView(){f1.Frame})-Absolute(2))", v1.Width.ToString ());
 #endif
 #endif
-                       Assert.Equal ("Combine(Fill(0)-Absolute(2))", v1.Height.ToString ());
+                       Assert.Equal ("Combine(Fill(Absolute(0))-Absolute(2))", v1.Height.ToString ());
                        Assert.Equal (97, v1.Frame.Width); // 99-2=97
                        Assert.Equal (97, v1.Frame.Width); // 99-2=97
                        Assert.Equal (189, v1.Frame.Height); // 198-2-7=189
                        Assert.Equal (189, v1.Frame.Height); // 198-2-7=189
 
 
@@ -402,7 +402,7 @@ public class DimTests
 #else
 #else
                        Assert.Equal ($"Combine(View(Width,FrameView(){f2.Frame})-Absolute(2))", v2.Width.ToString ());
                        Assert.Equal ($"Combine(View(Width,FrameView(){f2.Frame})-Absolute(2))", v2.Width.ToString ());
 #endif
 #endif
-                       Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ());
+                       Assert.Equal ("Combine(Fill(Absolute(0))-Absolute(2))", v2.Height.ToString ());
                        Assert.Equal (97, v2.Frame.Width); // 99-2=97
                        Assert.Equal (97, v2.Frame.Width); // 99-2=97
                        Assert.Equal (189, v2.Frame.Height); // 198-2-7=189
                        Assert.Equal (189, v2.Frame.Height); // 198-2-7=189
 
 

+ 6 - 6
UnitTests/View/Layout/SetRelativeLayoutTests.cs

@@ -37,11 +37,11 @@ public class SetRelativeLayoutTests
 
 
         Assert.Equal ("Absolute(1)", view.X.ToString ());
         Assert.Equal ("Absolute(1)", view.X.ToString ());
         Assert.Equal ("Absolute(2)", view.Y.ToString ());
         Assert.Equal ("Absolute(2)", view.Y.ToString ());
-        Assert.Equal ("Fill(0)", view.Width.ToString ());
-        Assert.Equal ("Fill(0)", view.Height.ToString ());
+        Assert.Equal ("Fill(Absolute(0))", view.Width.ToString ());
+        Assert.Equal ("Fill(Absolute(0))", view.Height.ToString ());
         view.SetRelativeLayout (screen);
         view.SetRelativeLayout (screen);
-        Assert.Equal ("Fill(0)", view.Width.ToString ());
-        Assert.Equal ("Fill(0)", view.Height.ToString ());
+        Assert.Equal ("Fill(Absolute(0))", view.Width.ToString ());
+        Assert.Equal ("Fill(Absolute(0))", view.Height.ToString ());
     }
     }
 
 
     [Fact]
     [Fact]
@@ -50,7 +50,7 @@ public class SetRelativeLayoutTests
         var view = new View { X = 1, Y = 1, Width = Dim.Fill (), Height = Dim.Fill () };
         var view = new View { X = 1, Y = 1, Width = Dim.Fill (), Height = Dim.Fill () };
 
 
         view.SetRelativeLayout (new Size (80, 25));
         view.SetRelativeLayout (new Size (80, 25));
-        Assert.Equal ("Fill(0)", view.Width.ToString ());
+        Assert.Equal ("Fill(Absolute(0))", view.Width.ToString ());
         Assert.Equal (1, view.Frame.X);
         Assert.Equal (1, view.Frame.X);
         Assert.Equal (1, view.Frame.Y);
         Assert.Equal (1, view.Frame.Y);
         Assert.Equal (79, view.Frame.Width);
         Assert.Equal (79, view.Frame.Width);
@@ -63,7 +63,7 @@ public class SetRelativeLayoutTests
         view.X = 0;
         view.X = 0;
         view.Y = 0;
         view.Y = 0;
         Assert.Equal ("Absolute(0)", view.X.ToString ());
         Assert.Equal ("Absolute(0)", view.X.ToString ());
-        Assert.Equal ("Fill(0)", view.Width.ToString ());
+        Assert.Equal ("Fill(Absolute(0))", view.Width.ToString ());
         view.SetRelativeLayout (new Size (80, 25));
         view.SetRelativeLayout (new Size (80, 25));
         Assert.Equal (0, view.Frame.X);
         Assert.Equal (0, view.Frame.X);
         Assert.Equal (0, view.Frame.Y);
         Assert.Equal (0, view.Frame.Y);

+ 2 - 2
UnitTests/Views/ToplevelTests.cs

@@ -10,8 +10,8 @@ public partial class ToplevelTests (ITestOutputHelper output)
         var top = new Toplevel ();
         var top = new Toplevel ();
 
 
         Assert.Equal (Colors.ColorSchemes ["TopLevel"], top.ColorScheme);
         Assert.Equal (Colors.ColorSchemes ["TopLevel"], top.ColorScheme);
-        Assert.Equal ("Fill(0)", top.Width.ToString ());
-        Assert.Equal ("Fill(0)", top.Height.ToString ());
+        Assert.Equal ("Fill(Absolute(0))", top.Width.ToString ());
+        Assert.Equal ("Fill(Absolute(0))", top.Height.ToString ());
         Assert.False (top.Running);
         Assert.False (top.Running);
         Assert.False (top.Modal);
         Assert.False (top.Modal);
         Assert.Null (top.MenuBar);
         Assert.Null (top.MenuBar);