Skip to main content

Tabs class

Namespace: Arlecchino.Widgets.Lists · Assembly: Arlecchino

A row of labels where one is current. The widget only tracks which that is; what each tab shows is left to the view, which draws whatever fits the selection.

public sealed class Tabs : IArlecchinoInteractiveWidget, IArlecchinoWidget, IArlecchinoFocusable

Implements IArlecchinoInteractiveWidget, IArlecchinoWidget, IArlecchinoFocusable

Constructors

MemberSummary
Tabs(ArlecchinoKeymap)Creates the strip.

Properties

MemberSummary
IsFocusedWhether the strip has focus, which decides how strongly the current tab is drawn.
OnSelectedCalled when the selection actually changes, not on every attempt to move.
SelectedIndexIndex of the current tab.
TitlesThe labels, as delegates, so a tab can show a count or a marker that changes.

Methods

MemberSummary
Draw(SurfaceRegion)Draws the labels side by side and remembers where each starts, which is what lets a click be resolved to a tab. Returns the rows below the strip, which is where the current tab's content belongs.
Handle(KeyPress)Switches tabs with the horizontal arrows, leaving everything else alone.
HandleMouse(MouseEvent)Switches to the tab that was clicked. A click in the gap between labels lands on the tab to its left, so the strip has no dead columns.
Select(int)Switches tabs, ignoring indexes outside the strip and moves that change nothing.

Constructors in detail

Tabs(ArlecchinoKeymap)

Obsolete

Constructors of types with required members are not supported in this version of your compiler.

public Tabs(ArlecchinoKeymap keymap);

Creates the strip.

Parameters

NameTypeDescription
keymapArlecchinoKeymapKeys to obey, so the strip follows the application's bindings.

Properties in detail

IsFocused

public bool IsFocused { get; set; }

Whether the strip has focus, which decides how strongly the current tab is drawn.

Type bool

OnSelected

public Action<int>? OnSelected { get; init; }

Called when the selection actually changes, not on every attempt to move.

Type Action<T><int>

SelectedIndex

public int SelectedIndex { get; }

Index of the current tab.

Type int

Titles

public IReadOnlyList<Func<string>> Titles { get; init; }

The labels, as delegates, so a tab can show a count or a marker that changes.

Type IReadOnlyList<T><Func<TResult><string>>

Methods in detail

Draw(SurfaceRegion)

public SurfaceRegion Draw(SurfaceRegion region);

Draws the labels side by side and remembers where each starts, which is what lets a click be resolved to a tab. Returns the rows below the strip, which is where the current tab's content belongs.

Parameters

NameTypeDescription
regionSurfaceRegionWhere to draw; only its first row is used.

Returns SurfaceRegion — The region below the strip.

Handle(KeyPress)

public FocusResult Handle(KeyPress key);

Switches tabs with the horizontal arrows, leaving everything else alone.

Parameters

NameTypeDescription
keyKeyPressThe key that was pressed.

Returns FocusResult — What became of the key.

HandleMouse(MouseEvent)

public FocusResult HandleMouse(MouseEvent mouse);

Switches to the tab that was clicked. A click in the gap between labels lands on the tab to its left, so the strip has no dead columns.

Parameters

NameTypeDescription
mouseMouseEventThe event that arrived.

Returns FocusResult — What became of the event.

Select(int)

public void Select(int index);

Switches tabs, ignoring indexes outside the strip and moves that change nothing.

Parameters

NameTypeDescription
indexintTab to switch to.