ScrollPane class
Namespace: Arlecchino.Widgets.Lists · Assembly: Arlecchino
A window onto content taller than the space it has: it draws the content shifted up by the offset, clips it, and answers the movement keys and the wheel. The content is drawn by a delegate rather than owned.
public sealed class ScrollPane :
IArlecchinoInteractiveWidget,
IArlecchinoWidget,
IArlecchinoFocusable
Implements IArlecchinoInteractiveWidget, IArlecchinoWidget, IArlecchinoFocusable
Constructors
| Member | Summary |
|---|---|
ScrollPane(ArlecchinoKeymap) | Creates the pane. |
Properties
| Member | Summary |
|---|---|
Content | Draws the content. The region it is handed is as tall as ScrollPane.ContentHeight and moved up by the offset, so the delegate always writes at row zero for the first line and never has to know where the window is. |
ContentHeight | How many rows the content occupies, asked once per frame. |
IsFocused | Whether the pane has focus. Only a focused pane answers keys. |
Offset | First content row shown, clamped to what there is on every frame. |
ShowScrollBar | Whether a scroll bar is drawn down the last column when the content does not fit. |
Methods
| Member | Summary |
|---|---|
Draw(SurfaceRegion) | Draws the visible slice of the content, and the scroll bar when one is needed. The pane is a window onto content taller than itself, so nothing is ever left underneath it. |
Handle(KeyPress) | Moves the window a row, a page, or to either end. |
HandleMouse(MouseEvent) | Scrolls with the wheel while the pointer is over the pane. |
Constructors in detail
ScrollPane(ArlecchinoKeymap)
Constructors of types with required members are not supported in this version of your compiler.
public ScrollPane(ArlecchinoKeymap keymap);
Creates the pane.
Parameters
| Name | Type | Description |
|---|---|---|
keymap | ArlecchinoKeymap | Keys to obey, so the pane follows the application's bindings. |
Properties in detail
Content
public Action<SurfaceRegion> Content { get; init; }
Draws the content. The region it is handed is as tall as ScrollPane.ContentHeight and moved up by the offset, so the delegate always writes at row zero for the first line and never has to know where the window is.
Type Action<T><SurfaceRegion>
ContentHeight
public Func<int> ContentHeight { get; init; }
How many rows the content occupies, asked once per frame.
Type Func<TResult><int>
IsFocused
public bool IsFocused { get; set; }
Whether the pane has focus. Only a focused pane answers keys.
Type bool
Offset
public int Offset { get; set; }
First content row shown, clamped to what there is on every frame.
Type int
ShowScrollBar
public bool ShowScrollBar { get; set; }
Whether a scroll bar is drawn down the last column when the content does not fit.
Type bool
Methods in detail
Draw(SurfaceRegion)
public SurfaceRegion Draw(SurfaceRegion region);
Draws the visible slice of the content, and the scroll bar when one is needed. The pane is a window onto content taller than itself, so nothing is ever left underneath it.
Parameters
| Name | Type | Description |
|---|---|---|
region | SurfaceRegion | Where to draw. |
Returns SurfaceRegion — An empty region: the pane uses every row it is handed.
Handle(KeyPress)
public FocusResult Handle(KeyPress key);
Moves the window a row, a page, or to either end.
Parameters
| Name | Type | Description |
|---|---|---|
key | KeyPress | The key that was pressed. |
Returns FocusResult — Whether the pane took it.
HandleMouse(MouseEvent)
public FocusResult HandleMouse(MouseEvent mouse);
Scrolls with the wheel while the pointer is over the pane.
Parameters
| Name | Type | Description |
|---|---|---|
mouse | MouseEvent | The event that arrived. |
Returns FocusResult — Whether the pane took it.