Skip to main content

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

MemberSummary
ScrollPane(ArlecchinoKeymap)Creates the pane.

Properties

MemberSummary
ContentDraws 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.
ContentHeightHow many rows the content occupies, asked once per frame.
IsFocusedWhether the pane has focus. Only a focused pane answers keys.
OffsetFirst content row shown, clamped to what there is on every frame.
ShowScrollBarWhether a scroll bar is drawn down the last column when the content does not fit.

Methods

MemberSummary
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)

Obsolete

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

public ScrollPane(ArlecchinoKeymap keymap);

Creates the pane.

Parameters

NameTypeDescription
keymapArlecchinoKeymapKeys 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

NameTypeDescription
regionSurfaceRegionWhere 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

NameTypeDescription
keyKeyPressThe 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

NameTypeDescription
mouseMouseEventThe event that arrived.

Returns FocusResult — Whether the pane took it.