#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 /// ). /// If the dimension is computed using the View's . /// public class DimPercent (float percent, bool usePosition = false) : Dim { /// public override bool Equals (object? other) { return other is DimPercent f && f.Percent == Percent && f.UsePosition == UsePosition; } /// public override int GetHashCode () { return Percent.GetHashCode (); } /// /// Gets the percentage. /// public new float Percent { get; } = percent; /// /// /// public override string ToString () { return $"Percent({Percent},{UsePosition})"; } /// /// Gets whether the dimension is computed using the View's position or ContentSize. /// public bool UsePosition { get; } = usePosition; internal override int GetAnchor (int size) { return (int)(size * Percent); } internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension) { return UsePosition ? Math.Max (GetAnchor (superviewContentSize - location), 0) : GetAnchor (superviewContentSize); } }