Browse Source

PosAnchorEnd now public

Tig 1 year ago
parent
commit
90c8f836ca
1 changed files with 30 additions and 8 deletions
  1. 30 8
      Terminal.Gui/View/Layout/Pos.cs

+ 30 - 8
Terminal.Gui/View/Layout/Pos.cs

@@ -402,20 +402,42 @@ public class PosAbsolute (int position) : Pos
     internal override int Anchor (int width) { return Position; }
     internal override int Anchor (int width) { return Position; }
 }
 }
 
 
-internal class PosAnchorEnd : Pos
+/// <summary>
+///     Represents a position anchored to the end (right side or bottom).
+/// </summary>
+public class PosAnchorEnd : Pos
 {
 {
-    private readonly int _offset;
+    /// <summary>
+    /// Gets the offset of the position from the right/bottom.
+    /// </summary>
+    public int Offset { get; }
+
+    /// <summary>
+    ///     Constructs a new position anchored to the end (right side or bottom) of the SuperView,
+    ///     minus the respective dimension of the View. This is equivalent to using <see cref="PosAnchorEnd(int)"/>,
+    ///     with an offset equivalent to the View's respective dimension.
+    /// </summary>
     public PosAnchorEnd () { UseDimForOffset = true; }
     public PosAnchorEnd () { UseDimForOffset = true; }
-    public PosAnchorEnd (int offset) { _offset = offset; }
-    public override bool Equals (object other) { return other is PosAnchorEnd anchorEnd && anchorEnd._offset == _offset; }
-    public override int GetHashCode () { return _offset.GetHashCode (); }
+
+    /// <summary>
+    ///     Constructs a new position anchored to the end (right side or bottom) of the SuperView,
+    /// </summary>
+    /// <param name="offset"></param>
+    public PosAnchorEnd (int offset) { Offset = offset; }
+
+    /// <inheritdoc />
+    public override bool Equals (object other) { return other is PosAnchorEnd anchorEnd && anchorEnd.Offset == Offset; }
+
+    /// <inheritdoc />
+    public override int GetHashCode () { return Offset.GetHashCode (); }
 
 
     /// <summary>
     /// <summary>
     ///     If true, the offset is the width of the view, if false, the offset is the offset value.
     ///     If true, the offset is the width of the view, if false, the offset is the offset value.
     /// </summary>
     /// </summary>
-    internal bool UseDimForOffset { get; set; }
+    public bool UseDimForOffset { get; }
 
 
-    public override string ToString () { return UseDimForOffset ? "AnchorEnd()" : $"AnchorEnd({_offset})"; }
+    /// <inheritdoc />
+    public override string ToString () { return UseDimForOffset ? "AnchorEnd()" : $"AnchorEnd({Offset})"; }
 
 
     internal override int Anchor (int width)
     internal override int Anchor (int width)
     {
     {
@@ -424,7 +446,7 @@ internal class PosAnchorEnd : Pos
             return width;
             return width;
         }
         }
 
 
-        return width - _offset;
+        return width - Offset;
     }
     }
 
 
     internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
     internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)