diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs
index 6da3a0a03..3b63f9a5b 100644
--- a/Terminal.Gui/View/Layout/PosDim.cs
+++ b/Terminal.Gui/View/Layout/PosDim.cs
@@ -125,20 +125,35 @@
public class Pos
{
///
- /// Creates a object that is anchored to the end (right side or bottom) of the dimension, useful
- /// to flush the layout from the right or bottom.
+ /// Creates a object that has its end (right side or bottom) anchored to the end (right side or
+ /// bottom)
+ /// of the SuperView, useful to flush the layout from the right or bottom.
+ ///
+ /// The object anchored to the end (the bottom or the right side).
+ ///
+ /// This sample shows how align a to the bottom-right the SuperView.
+ ///
+ /// anchorButton.X = Pos.AnchorEnd (0);
+ /// anchorButton.Y = Pos.AnchorEnd (0);
+ ///
+ ///
+ public static Pos AnchorEnd () { return new PosAnchorEnd (0); }
+
+ ///
+ /// Creates a object that is anchored to the end (right side or bottom) of the SuperView,
+ /// useful to flush the layout from the right or bottom.
///
/// The object anchored to the end (the bottom or the right side).
/// The view will be shifted left or up by the amount specified.
///
- /// This sample shows how align a to the bottom-right of a .
- ///
- /// // See Issue #502
- /// anchorButton.X = Pos.AnchorEnd () - (Pos.Right (anchorButton) - Pos.Left (anchorButton));
- /// anchorButton.Y = Pos.AnchorEnd (1);
+ /// This sample shows how align a such that its left side is offset 10 columns from
+ /// the right edge of the SuperView.
+ ///
+ /// anchorButton.X = Pos.AnchorEnd (10);
+ /// anchorButton.Y = 1
///
///
- public static Pos AnchorEnd (int offset = 0)
+ public static Pos AnchorEnd (int offset)
{
if (offset < 0)
{
diff --git a/UICatalog/Scenarios/ColorPicker.cs b/UICatalog/Scenarios/ColorPicker.cs
index 8ae76c5dc..bc426e4e2 100644
--- a/UICatalog/Scenarios/ColorPicker.cs
+++ b/UICatalog/Scenarios/ColorPicker.cs
@@ -44,20 +44,20 @@ public class ColorPickers : Scenario
backgroundColorPicker = new ColorPicker
{
Title = "Background Color",
- // TODO: Replace with Pos.AnchorEnd () when #2900 is done
+ // TODO: Replace with Pos.AnchorEnd (0) when #2900 is done
X = Pos.AnchorEnd ((8 * 4) + 2), // 8 box * 4 width + 2 for border
BoxHeight = 1,
BoxWidth = 4,
BorderStyle = LineStyle.Single
};
- //backgroundColorPicker.X = Pos.AnchorEnd () - (Pos.Right (backgroundColorPicker) - Pos.Left (backgroundColorPicker));
+ //backgroundColorPicker.X = Pos.AnchorEnd (0) - (Pos.Right (backgroundColorPicker) - Pos.Left (backgroundColorPicker));
backgroundColorPicker.ColorChanged += BackgroundColor_ColorChanged;
Win.Add (backgroundColorPicker);
_backgroundColorLabel = new Label ();
_backgroundColorLabel.X =
- Pos.AnchorEnd () - (Pos.Right (_backgroundColorLabel) - Pos.Left (_backgroundColorLabel));
+ Pos.AnchorEnd (0) - (Pos.Right (_backgroundColorLabel) - Pos.Left (_backgroundColorLabel));
_backgroundColorLabel.Y = Pos.Bottom (backgroundColorPicker) + 1;
Win.Add (_backgroundColorLabel);
diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs
index d51311c90..65904cdf9 100644
--- a/UICatalog/Scenarios/ComputedLayout.cs
+++ b/UICatalog/Scenarios/ComputedLayout.cs
@@ -316,8 +316,8 @@ public class ComputedLayout : Scenario
Top.Add (oddballButton);
// Demonstrate AnchorEnd - Button is anchored to bottom/right
- var anchorButton = new Button { Text = "Button using AnchorEnd", Y = Pos.AnchorEnd () - 1 };
- anchorButton.X = Pos.AnchorEnd () - (Pos.Right (anchorButton) - Pos.Left (anchorButton));
+ var anchorButton = new Button { Text = "Button using AnchorEnd", Y = Pos.AnchorEnd (0) - 1 };
+ anchorButton.X = Pos.AnchorEnd (0) - (Pos.Right (anchorButton) - Pos.Left (anchorButton));
anchorButton.Accept += (s, e) =>
{
@@ -362,7 +362,7 @@ public class ComputedLayout : Scenario
// Show positioning vertically using Pos.AnchorEnd via Pos.Combine
var leftButton = new Button
{
- Text = "Left", Y = Pos.AnchorEnd () - 1 // Pos.Combine
+ Text = "Left", Y = Pos.AnchorEnd (0) - 1 // Pos.Combine
};
leftButton.Accept += (s, e) =>
diff --git a/UICatalog/Scenarios/DynamicMenuBar.cs b/UICatalog/Scenarios/DynamicMenuBar.cs
index bb5451655..f6ec1616e 100644
--- a/UICatalog/Scenarios/DynamicMenuBar.cs
+++ b/UICatalog/Scenarios/DynamicMenuBar.cs
@@ -604,7 +604,7 @@ public class DynamicMenuBar : Scenario
var _btnRemoveMenuBar = new Button { Y = 1, Text = "Remove a MenuBar" };
- _btnRemoveMenuBar.X = Pos.AnchorEnd () - (Pos.Right (_btnRemoveMenuBar) - Pos.Left (_btnRemoveMenuBar));
+ _btnRemoveMenuBar.X = Pos.AnchorEnd (0) - (Pos.Right (_btnRemoveMenuBar) - Pos.Left (_btnRemoveMenuBar));
_frmMenu.Add (_btnRemoveMenuBar);
var _btnPrevious = new Button
@@ -614,7 +614,7 @@ public class DynamicMenuBar : Scenario
_frmMenu.Add (_btnPrevious);
var _btnAdd = new Button { Y = Pos.Top (_btnPrevious) + 2, Text = " Add " };
- _btnAdd.X = Pos.AnchorEnd () - (Pos.Right (_btnAdd) - Pos.Left (_btnAdd));
+ _btnAdd.X = Pos.AnchorEnd (0) - (Pos.Right (_btnAdd) - Pos.Left (_btnAdd));
_frmMenu.Add (_btnAdd);
var _btnNext = new Button { X = Pos.X (_btnAdd), Y = Pos.Top (_btnPrevious), Text = ">" };
diff --git a/UICatalog/Scenarios/DynamicStatusBar.cs b/UICatalog/Scenarios/DynamicStatusBar.cs
index 55a114d38..f7934024a 100644
--- a/UICatalog/Scenarios/DynamicStatusBar.cs
+++ b/UICatalog/Scenarios/DynamicStatusBar.cs
@@ -371,11 +371,11 @@ public class DynamicStatusBar : Scenario
var _btnRemoveStatusBar = new Button { Y = 1, Text = "Remove a StatusBar" };
- _btnRemoveStatusBar.X = Pos.AnchorEnd () - (Pos.Right (_btnRemoveStatusBar) - Pos.Left (_btnRemoveStatusBar));
+ _btnRemoveStatusBar.X = Pos.AnchorEnd (0) - (Pos.Right (_btnRemoveStatusBar) - Pos.Left (_btnRemoveStatusBar));
_frmStatusBar.Add (_btnRemoveStatusBar);
var _btnAdd = new Button { Y = Pos.Top (_btnRemoveStatusBar) + 2, Text = " Add " };
- _btnAdd.X = Pos.AnchorEnd () - (Pos.Right (_btnAdd) - Pos.Left (_btnAdd));
+ _btnAdd.X = Pos.AnchorEnd (0) - (Pos.Right (_btnAdd) - Pos.Left (_btnAdd));
_frmStatusBar.Add (_btnAdd);
_lstItems = new ListView
diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs
index aaf4ae626..ec17a1d16 100644
--- a/UICatalog/Scenarios/Scrolling.cs
+++ b/UICatalog/Scenarios/Scrolling.cs
@@ -122,10 +122,10 @@ public class Scrolling : Scenario
);
// Demonstrate AnchorEnd - Button is anchored to bottom/right
- var anchorButton = new Button { Y = Pos.AnchorEnd () - 1, Text = "Bottom Right" };
+ var anchorButton = new Button { Y = Pos.AnchorEnd (0) - 1, Text = "Bottom Right" };
// TODO: Use Pos.Width instead of (Right-Left) when implemented (#502)
- anchorButton.X = Pos.AnchorEnd () - (Pos.Right (anchorButton) - Pos.Left (anchorButton));
+ anchorButton.X = Pos.AnchorEnd (0) - (Pos.Right (anchorButton) - Pos.Left (anchorButton));
anchorButton.Accept += (s, e) =>
{
diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs
index dda940810..98319d10c 100644
--- a/UICatalog/Scenarios/ViewExperiments.cs
+++ b/UICatalog/Scenarios/ViewExperiments.cs
@@ -200,7 +200,7 @@ public class ViewExperiments : Scenario
view.Add (edit);
edit = new TextField { Text = "AnchorEnd[Right];AnchorEnd (1)", Y = Pos.AnchorEnd (1), Width = 30, Height = 1 };
- edit.X = Pos.AnchorEnd () - (Pos.Right (edit) - Pos.Left (edit));
+ edit.X = Pos.AnchorEnd (0) - (Pos.Right (edit) - Pos.Left (edit));
view.Add (edit);
edit = new TextField
diff --git a/UICatalog/Scenarios/WindowsAndFrameViews.cs b/UICatalog/Scenarios/WindowsAndFrameViews.cs
index ba6fec117..51f4e0631 100644
--- a/UICatalog/Scenarios/WindowsAndFrameViews.cs
+++ b/UICatalog/Scenarios/WindowsAndFrameViews.cs
@@ -207,7 +207,7 @@ public class WindowsAndFrameViews : Scenario
new CheckBox { X = 0, Y = Pos.AnchorEnd (1), Text = "Btn1 (Y = Pos.AnchorEnd (1))" }
);
var c = new CheckBox { Y = Pos.AnchorEnd (1), Text = "Btn2 (Y = Pos.AnchorEnd (1))" };
- c.X = Pos.AnchorEnd () - (Pos.Right (c) - Pos.Left (c));
+ c.X = Pos.AnchorEnd (0) - (Pos.Right (c) - Pos.Left (c));
frame.Add (c);
frame.Add (subFrameViewofFV);
diff --git a/UnitTests/View/Layout/PosTests.cs b/UnitTests/View/Layout/PosTests.cs
index dc9b7eb43..f4379c17b 100644
--- a/UnitTests/View/Layout/PosTests.cs
+++ b/UnitTests/View/Layout/PosTests.cs
@@ -98,7 +98,7 @@ public class PosTests
public void AnchorEnd_SetsValue ()
{
var n = 0;
- Pos pos = Pos.AnchorEnd ();
+ Pos pos = Pos.AnchorEnd (0);
Assert.Equal ($"AnchorEnd({n})", pos.ToString ());
n = 5;
@@ -122,7 +122,7 @@ public class PosTests
int Btn_Width () { return btn?.Viewport.Width ?? 0; }
- btn = new Button { Text = "Ok", X = Pos.AnchorEnd () - Pos.Function (Btn_Width) };
+ btn = new Button { Text = "Ok", X = Pos.AnchorEnd (0) - Pos.Function (Btn_Width) };
var view = new View
{
@@ -619,7 +619,7 @@ public class PosTests
var super = new View { Width = 10, Height = 10, Text = "super" };
var view1 = new View { Width = 2, Height = 2, Text = "view1" };
var view2 = new View { Width = 2, Height = 2, Text = "view2" };
- view2.X = Pos.AnchorEnd () - (Pos.Right (view2) - Pos.Left (view2));
+ view2.X = Pos.AnchorEnd (0) - (Pos.Right (view2) - Pos.Left (view2));
super.Add (view1, view2);
super.BeginInit ();
diff --git a/UnitTests/View/Layout/SetRelativeLayoutTests.cs b/UnitTests/View/Layout/SetRelativeLayoutTests.cs
index 63a9f313d..f217a132a 100644
--- a/UnitTests/View/Layout/SetRelativeLayoutTests.cs
+++ b/UnitTests/View/Layout/SetRelativeLayoutTests.cs
@@ -405,7 +405,7 @@ public class SetRelativeLayoutTests
{
var screen = new Size (30, 1);
var view = new View { Text = "abc", AutoSize = true }; // BUGBUG: AutoSize or Width must be set
- view.X = Pos.AnchorEnd () - Pos.Function (GetViewWidth);
+ view.X = Pos.AnchorEnd (0) - Pos.Function (GetViewWidth);
int GetViewWidth () { return view.Frame.Width; }
diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs
index 313df7ce6..3d37a8f7e 100644
--- a/UnitTests/Views/ButtonTests.cs
+++ b/UnitTests/Views/ButtonTests.cs
@@ -164,8 +164,8 @@ public class ButtonTests (ITestOutputHelper output)
var btn = new Button { Y = Pos.Center (), Text = "Say Hello 你", AutoSize = true };
var btnTxt = $"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}";
- btn.X = Pos.AnchorEnd () - Pos.Function (() => btn.TextFormatter.Text.GetColumns ());
- btn.X = Pos.AnchorEnd () - Pos.Function (() => btn.TextFormatter.Text.GetColumns ());
+ btn.X = Pos.AnchorEnd (0) - Pos.Function (() => btn.TextFormatter.Text.GetColumns ());
+ btn.X = Pos.AnchorEnd (0) - Pos.Function (() => btn.TextFormatter.Text.GetColumns ());
var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
win.Add (btn);
diff --git a/UnitTests/Views/CheckBoxTests.cs b/UnitTests/Views/CheckBoxTests.cs
index 88e2afe9a..ff554c827 100644
--- a/UnitTests/Views/CheckBoxTests.cs
+++ b/UnitTests/Views/CheckBoxTests.cs
@@ -77,7 +77,7 @@ public class CheckBoxTests
{
var checkBox = new CheckBox { Y = Pos.Center (), Text = "C_heck this out 你" };
- checkBox.X = Pos.AnchorEnd () - Pos.Function (() => checkBox.GetSizeNeededForTextWithoutHotKey ().Width);
+ checkBox.X = Pos.AnchorEnd (0) - Pos.Function (() => checkBox.GetSizeNeededForTextWithoutHotKey ().Width);
var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
win.Add (checkBox);
@@ -121,7 +121,7 @@ public class CheckBoxTests
{
var checkBox = new CheckBox { Y = Pos.Center (), Text = "Check this out 你" };
- checkBox.X = Pos.AnchorEnd () - Pos.Function (() => checkBox.GetSizeNeededForTextWithoutHotKey ().Width);
+ checkBox.X = Pos.AnchorEnd (0) - Pos.Function (() => checkBox.GetSizeNeededForTextWithoutHotKey ().Width);
var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
win.Add (checkBox);
diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs
index 660baf395..48ba65a32 100644
--- a/UnitTests/Views/LabelTests.cs
+++ b/UnitTests/Views/LabelTests.cs
@@ -92,7 +92,7 @@ public class LabelTests
public void AutoSize_Stays_True_AnchorEnd ()
{
var label = new Label { Y = Pos.Center (), Text = "Say Hello 你", AutoSize = true };
- label.X = Pos.AnchorEnd () - Pos.Function (() => label.TextFormatter.Text.GetColumns ());
+ label.X = Pos.AnchorEnd (0) - Pos.Function (() => label.TextFormatter.Text.GetColumns ());
var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
win.Add (label);