Skip to content
ConsoleMonster
Class

LayoutGrid

ConsoleMonster.Layout

Namespace
ConsoleMonster.Layout
Assembly
ConsoleMonster
Implements
IContainer IWidget IContentOwner
Modifiers
sealed

Lays children out in equal-width columns, row by row. Cells in a row share the row height. When columns would become narrower than LayoutGrid.MinColumnWidth, the grid uses fewer columns. In a live frame with spare height, rows grow equally so the grid fills its region.

Inheritance

  • object
  • LayoutGrid

Usage

Explore 28 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 14

Constructors

public LayoutGrid(int columns, params IWidget[] children) #

Creates a grid.

Parameters

columns int required
Number of columns (at least 1).
children ConsoleMonster.Layout.IWidget[] required
Initial children.

Methods

public LayoutGrid Add(IWidget child) #

Adds a cell.

Parameters

child ConsoleMonster.Layout.IWidget required
The child.

Returns

LayoutGrid This instance.
public Size Measure(Constraints constraints, RenderContext context) #

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints required
The space offered.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Returns

Size The desired size, never larger than the constraints.
public void Render(Region region, RenderContext context) #

Renders into a region. The region may be smaller or larger than the measured size.

Parameters

region ConsoleMonster.Canvas.Region required
The target region.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Properties

public int Columns { get; set; } #

The preferred number of columns.

public int ColumnGap { get; set; } #

Blank columns between cells (default 1).

public int RowGap { get; set; } #

Blank rows between grid rows (default 0).

public int MinColumnWidth { get; set; } #

The narrowest column before the grid reduces its column count (default 24).

public bool FillHeight { get; set; } #

Whether rows grow to fill spare height in a bounded region (default true).

public IReadOnlyList<IWidget> Children { get; } #

The child widgets in layout order.

Extension Methods

public static LayoutGrid ColumnGap(LayoutGrid layoutGrid, int value) #

Sets LayoutGrid.ColumnGap: Blank columns between cells (default 1).

Parameters

layoutGrid ConsoleMonster.Layout.LayoutGrid required
The instance.
value int required
The value.

Returns

LayoutGrid The same instance.

Examples

// C# initializer or property    // C# fluent
layoutGrid.ColumnGap = value;    Ui.LayoutGrid().ColumnGap(value);
public static LayoutGrid Columns(LayoutGrid layoutGrid, int value) #

Sets LayoutGrid.Columns: The preferred number of columns.

Parameters

layoutGrid ConsoleMonster.Layout.LayoutGrid required
The instance.
value int required
The value.

Returns

LayoutGrid The same instance.

Examples

// C# initializer or property    // C# fluent
layoutGrid.Columns = value;      Ui.LayoutGrid().Columns(value);
Content 2 overloads
public static LayoutGrid Content(LayoutGrid layoutGrid, IWidget content) #

Configures this container's content before session ownership.

Parameters

layoutGrid ConsoleMonster.Layout.LayoutGrid required
The instance.
content ConsoleMonster.Layout.IWidget required
The widget or nested content builder.

Returns

LayoutGrid The same instance.
public static LayoutGrid Content(LayoutGrid layoutGrid, Action<ContentBuilder> content) #

Configures this container's content before session ownership.

Parameters

layoutGrid ConsoleMonster.Layout.LayoutGrid required
The instance.
content System.Action<ConsoleMonster.Layout.ContentBuilder> required
The widget or nested content builder.

Returns

LayoutGrid The same instance.
FillHeight 2 overloads
public static LayoutGrid FillHeight(LayoutGrid layoutGrid, bool value) #

Sets LayoutGrid.FillHeight: Whether rows grow to fill spare height in a bounded region (default true).

Parameters

layoutGrid ConsoleMonster.Layout.LayoutGrid required
The instance.
value bool required
The value.

Returns

LayoutGrid The same instance.

Examples

// C# initializer or property     // C# fluent
layoutGrid.FillHeight = value;    Ui.LayoutGrid().FillHeight(value);
public static LayoutGrid FillHeight(LayoutGrid layoutGrid) #

Sets LayoutGrid.FillHeight to true.

Parameters

layoutGrid ConsoleMonster.Layout.LayoutGrid required
The instance to configure.

Returns

LayoutGrid The same instance.
public static LayoutGrid MinColumnWidth(LayoutGrid layoutGrid, int value) #

Sets LayoutGrid.MinColumnWidth: The narrowest column before the grid reduces its column count (default 24).

Parameters

layoutGrid ConsoleMonster.Layout.LayoutGrid required
The instance.
value int required
The value.

Returns

LayoutGrid The same instance.

Examples

// C# initializer or property         // C# fluent
layoutGrid.MinColumnWidth = value;    Ui.LayoutGrid().MinColumnWidth(value);
public static LayoutGrid RowGap(LayoutGrid layoutGrid, int value) #

Sets LayoutGrid.RowGap: Blank rows between grid rows (default 0).

Parameters

layoutGrid ConsoleMonster.Layout.LayoutGrid required
The instance.
value int required
The value.

Returns

LayoutGrid The same instance.

Examples

// C# initializer or property    // C# fluent
layoutGrid.RowGap = value;       Ui.LayoutGrid().RowGap(value);