Table of Contents

Class LayoutRequirements

Namespace
SharpConsoleUI.Core
Assembly
SharpConsoleUI.dll

Controls express sizing and alignment needs via this record. Single source of truth for all layout-related information.

public record LayoutRequirements : IEquatable<LayoutRequirements>
Inheritance
LayoutRequirements
Implements
Inherited Members

Fields

Default

Default layout requirements with no fixed dimensions and left alignment.

public static readonly LayoutRequirements Default

Field Value

LayoutRequirements

Properties

EffectiveMaxHeight

Effective maximum height (defaults to int.MaxValue if null)

public int EffectiveMaxHeight { get; }

Property Value

int

EffectiveMaxWidth

Effective maximum width (defaults to int.MaxValue if null)

public int EffectiveMaxWidth { get; }

Property Value

int

EffectiveMinHeight

Effective minimum height (defaults to 1 if null)

public int EffectiveMinHeight { get; }

Property Value

int

EffectiveMinWidth

Effective minimum width (defaults to 1 if null)

public int EffectiveMinWidth { get; }

Property Value

int

FlexFactor

Flex factor for proportional sizing when Width is null (1.0 = equal share)

public double FlexFactor { get; init; }

Property Value

double

Height

Fixed height (null = flexible)

public int? Height { get; init; }

Property Value

int?

HorizontalAlignment

Horizontal alignment within allocated space

public HorizontalAlignment HorizontalAlignment { get; init; }

Property Value

HorizontalAlignment

IsFixed

True if this has a fixed width (Width is set)

public bool IsFixed { get; }

Property Value

bool

IsStretch

True if this should expand to fill available space

public bool IsStretch { get; }

Property Value

bool

MaxHeight

Maximum height constraint (null = unlimited)

public int? MaxHeight { get; init; }

Property Value

int?

MaxWidth

Maximum width constraint (null = unlimited)

public int? MaxWidth { get; init; }

Property Value

int?

MinHeight

Minimum height constraint (null = no minimum)

public int? MinHeight { get; init; }

Property Value

int?

MinWidth

Minimum width constraint (null = no minimum, defaults to 1 during layout)

public int? MinWidth { get; init; }

Property Value

int?

VerticalAlignment

Vertical alignment within allocated space

public VerticalAlignment VerticalAlignment { get; init; }

Property Value

VerticalAlignment

Width

Fixed width (null = flexible, uses available space)

public int? Width { get; init; }

Property Value

int?

Methods

ClampHeight(int)

Clamps a height value to the min/max constraints

public int ClampHeight(int height)

Parameters

height int

Returns

int

ClampWidth(int)

Clamps a width value to the min/max constraints

public int ClampWidth(int width)

Parameters

width int

Returns

int

Fixed(int, HorizontalAlignment)

Creates fixed-width requirements

public static LayoutRequirements Fixed(int width, HorizontalAlignment alignment = HorizontalAlignment.Left)

Parameters

width int
alignment HorizontalAlignment

Returns

LayoutRequirements

Fixed(int, int, HorizontalAlignment, VerticalAlignment)

Creates fixed-size requirements

public static LayoutRequirements Fixed(int width, int height, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left, VerticalAlignment verticalAlignment = VerticalAlignment.Top)

Parameters

width int
height int
horizontalAlignment HorizontalAlignment
verticalAlignment VerticalAlignment

Returns

LayoutRequirements

Flexible(int?, int?, HorizontalAlignment)

Creates flexible requirements with optional constraints

public static LayoutRequirements Flexible(int? minWidth = null, int? maxWidth = null, HorizontalAlignment alignment = HorizontalAlignment.Left)

Parameters

minWidth int?
maxWidth int?
alignment HorizontalAlignment

Returns

LayoutRequirements

Stretch()

Creates stretch requirements (expands to fill available space)

public static LayoutRequirements Stretch()

Returns

LayoutRequirements