DimAbsolute.cs 914 B

123456789101112131415161718192021222324252627282930
  1. #nullable enable
  2. namespace Terminal.Gui;
  3. /// <summary>
  4. /// Represents a dimension that is a fixed size.
  5. /// </summary>
  6. /// <remarks>
  7. /// <para>
  8. /// This is a low-level API that is typically used internally by the layout system. Use the various static
  9. /// methods on the <see cref="Dim"/> class to create <see cref="Dim"/> objects instead.
  10. /// </para>
  11. /// </remarks>
  12. /// <param name="Size"></param>
  13. public record DimAbsolute (int Size) : Dim
  14. {
  15. /// <summary>
  16. /// Gets the size of the dimension.
  17. /// </summary>
  18. public int Size { get; } = Size;
  19. /// <inheritdoc/>
  20. public override string ToString () { return $"Absolute({Size})"; }
  21. internal override int GetAnchor (int size) { return Size; }
  22. internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
  23. {
  24. return Math.Max (GetAnchor (0), 0);
  25. }
  26. }