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.
public sealed class ScrollView : WidgetInheritance
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).
public ScrollView(Widget? content = null)Parameters
content Widget?
Properties
Children
The widgets this one contains, in focus and drawing order.
public override IReadOnlyList<Widget> Children { get; }Property Value
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.
public override bool ClipsChildren { get; }Property Value
Content
The widget scrolled, or null.
public Widget? Content { get; set; }Property Value
InterceptsDrag
A drag inside the view scrolls it, while the content does not fit.
protected override bool InterceptsDrag { get; }Property Value
MaxScroll
How far the content can scroll by the last layout: its length beyond the view’s, or 0 when it fits.
public float MaxScroll { get; }Property Value
Orientation
The direction the content scrolls in (vertical by default).
public Orientation Orientation { get; set; }Property Value
Scroll
How far the content is scrolled, in UI units, from 0 to MaxScroll.
public float Scroll { get; set; }Property Value
ShowScrollBar
Whether the bar that shows the scroll position is drawn while the content does not fit (true by default).
public bool ShowScrollBar { get; set; }Property Value
WheelStep
How far one notch of the wheel scrolls, in UI units; null (the default) is three lines of the font.
public float? WheelStep { get; set; }Property Value
Methods
ArrangeContent(RectF, UiContext)
Places the children within bounds; nothing by default.
protected override void ArrangeContent(RectF bounds, UiContext context)Parameters
bounds RectF
context UiContext
DrawContent(IRenderer, UiContext)
Draws the widget in Bounds, and its children.
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.
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.
protected override Vector2 MeasureContent(UiContext context)Parameters
context UiContext
Returns
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.
protected override void OnPointerDown(Vector2 position)Parameters
position Vector2
OnPointerMove(Vector2)
The content follows the pointer.
protected override void OnPointerMove(Vector2 position)Parameters
position Vector2
OnWheel(Vector2)
Scrolls by the wheel: away from the player goes back towards the start.
protected override bool OnWheel(Vector2 delta)Parameters
delta Vector2