Class ScrollBar
ListView,
TextArea, ScrollView, …), so they look and behave identically.
It is an overlay widget the host lays out along an edge; it reads/writes
scroll through a ScrollBar.Model and handles its own thumb drag and track paging.
- Themed: the thumb is drawn in
Theme.textMuted, so it is visible on both light and dark surfaces. - Draggable: drag the thumb, or click the track to page.
- Policy (
setPolicy(limn.components.ScrollBar.Policy)):ScrollBar.Policy.HIDDEN,ScrollBar.Policy.ALWAYS,ScrollBar.Policy.ON_SCROLL(fades in on scroll) orScrollBar.Policy.AUTO(also while the pointer is active over the host). - Thin idle / wide on approach: a slim bar that widens when the pointer is over it or dragging, ready to grab.
- Mirrored: a horizontal bar reads with its subtree, so right to left the thumb rests at the right end of the track and walks left as the offset grows. A vertical bar's travel is a y and never mirrors; only the side its thumb hugs does, following the side the host puts the strip on.
onScrolled() when it scrolls and onHostActivity()
on pointer movement (for AUTO).
The hold is a timer, not an animation. A reveal lasts HOLD_SECONDS past
the last scroll or pointer movement and then fades; the fade in and out are transitions,
which tick only while a value moves. The hold itself used to be a real-time ticker that
returned "still holding" every frame for a second after every pointer move, and a scene
keeps its frame pump running while any ticker is alive: moving the pointer over a form
inside a scroll view rendered at the display's rate with nothing on screen changing, and
resting it over the bar rendered forever. The hold is now a timestamp compared on demand
and one delayed task armed for the moment it expires, so a bar that is showing and still
asks for no frame at all.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe scroll state the bar reflects and drives.static enumWhich axis the bar controls.static enumWhen the bar is shown. -
Constructor Summary
ConstructorsConstructorDescriptionScrollBar(ScrollBar.Orientation orientation, ScrollBar.Model model) A bar reading its extent and offset frommodel. -
Method Summary
Modifier and TypeMethodDescriptionhitTest(float localX, float localY) Transparent to events while effectively invisible, so it never blocks the content.voidThe pointer is active over the host: reveal the bar (AUTO).protected SizeonMeasure(Constraints constraints) Reports the size this widget wants withinconstraints.protected voidonMouseEvent(MouseEvent event) Mouse events (bubbling); callevent.consume()when handled.protected voidWidget's own background/content, in local coordinates.voidThe host scrolled: reveal the bar (ON_SCROLL / AUTO).policy()The current visibility policy.voidrefresh()Re-evaluate visibility after the content/overflow changed.setPolicy(ScrollBar.Policy newPolicy) When the bar is shown: always, never, or only while the content overflows.static floatThe strip thickness the host reserves/lays the bar out with.Methods inherited from class limn.scene.Widget
acceptsTextInput, add, baselineOffset, baselineOffsetOf, caretRect, children, clipboard, clipsChildren, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedByTraversal, height, imageCursor, invalidate, invalidate, isEnabled, isFocusable, isFocused, isShowing, isVisible, layoutBox, layoutDirection, locale, localToSceneX, localToSceneY, markNeedsContainedLayout, markNeedsLayout, measure, moveChild, neutralBase, onAttached, onCharTyped, onDetached, onFileDrop, onFocusGained, onFocusLost, onKeyEvent, onLayout, onPaintOverlay, onPreedit, overlayPassesPointer, paintChildren, paintOutset, paintWidget, parent, remove, requestFocus, revealInView, scene, sceneToLocalX, sceneToLocalY, setControlSize, setCursor, setEnabled, setFocusable, setImageCursor, setInheritanceHost, setLayoutDirection, setLocale, setTooltip, setTooltip, setVisible, shapeText, textRuler, tooltip, width, x, y
-
Constructor Details
-
ScrollBar
A bar reading its extent and offset frommodel.
-
-
Method Details
-
setPolicy
When the bar is shown: always, never, or only while the content overflows. -
policy
The current visibility policy. -
thickness
public static float thickness()The strip thickness the host reserves/lays the bar out with. -
onScrolled
public void onScrolled()The host scrolled: reveal the bar (ON_SCROLL / AUTO). -
onHostActivity
public void onHostActivity()The pointer is active over the host: reveal the bar (AUTO). Called for every pointer move over the host, so it must cost nothing while the bar is already showing: a stamp and two comparisons, no invalidation and no frame. -
refresh
public void refresh()Re-evaluate visibility after the content/overflow changed.Content that has just become scrollable reveals the bar for one hold-and-fade, the way an overlay scroller flashes when a pane first has something to scroll. Under
ScrollBar.Policy.AUTO(the default, and what aDialogbody uses) the bar is otherwise invisible until the pointer moves over the host or the wheel turns, so a card that was capped opens with nothing at all saying that anything was cut off. The gutter inset says the card is capped; only the bar says it can be scrolled. -
onMeasure
Description copied from class:WidgetReports the size this widget wants withinconstraints. Called once per layout pass, and the result is cached against the constraints and the resolved axes (size step, layout direction, locale), so it must be a pure function of them and of this widget's own state.Resolve the
ControlSizeand theLayoutDirectiononce each here and thread them down; never read either in a constructor. The locale needs no threading: it is in scope, andI18n.locale()answers it wherever text is resolved. -
onPaint
Description copied from class:WidgetWidget's own background/content, in local coordinates. -
hitTest
Transparent to events while effectively invisible, so it never blocks the content. -
onMouseEvent
Description copied from class:WidgetMouse events (bubbling); callevent.consume()when handled.- Overrides:
onMouseEventin classWidget
-