DimAbsolute.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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 class DimAbsolute (int size) : Dim
  14. {
  15. /// <inheritdoc/>
  16. public override bool Equals (object? other) { return other is DimAbsolute abs && abs.Size == Size; }
  17. /// <inheritdoc/>
  18. public override int GetHashCode () { return Size.GetHashCode (); }
  19. /// <summary>
  20. /// Gets the size of the dimension.
  21. /// </summary>
  22. public int Size { get; } = size;
  23. /// <inheritdoc/>
  24. public override string ToString () { return $"Absolute({Size})"; }
  25. internal override int GetAnchor (int size) { return Size; }
  26. internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
  27. {
  28. return Math.Max (GetAnchor (0), 0);
  29. }
  30. }