#nullable enable namespace Terminal.Gui; /// /// Represents a position that is a combination of two other positions. /// /// /// /// 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. /// /// /// /// Indicates whether the two positions are added or subtracted. /// /// The left position. /// The right position. public record PosCombine (AddOrSubtract Add, Pos Left, Pos Right) : Pos { /// /// Gets whether the two positions are added or subtracted. /// public AddOrSubtract Add { get; } = Add; /// /// Gets the left position. /// public new Pos Left { get; } = Left; /// /// Gets the right position. /// public new Pos Right { get; } = Right; /// public override string ToString () { return $"Combine({Left}{(Add == AddOrSubtract.Add ? '+' : '-')}{Right})"; } internal override int GetAnchor (int size) { if (Add == AddOrSubtract.Add) { return Left.GetAnchor (size) + Right.GetAnchor (size); } return Left.GetAnchor (size) - Right.GetAnchor (size); } internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension) { if (Add == AddOrSubtract.Add) { return Left.Calculate (superviewDimension, dim, us, dimension) + Right.Calculate (superviewDimension, dim, us, dimension); } return Left.Calculate (superviewDimension, dim, us, dimension) - Right.Calculate (superviewDimension, dim, us, dimension); } internal override bool ReferencesOtherViews () { if (Left.ReferencesOtherViews ()) { return true; } if (Right.ReferencesOtherViews ()) { return true; } return false; } }