#nullable enable namespace Terminal.Gui; /// /// Represents a position anchored to the end (right side or bottom). /// /// /// /// This is a low-level API that is typically used internally by the layout system. Use the various static /// methods on the class to create objects instead. /// /// public record PosAnchorEnd : Pos { /// /// Gets the offset of the position from the right/bottom. /// public int Offset { get; } /// /// 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 , /// with an offset equivalent to the View's respective dimension. /// public PosAnchorEnd () { UseDimForOffset = true; } /// /// Constructs a new position anchored to the end (right side or bottom) of the SuperView, /// /// public PosAnchorEnd (int offset) { Offset = offset; } /// /// If true, the offset is the width of the view, if false, the offset is the offset value. /// public bool UseDimForOffset { get; } /// public override string ToString () { return UseDimForOffset ? "AnchorEnd" : $"AnchorEnd({Offset})"; } internal override int GetAnchor (int size) { if (UseDimForOffset) { return size; } return size - Offset; } internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension) { int newLocation = GetAnchor (superviewDimension); if (UseDimForOffset) { newLocation -= dim.GetAnchor (superviewDimension); } return newLocation; } }