Table of Contents

Class Layout

Namespace
MiniTui
Assembly
MiniTui.dll

Fluent builder for creating layouts with named regions (§7).

public class Layout
Inheritance
Layout
Inherited Members

Examples

var layout = Layout.Vertical(screen)
    .Add("header", Constraint.Length(3))
    .Add("body", Constraint.Fill())
    .Add("status", Constraint.Length(1))
    .Build();
var body = layout["body"];

Properties

this[string]

Get a named region. Builds the layout if needed.

public Rect this[string name] { get; }

Parameters

name string

Property Value

Rect

Exceptions

KeyNotFoundException

No region has this name.

Methods

Add(string, Constraint)

Add a named region.

public Layout Add(string name, Constraint constraint)

Parameters

name string
constraint Constraint

Returns

Layout

Exceptions

ArgumentException

A region with this name was already added.

Build()

Compute the regions. Calling it again without changes does nothing.

public Layout Build()

Returns

Layout

Flex(Flex)

Where space goes when no region can grow into it. The default is Start.

public Layout Flex(Flex flex)

Parameters

flex Flex

Returns

Layout

Horizontal(Rect)

Create a horizontal layout (columns side by side).

public static Layout Horizontal(Rect area)

Parameters

area Rect

Returns

Layout

Margin(Margin)

Lay the regions out inside margin.

public Layout Margin(Margin margin)

Parameters

margin Margin

Returns

Layout

Spacing(int)

Leave cells empty cells between regions. Reduced if it doesn't fit.

public Layout Spacing(int cells)

Parameters

cells int

Returns

Layout

Split(Rect, Direction, params Constraint[])

Split area into one rect per constraint, in order.

public static Rect[] Split(Rect area, Direction direction, params Constraint[] constraints)

Parameters

area Rect
direction Direction
constraints Constraint[]

Returns

Rect[]

TryGet(string, out Rect)

Try to get a named region. Builds the layout if needed.

public bool TryGet(string name, out Rect rect)

Parameters

name string
rect Rect

Returns

bool

Vertical(Rect)

Create a vertical layout (rows stacked top to bottom).

public static Layout Vertical(Rect area)

Parameters

area Rect

Returns

Layout