#nullable enable
namespace Terminal.Gui;
///
/// Represents a dimension that is a percentage of the width or height of the SuperView.
///
///
/// 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 percentage.
///
/// If the dimension is computed using the View's position ( or
/// ); otherwise, the dimension is computed using the View's .
///
public record DimPercent (int Percentage, DimPercentMode Mode = DimPercentMode.ContentSize) : Dim
{
///
///
///
public override string ToString () { return $"Percent({Percentage},{Mode})"; }
///
/// Gets whether the dimension is computed using the View's position or GetContentSize ().
///
public DimPercentMode Mode { get; } = Mode;
internal override int GetAnchor (int size) { return (int)(size * (Percentage / 100f)); }
internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
{
return Mode == DimPercentMode.Position ? Math.Max (GetAnchor (superviewContentSize - location), 0) : GetAnchor (superviewContentSize);
}
}