Table of Contents

Class SpinnerControl

Namespace
SharpConsoleUI.Controls
Assembly
SharpConsoleUI.dll

An animated spinner control for indeterminate-progress feedback. Cycles a set of glyph frames on a fixed interval via the window system's animation manager. Frames may contain Spectre-compatible markup (e.g. "[yellow]◐[/]").

public class SpinnerControl : BaseControl, IWindowControl, IDisposable, IDOMPaintable, INotifyPropertyChanged, IColorRoleableControl
Inheritance
SpinnerControl
Implements
Inherited Members
Extension Methods

Constructors

SpinnerControl()

Initializes a new spinner.

public SpinnerControl()

Properties

Color

Gets or sets the foreground color for plain (un-marked-up) frames. Theme-resolved when null.

public Color? Color { get; set; }

Property Value

Color?

ColorRole

The semantic color role. Default = no role (normal resolution).

public ColorRole ColorRole { get; set; }

Property Value

ColorRole

ColorRoleMode

Optional ThemeMode override for role-colour derivation. When non-null, the role's dark/light seed colours are resolved as if the theme were in this mode, regardless of the theme's own Mode. When null (the default), the active theme's mode is used.

public ThemeMode? ColorRoleMode { get; set; }

Property Value

ThemeMode?

Container

Gets or sets the parent container that hosts this control.

public override IContainer? Container { get; set; }

Property Value

IContainer

ContentWidth

Gets the minimum width needed to display the control's content, including margins. Returns null if width cannot be determined. This is calculated based on content (text length, child controls, etc.) and represents the natural/intrinsic size.

public override int? ContentWidth { get; }

Property Value

int?

CurrentFrameIndex

Gets the current frame index.

public int CurrentFrameIndex { get; }

Property Value

int

EffectiveFrames

Gets the frame set actually in use (custom frames if set, else the style preset).

public IReadOnlyList<string> EffectiveFrames { get; }

Property Value

IReadOnlyList<string>

Frames

Gets or sets custom frames (overrides Style when non-empty). May contain markup.

public IReadOnlyList<string>? Frames { get; set; }

Property Value

IReadOnlyList<string>

IntervalMs

Gets or sets the per-frame interval in milliseconds. When not explicitly set, the getter resolves to the per-style default (see DefaultIntervalMs(SpinnerStyle)).

public int IntervalMs { get; set; }

Property Value

int

IsSpinning

Gets or sets whether the spinner is animating.

public bool IsSpinning { get; set; }

Property Value

bool

Outline

When true and a role is set, renders outline style (role color on text + border, surface fill).

public bool Outline { get; set; }

Property Value

bool

Style

Gets or sets the preset frame style. Default Braille.

public SpinnerStyle Style { get; set; }

Property Value

SpinnerStyle

Width

Gets or sets an explicit minimum width (in columns) for the spinner. The control always reserves at least the widest frame's width, so a smaller value is clamped up and never clips the glyph; a larger value pads the reserved field (e.g. to align the spinner with neighbouring controls). Null (the default) reserves exactly the widest frame's width.

public override int? Width { get; set; }

Property Value

int?

Methods

GetLogicalContentSize()

Gets the logical size of the control's content without rendering.

public override Size GetLogicalContentSize()

Returns

Size

The size representing the content's natural dimensions.

MeasureDOM(LayoutConstraints)

Measures the control's desired size given the available constraints.

public override LayoutSize MeasureDOM(LayoutConstraints constraints)

Parameters

constraints LayoutConstraints

The layout constraints (min/max width/height).

Returns

LayoutSize

The desired size of the control.

PaintDOM(CharacterBuffer, LayoutRect, LayoutRect, Color, Color)

Paints the control's content directly to a CharacterBuffer.

public override void PaintDOM(CharacterBuffer buffer, LayoutRect bounds, LayoutRect clipRect, Color defaultFg, Color defaultBg)

Parameters

buffer CharacterBuffer

The buffer to paint to.

bounds LayoutRect

The absolute bounds where the control should paint.

clipRect LayoutRect

The clipping rectangle (visible area).

defaultFg Color
defaultBg Color

Start()

Starts animating.

public void Start()

Stop()

Stops animating, freezing the current frame.

public void Stop()