Table of Contents

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

MinWidth int
MaxWidth int
MinHeight int
MaxHeight int

Properties

HasTightHeight

Gets whether the height is tightly constrained (min == max).

public bool HasTightHeight { get; }

Property Value

bool

HasTightWidth

Gets whether the width is tightly constrained (min == max).

public bool HasTightWidth { get; }

Property Value

bool

IsTight

Gets whether both dimensions are tightly constrained.

public bool IsTight { get; }

Property Value

bool

MaxHeight

public int MaxHeight { get; init; }

Property Value

int

MaxSize

Gets the maximum size from these constraints.

public LayoutSize MaxSize { get; }

Property Value

LayoutSize

MaxWidth

public int MaxWidth { get; init; }

Property Value

int

MinHeight

public int MinHeight { get; init; }

Property Value

int

MinSize

Gets the minimum size from these constraints.

public LayoutSize MinSize { get; }

Property Value

LayoutSize

MinWidth

public int MinWidth { get; init; }

Property Value

int

Unbounded

Gets unbounded constraints (0 to MaxValue).

public static LayoutConstraints Unbounded { get; }

Property Value

LayoutConstraints

Zero

Gets zero-size constraints.

public static LayoutConstraints Zero { get; }

Property Value

LayoutConstraints

Methods

Constrain(LayoutSize)

Constrains a size to fit within these bounds.

public LayoutSize Constrain(LayoutSize size)

Parameters

size LayoutSize

Returns

LayoutSize

Constrain(int, int)

Constrains dimensions to fit within these bounds.

public LayoutSize Constrain(int width, int height)

Parameters

width int
height int

Returns

LayoutSize

Fixed(LayoutSize)

Creates constraints with fixed size.

public static LayoutConstraints Fixed(LayoutSize size)

Parameters

size LayoutSize

Returns

LayoutConstraints

Fixed(int, int)

Creates constraints with fixed width and height.

public static LayoutConstraints Fixed(int width, int height)

Parameters

width int
height int

Returns

LayoutConstraints

Intersect(LayoutConstraints)

Returns constraints that are the intersection of this and another.

public LayoutConstraints Intersect(LayoutConstraints other)

Parameters

other LayoutConstraints

Returns

LayoutConstraints

IsSatisfiedBy(LayoutSize)

Returns whether a size satisfies these constraints.

public bool IsSatisfiedBy(LayoutSize size)

Parameters

size LayoutSize

Returns

bool

Loose(LayoutSize)

Creates constraints with maximum bounds but no minimum.

public static LayoutConstraints Loose(LayoutSize maxSize)

Parameters

maxSize LayoutSize

Returns

LayoutConstraints

Loose(int, int)

Creates constraints with maximum bounds but no minimum.

public static LayoutConstraints Loose(int maxWidth, int maxHeight)

Parameters

maxWidth int
maxHeight int

Returns

LayoutConstraints

SubtractHeight(int)

Returns constraints with the maximum height reduced by the specified amount.

public LayoutConstraints SubtractHeight(int height)

Parameters

height int

Returns

LayoutConstraints

SubtractWidth(int)

Returns constraints with the maximum width reduced by the specified amount.

public LayoutConstraints SubtractWidth(int width)

Parameters

width int

Returns

LayoutConstraints

Tight(LayoutSize)

Creates tight constraints where min equals max.

public static LayoutConstraints Tight(LayoutSize size)

Parameters

size LayoutSize

Returns

LayoutConstraints

Tight(int, int)

Creates tight constraints where min equals max.

public static LayoutConstraints Tight(int width, int height)

Parameters

width int
height int

Returns

LayoutConstraints

ToString()

Returns a string representation of these layout constraints.

public override string ToString()

Returns

string

WithMaxHeight(int)

Returns constraints with a new maximum height.

public LayoutConstraints WithMaxHeight(int maxHeight)

Parameters

maxHeight int

Returns

LayoutConstraints

WithMaxWidth(int)

Returns constraints with a new maximum width.

public LayoutConstraints WithMaxWidth(int maxWidth)

Parameters

maxWidth int

Returns

LayoutConstraints

WithMinHeight(int)

Returns constraints with a new minimum height.

public LayoutConstraints WithMinHeight(int minHeight)

Parameters

minHeight int

Returns

LayoutConstraints

WithMinWidth(int)

Returns constraints with a new minimum width.

public LayoutConstraints WithMinWidth(int minWidth)

Parameters

minWidth int

Returns

LayoutConstraints