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
namestring
Property Value
Exceptions
- KeyNotFoundException
No region has this name.
Methods
Add(string, Constraint)
Add a named region.
public Layout Add(string name, Constraint constraint)
Parameters
namestringconstraintConstraint
Returns
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
Flex(Flex)
Where space goes when no region can grow into it. The default is Start.
public Layout Flex(Flex flex)
Parameters
flexFlex
Returns
Horizontal(Rect)
Create a horizontal layout (columns side by side).
public static Layout Horizontal(Rect area)
Parameters
areaRect
Returns
Margin(Margin)
Lay the regions out inside margin.
public Layout Margin(Margin margin)
Parameters
marginMargin
Returns
Spacing(int)
Leave cells empty cells between regions. Reduced if it doesn't fit.
public Layout Spacing(int cells)
Parameters
cellsint
Returns
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
areaRectdirectionDirectionconstraintsConstraint[]
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
Returns
Vertical(Rect)
Create a vertical layout (rows stacked top to bottom).
public static Layout Vertical(Rect area)
Parameters
areaRect