diff --git a/Terminal.Gui/Drawing/Thickness.cs b/Terminal.Gui/Drawing/Thickness.cs index 653b210ac..733275c88 100644 --- a/Terminal.Gui/Drawing/Thickness.cs +++ b/Terminal.Gui/Drawing/Thickness.cs @@ -1,4 +1,5 @@ -using System.Text.Json.Serialization; +using System.Numerics; +using System.Text.Json.Serialization; namespace Terminal.Gui; @@ -17,8 +18,19 @@ namespace Terminal.Gui; /// public record struct Thickness { + private Vector4 _sides; + + /// Initializes a new instance of the class. + public Thickness (float left, float top, float right, float bottom) + { + _sides = new (left, top, right, bottom); + } + /// Initializes a new instance of the class with all widths set to 0. - public Thickness () { } + public Thickness () + { + _sides = new (0, 0, 0, 0); + } /// Initializes a new instance of the class with a uniform width to each side. /// @@ -40,21 +52,37 @@ public record struct Thickness Bottom = bottom; } - /// Gets or sets the width of the lower side of the rectangle. - [JsonInclude] - public int Bottom { get; set; } /// Gets or sets the width of the left side of the rectangle. [JsonInclude] - public int Left { get; set; } + public int Left + { + get => (int)_sides.X; + set => _sides.X = value; + } + /// Gets or sets the width of the upper side of the rectangle. + [JsonInclude] + public int Top + { + get => (int)_sides.Y; + set => _sides.Y = value; + } /// Gets or sets the width of the right side of the rectangle. [JsonInclude] - public int Right { get; set; } + public int Right + { + get => (int)_sides.Z; + set => _sides.Z = value; + } - /// Gets or sets the width of the upper side of the rectangle. + /// Gets or sets the width of the lower side of the rectangle. [JsonInclude] - public int Top { get; set; } + public int Bottom + { + get => (int)_sides.W; + set => _sides.W = value; + } /// /// Adds the thickness widths of another to the current , returning a @@ -248,7 +276,7 @@ public record struct Thickness /// Returns the thickness widths of the Thickness formatted as a string. /// The thickness widths as a string. - public readonly override string ToString () { return $"(Left={Left},Top={Top},Right={Right},Bottom={Bottom})"; } + public override string ToString () { return $"(Left={Left},Top={Top},Right={Right},Bottom={Bottom})"; } /// /// Gets the total height of the top and bottom sides of the rectangle. Sets the height of the top and bottom