Skip to content
ConsoleMonster
Class

RegionWidget

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

A named place in a layout whose widget can be replaced while a live session runs: put it anywhere (inside a panel, a column, a dashboard), then swap its content with LiveSession.Region or a RegionHandle. The swap goes through the session's update queue, so it is thread-safe and lands between frames; the surrounding layout is recomposed and the existing cell diff writes only changed cells. Live widgets inside the new content are registered with the session under their names, replacing widgets of the same name. Live operations: set (Payload = the new widget), clear.

Inheritance

Constructors

public RegionWidget(string widgetId, IWidget? content = null) #

Creates a slot.

Parameters

widgetId string required
The live name the slot is addressed by.
content ConsoleMonster.Layout.IWidget? = null optional
The first content, or null for an empty slot.

Methods

public override void Apply(LiveEvent liveEvent) #

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event.
public RegionHandle Handle(ILiveDispatcher dispatcher) #

A handle that replaces the content through a dispatcher (a live session).

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher required
The dispatcher.

Returns

RegionHandle The handle.
public override 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 override 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.
public void Set(IWidget? content) #

Replaces the content directly (not thread-safe; use a handle while a session runs).

Parameters

content ConsoleMonster.Layout.IWidget? required
The new content, or null to empty the slot.

Properties

public IWidget Content { get; } #

The current content.

public IReadOnlyList<IWidget> Children { get; } #

The child widgets in layout order.