Struct LayoutConstraints
- Namespace
- SharpConsoleUI.Layout
- Assembly
- SharpConsoleUI.dll
Represents layout constraints for measuring controls. Defines minimum and maximum width/height bounds.
public readonly record struct LayoutConstraints : IEquatable<LayoutConstraints>
- Implements
- Inherited Members
Constructors
LayoutConstraints(int, int, int, int)
Represents layout constraints for measuring controls. Defines minimum and maximum width/height bounds.
public LayoutConstraints(int MinWidth, int MaxWidth, int MinHeight, int MaxHeight)
Parameters
Properties
HasTightHeight
Gets whether the height is tightly constrained (min == max).
public bool HasTightHeight { get; }
Property Value
HasTightWidth
Gets whether the width is tightly constrained (min == max).
public bool HasTightWidth { get; }
Property Value
IsTight
Gets whether both dimensions are tightly constrained.
public bool IsTight { get; }
Property Value
MaxHeight
public int MaxHeight { get; init; }
Property Value
MaxSize
Gets the maximum size from these constraints.
public LayoutSize MaxSize { get; }
Property Value
MaxWidth
public int MaxWidth { get; init; }
Property Value
MinHeight
public int MinHeight { get; init; }
Property Value
MinSize
Gets the minimum size from these constraints.
public LayoutSize MinSize { get; }
Property Value
MinWidth
public int MinWidth { get; init; }
Property Value
Unbounded
Gets unbounded constraints (0 to MaxValue).
public static LayoutConstraints Unbounded { get; }
Property Value
Zero
Gets zero-size constraints.
public static LayoutConstraints Zero { get; }
Property Value
Methods
Constrain(LayoutSize)
Constrains a size to fit within these bounds.
public LayoutSize Constrain(LayoutSize size)
Parameters
sizeLayoutSize
Returns
Constrain(int, int)
Constrains dimensions to fit within these bounds.
public LayoutSize Constrain(int width, int height)
Parameters
Returns
Fixed(LayoutSize)
Creates constraints with fixed size.
public static LayoutConstraints Fixed(LayoutSize size)
Parameters
sizeLayoutSize
Returns
Fixed(int, int)
Creates constraints with fixed width and height.
public static LayoutConstraints Fixed(int width, int height)
Parameters
Returns
Intersect(LayoutConstraints)
Returns constraints that are the intersection of this and another.
public LayoutConstraints Intersect(LayoutConstraints other)
Parameters
otherLayoutConstraints
Returns
IsSatisfiedBy(LayoutSize)
Returns whether a size satisfies these constraints.
public bool IsSatisfiedBy(LayoutSize size)
Parameters
sizeLayoutSize
Returns
Loose(LayoutSize)
Creates constraints with maximum bounds but no minimum.
public static LayoutConstraints Loose(LayoutSize maxSize)
Parameters
maxSizeLayoutSize
Returns
Loose(int, int)
Creates constraints with maximum bounds but no minimum.
public static LayoutConstraints Loose(int maxWidth, int maxHeight)
Parameters
Returns
SubtractHeight(int)
Returns constraints with the maximum height reduced by the specified amount.
public LayoutConstraints SubtractHeight(int height)
Parameters
heightint
Returns
SubtractWidth(int)
Returns constraints with the maximum width reduced by the specified amount.
public LayoutConstraints SubtractWidth(int width)
Parameters
widthint
Returns
Tight(LayoutSize)
Creates tight constraints where min equals max.
public static LayoutConstraints Tight(LayoutSize size)
Parameters
sizeLayoutSize
Returns
Tight(int, int)
Creates tight constraints where min equals max.
public static LayoutConstraints Tight(int width, int height)
Parameters
Returns
ToString()
Returns a string representation of these layout constraints.
public override string ToString()
Returns
WithMaxHeight(int)
Returns constraints with a new maximum height.
public LayoutConstraints WithMaxHeight(int maxHeight)
Parameters
maxHeightint
Returns
WithMaxWidth(int)
Returns constraints with a new maximum width.
public LayoutConstraints WithMaxWidth(int maxWidth)
Parameters
maxWidthint
Returns
WithMinHeight(int)
Returns constraints with a new minimum height.
public LayoutConstraints WithMinHeight(int minHeight)
Parameters
minHeightint
Returns
WithMinWidth(int)
Returns constraints with a new minimum width.
public LayoutConstraints WithMinWidth(int minWidth)
Parameters
minWidthint