#nullable enable using System.Diagnostics; namespace Terminal.Gui; /// /// Represents a position that is anchored to the side of another view. /// /// /// /// 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 PosView : Pos { /// /// Represents a position that is anchored to the side of another view. /// /// /// /// 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. /// /// /// The View the position is anchored to. /// The side of the View the position is anchored to. public PosView (View view, Side side) { ArgumentNullException.ThrowIfNull (view); Target = view; Side = side; } /// /// Gets the View the position is anchored to. /// public View Target { get; } /// /// Gets the side of the View the position is anchored to. /// public Side Side { get; } /// public override string ToString () { string sideString = Side.ToString (); if (Target == null) { throw new NullReferenceException (nameof (Target)); } return $"View(Side={sideString},Target={Target})"; } internal override int GetAnchor (int size) { return Side switch { Side.Left => Target!.Frame.X, Side.Top => Target!.Frame.Y, Side.Right => Target!.Frame.Right, Side.Bottom => Target!.Frame.Bottom, _ => 0 }; } internal override bool ReferencesOtherViews () { return true; } }