Skip to main content

ScrollWindow struct

Namespace: Arlecchino.Widgets.Lists · Assembly: Arlecchino

The slice of a long list that fits on screen. Every scrolling widget works this out the same way, so the arithmetic lives here rather than in each of them.

public readonly struct ScrollWindow : IEquatable<ScrollWindow>

Implements IEquatable<T><ScrollWindow>

Constructors

MemberSummary
ScrollWindow(int, int)The slice of a long list that fits on screen. Every scrolling widget works this out the same way, so the arithmetic lives here rather than in each of them.

Properties

MemberSummary
CountHow many items are shown.
FirstIndex of the first item shown.
LastIndex of the last item shown. Reads as one before ScrollWindow.First when nothing fits.

Methods

MemberSummary
Around(int, int, int)Places the window with the selection in the middle, sliding it back at the ends of the list, so the rows are always filled rather than trailing off into blanks.
Contains(int)Whether an item is in view, which is what decides if it needs drawing.
Deconstruct(out int, out int)

Constructors in detail

ScrollWindow(int, int)

public ScrollWindow(int First, int Count);

The slice of a long list that fits on screen. Every scrolling widget works this out the same way, so the arithmetic lives here rather than in each of them.

Parameters

NameTypeDescription
FirstintIndex of the first item shown.
CountintHow many items are shown.

Properties in detail

Count

public int Count { get; init; }

How many items are shown.

Type int

First

public int First { get; init; }

Index of the first item shown.

Type int

Last

public int Last { get; }

Index of the last item shown. Reads as one before ScrollWindow.First when nothing fits.

Type int

Methods in detail

Around(int, int, int)

public static ScrollWindow Around(int selectedIndex, int itemCount, int rows);

Places the window with the selection in the middle, sliding it back at the ends of the list, so the rows are always filled rather than trailing off into blanks.

Parameters

NameTypeDescription
selectedIndexintIndex that has to stay visible.
itemCountintLength of the full list.
rowsintHow many rows there are to draw into.

Returns ScrollWindow — The slice to draw; empty when there is nothing to show or nowhere to show it.

Contains(int)

public bool Contains(int index);

Whether an item is in view, which is what decides if it needs drawing.

Parameters

NameTypeDescription
indexintIndex in the full list.

Returns booltrue when the item falls inside the window.

Deconstruct(out int, out int)

public void Deconstruct(out int First, out int Count);

Parameters

NameTypeDescription
Firstint
Countint