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
| Member | Summary |
|---|---|
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
| Member | Summary |
|---|---|
Count | How many items are shown. |
First | Index of the first item shown. |
Last | Index of the last item shown. Reads as one before ScrollWindow.First when nothing fits. |
Methods
| Member | Summary |
|---|---|
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
| Name | Type | Description |
|---|---|---|
First | int | Index of the first item shown. |
Count | int | How 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
| Name | Type | Description |
|---|---|---|
selectedIndex | int | Index that has to stay visible. |
itemCount | int | Length of the full list. |
rows | int | How 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
| Name | Type | Description |
|---|---|---|
index | int | Index in the full list. |
Returns bool — true when the item falls inside the window.
Deconstruct(out int, out int)
public void Deconstruct(out int First, out int Count);
Parameters
| Name | Type | Description |
|---|---|---|
First | int | |
Count | int |