Просмотр исходного кода

Merge branch 'v2_develop' into v2_1785-PosJustify

Tig 1 год назад
Родитель
Сommit
bb16808021

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

@@ -1,4 +1,4 @@
-using static Terminal.Gui.Dialog;
+using static Terminal.Gui.Dialog;
 
 namespace Terminal.Gui;
 

+ 2 - 0
UICatalog/Scenarios/ContentScrolling.cs

@@ -104,6 +104,8 @@ public class ContentScrolling : Scenario
         Window app = new ()
         {
             Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}",
+            // Use a different colorscheme so ViewSettings.ClearContentOnly is obvious
+            ColorScheme = Colors.ColorSchemes ["Toplevel"]
         };
 
         var editor = new AdornmentsEditor ();

+ 3 - 3
UnitTests/View/Layout/DimTests.cs

@@ -70,7 +70,7 @@ public class DimTests
     public void DimView_GetDimension_ReturnsCorrectValue ()
     {
         var view = new View { Width = 10 };
-        var dim = new DimView (view, Side.Width);
+        var dim = new DimView (view, Dimension.Width);
         var result = dim.Calculate (0, 100, 50, false);
         Assert.Equal (10, result);
     }
@@ -561,9 +561,9 @@ public class DimTests
         Assert.Equal (20, dimCombine.Anchor (100));
 
         var view = new View { Frame = new Rectangle (20, 10, 20, 1) };
-        var dimViewHeight = new Dim.DimView (view, Side.Height);
+        var dimViewHeight = new Dim.DimView (view, Dimension.Height);
         Assert.Equal (1, dimViewHeight.Anchor (0));
-        var dimViewWidth = new Dim.DimView (view, Side.Width);
+        var dimViewWidth = new Dim.DimView (view, Dimension.Width);
         Assert.Equal (20, dimViewWidth.Anchor (0));
 
         view.Dispose ();

+ 10 - 10
UnitTests/View/Layout/PosTests.cs

@@ -101,28 +101,28 @@ public class PosTests (ITestOutputHelper output)
         Pos pos = Pos.Left (v);
 
         Assert.Equal (
-                      $"View(side=x,target=View(V){v.Frame})",
+                      $"View(side=left,target=View(V){v.Frame})",
                       pos.ToString ()
                      );
 
         pos = Pos.X (v);
 
         Assert.Equal (
-                      $"View(side=x,target=View(V){v.Frame})",
+                      $"View(side=left,target=View(V){v.Frame})",
                       pos.ToString ()
                      );
 
         pos = Pos.Top (v);
 
         Assert.Equal (
-                      $"View(side=y,target=View(V){v.Frame})",
+                      $"View(side=top,target=View(V){v.Frame})",
                       pos.ToString ()
                      );
 
         pos = Pos.Y (v);
 
         Assert.Equal (
-                      $"View(side=y,target=View(V){v.Frame})",
+                      $"View(side=top,target=View(V){v.Frame})",
                       pos.ToString ()
                      );
 
@@ -197,9 +197,9 @@ public class PosTests (ITestOutputHelper output)
         Assert.Equal (20, posCombine.Anchor (100));
 
         var view = new View { Frame = new (20, 10, 20, 1) };
-        var posViewX = new Pos.PosView (view, Pos.Side.X);
+        var posViewX = new Pos.PosView (view, Pos.Side.Left);
         Assert.Equal (20, posViewX.Anchor (0));
-        var posViewY = new Pos.PosView (view, Pos.Side.Y);
+        var posViewY = new Pos.PosView (view, Pos.Side.Top);
         Assert.Equal (10, posViewY.Anchor (0));
         var posRight = new Pos.PosView (view, Pos.Side.Right);
         Assert.Equal (40, posRight.Anchor (0));
@@ -617,7 +617,7 @@ public class PosTests (ITestOutputHelper output)
         Pos pos;
 
         // Pos.Left
-        side = "x";
+        side = "left";
         testInt = 0;
         testRect = Rectangle.Empty;
         pos = Pos.Left (new ());
@@ -659,7 +659,7 @@ public class PosTests (ITestOutputHelper output)
                      );
 
         // Pos.X
-        side = "x";
+        side = "left";
         testInt = 0;
         testRect = Rectangle.Empty;
         pos = Pos.X (new ());
@@ -701,7 +701,7 @@ public class PosTests (ITestOutputHelper output)
                      );
 
         // Pos.Top
-        side = "y";
+        side = "top";
         testInt = 0;
         testRect = Rectangle.Empty;
         pos = Pos.Top (new ());
@@ -743,7 +743,7 @@ public class PosTests (ITestOutputHelper output)
                      );
 
         // Pos.Y
-        side = "y";
+        side = "top";
         testInt = 0;
         testRect = Rectangle.Empty;
         pos = Pos.Y (new ());

+ 1 - 1
docfx/docs/layout.md

@@ -55,7 +55,7 @@ The [Pos](~/api/Terminal.Gui.Pos.yml) is the type of `View.X` and `View.Y` and s
 
 * Absolute position, by passing an integer - `Pos.Absolute(n)`.
 * Percentage of the parent's view size - `Pos.Percent(percent)`.
-* Anchored from the end of the dimension - `Pos.AnchorEnd(margin)`.
+* Anchored from the end of the dimension - `Pos.AnchorEnd()`.
 * Centered, using `Pos.Center()`.
 * The `Pos.Left(otherView)`, `Pos.Top(otherView)`, `Pos.Bottom(otherView)`, `Pos.Right(otherView)` positions of another view.
 

+ 1 - 0
docfx/docs/newinv2.md

@@ -24,6 +24,7 @@ The entire library has been reviewed and simplified. As a result, the API is mor
 * *Adornments* - 
 * *Built-in Scrolling/Virtual Content Area* - In v1, to have a view a user could scroll required either a bespoke scrolling implementation, inheriting from `ScrollView`, or managing the complexity of `ScrollBarView` directly. In v2, the base-View class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by `View.ContentSize`. See [Layout](layout.md) for details.
 * *Computed Layout Improvements* - 
+* *`Pos.AnchorEnd ()`* - New to v2 is `Pos.AnchorEnd ()` (with no parameters) which allows a view to be anchored to the right or bottom of the Superview. 
 * *`Dim.Auto`* - 
 * ...