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
| Member | Summary |
|---|---|
Tabs(ArlecchinoKeymap) | Creates the strip. |
Properties
| Member | Summary |
|---|---|
IsFocused | Whether the strip has focus, which decides how strongly the current tab is drawn. |
OnSelected | Called when the selection actually changes, not on every attempt to move. |
SelectedIndex | Index of the current tab. |
Titles | The labels, as delegates, so a tab can show a count or a marker that changes. |
Methods
| Member | Summary |
|---|---|
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)
Constructors of types with required members are not supported in this version of your compiler.
public Tabs(ArlecchinoKeymap keymap);
Creates the strip.
Parameters
| Name | Type | Description |
|---|---|---|
keymap | ArlecchinoKeymap | Keys 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
| Name | Type | Description |
|---|---|---|
region | SurfaceRegion | Where 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
| Name | Type | Description |
|---|---|---|
key | KeyPress | The 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
| Name | Type | Description |
|---|---|---|
mouse | MouseEvent | The 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
| Name | Type | Description |
|---|---|---|
index | int | Tab to switch to. |