Skip to content

API reference

Class ScrollView

Namespace: MicroEngine.UI
Assembly: MicroEngine.UI.dll
Guide: UI widgets

A window onto content longer than the space it has: a long menu, a list of saves, an achievement list, the credits. Give it a fixed Height (or Width when Orientation is horizontal); its content keeps the size it measures and is cut at the view’s edges. It scrolls to show a widget inside it when that widget takes the focus, with the wheel over it, and with a drag, also one that starts on a button inside it (a finger on a phone). A thin bar on its edge shows where the window is.

C#
public sealed class ScrollView : Widget

Inheritance

object ← Widget ← ScrollView

Inherited Members

Widget.Measure(UiContext), Widget.Arrange(RectF, UiContext), Widget.Draw(IRenderer, UiContext), Widget.Bounds, Widget.Visible, Widget.Enabled, Widget.Width, Widget.Height, Widget.Offset, Widget.Opacity, Widget.BlocksPointer, Widget.Parent, Widget.Root, Widget.Children, Widget.Focusable, Widget.ClipsChildren, Widget.IsFocused, Widget.IsHovered, Widget.IsPressed, Widget.IsEnabledInTree, Widget.IsVisibleInTree, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

ScrollView(Widget?)

A view of content (optional).

C#
public ScrollView(Widget? content = null)

Parameters

content Widget?

Properties

Children

The widgets this one contains, in focus and drawing order.

C#
public override IReadOnlyList<Widget> Children { get; }

Property Value

IReadOnlyList<Widget>

ClipsChildren

Whether the widget restricts its children to its Bounds (false by default): what they draw outside is cut, and the pointer outside reaches them neither. A scrolling container does.

C#
public override bool ClipsChildren { get; }

Property Value

bool

Content

The widget scrolled, or null.

C#
public Widget? Content { get; set; }

Property Value

Widget?

InterceptsDrag

A drag inside the view scrolls it, while the content does not fit.

C#
protected override bool InterceptsDrag { get; }

Property Value

bool

MaxScroll

How far the content can scroll by the last layout: its length beyond the view’s, or 0 when it fits.

C#
public float MaxScroll { get; }

Property Value

float

Orientation

The direction the content scrolls in (vertical by default).

C#
public Orientation Orientation { get; set; }

Property Value

Orientation

Scroll

How far the content is scrolled, in UI units, from 0 to MaxScroll.

C#
public float Scroll { get; set; }

Property Value

float

ShowScrollBar

Whether the bar that shows the scroll position is drawn while the content does not fit (true by default).

C#
public bool ShowScrollBar { get; set; }

Property Value

bool

WheelStep

How far one notch of the wheel scrolls, in UI units; null (the default) is three lines of the font.

C#
public float? WheelStep { get; set; }

Property Value

float?

Methods

ArrangeContent(RectF, UiContext)

Places the children within bounds; nothing by default.

C#
protected override void ArrangeContent(RectF bounds, UiContext context)

Parameters

bounds RectF

context UiContext

DrawContent(IRenderer, UiContext)

Draws the widget in Bounds, and its children.

C#
protected override void DrawContent(IRenderer renderer, UiContext context)

Parameters

renderer IRenderer

context UiContext

HashState(StateHasher)

Adds the widget’s state that decides what happens next (a text field’s text) to the scene’s state hash; nothing by default.

C#
protected override void HashState(StateHasher hash)

Parameters

hash StateHasher

MeasureContent(UiContext)

The content’s size, and the scroll bar’s strip when the content is longer than the fixed length.

C#
protected override Vector2 MeasureContent(UiContext context)

Parameters

context UiContext

Returns

Vector2

OnPointerDown(Vector2)

Called when a pointer press starts on the widget (the focusable widget under the pointer, or its nearest focusable container). position is in UI units, like Bounds. The widget then holds the press: it receives the press’s moves and its release wherever the pointer goes.

C#
protected override void OnPointerDown(Vector2 position)

Parameters

position Vector2

OnPointerMove(Vector2)

The content follows the pointer.

C#
protected override void OnPointerMove(Vector2 position)

Parameters

position Vector2

OnWheel(Vector2)

Scrolls by the wheel: away from the player goes back towards the start.

C#
protected override bool OnWheel(Vector2 delta)

Parameters

delta Vector2

Returns

bool