#nullable enable
namespace Terminal.Gui;

/// <summary>
///     Represents a position that is centered.
/// </summary>
public class PosCenter : Pos
{
    /// <inheritdoc/>
    public override string ToString () { return "Center"; }

    internal override int GetAnchor (int size) { return size / 2; }

    internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
    {
        int newDimension = Math.Max (dim.Calculate (0, superviewDimension, us, dimension), 0);

        return GetAnchor (superviewDimension - newDimension);
    }
}