PosPercent.cs 853 B

123456789101112131415161718192021222324
  1. namespace Terminal.Gui.ViewBase;
  2. /// <summary>
  3. /// Represents a position that is a percentage of the width or height of the SuperView.
  4. /// </summary>
  5. /// <remarks>
  6. /// <para>
  7. /// This is a low-level API that is typically used internally by the layout system. Use the various static
  8. /// methods on the <see cref="Pos"/> class to create <see cref="Pos"/> objects instead.
  9. /// </para>
  10. /// </remarks>
  11. /// <param name="Percent"></param>
  12. public record PosPercent (int Percent) : Pos
  13. {
  14. /// <summary>
  15. /// Gets the percentage of the width or height of the SuperView.
  16. /// </summary>
  17. public new int Percent { get; } = Percent;
  18. /// <inheritdoc/>
  19. public override string ToString () { return $"Percent({Percent})"; }
  20. internal override int GetAnchor (int size) { return (int)(size * (Percent / 100f)); }
  21. }