Class ScrollView
- All Implemented Interfaces:
Scrollable
(-offsetX, -offsetY), so hit-testing and event coordinates work
unchanged.
Scroll indicators are the shared ScrollBar (draggable, themed,
policy-driven), the same component every scroller uses.
The bars either float over the content or take a gutter of their own
(setBarLayout(limn.components.ScrollGutters.Layout)). Which one is right is a property of what is being
scrolled, not a taste: an image, a video or a page of prose wants every point of
width and loses nothing to a bar that fades over it, while a table, a form or a
tree wants its last column readable at all times, and a bar sitting on it is a
defect however briefly it shows.
-
Constructor Summary
ConstructorsConstructorDescriptionScrollView(Widget child) Wrapschild, scrolling on both axes as its content overflows.ScrollView(Widget child, boolean horizontal, boolean vertical) Wrapschild, scrolling only on the axes enabled here. -
Method Summary
Modifier and TypeMethodDescriptionWhether the scrollbars overlay the content or reserve a gutter.protected booleanWhetherWidget.paintChildren(limn.graphics.Canvas)clips its children to this widget's bounds (scroll views, list viewports, tab strips).floatLargest validoffsetX();0when the content fits.floatLargest validoffsetY();0when the content fits.floatoffsetX()Horizontal scroll position in logical points,0at the leading edge: the left edge in a left-to-right subtree and the right edge in a right-to-left one.floatoffsetY()Vertical scroll position in logical points,0at the top.protected voidonKeyEvent(KeyEvent event) Key events (focused widget first, then ancestors).protected voidonLayout()Containers position children here (measure +Widget.layoutBox(float, float, float, float)per child).protected SizeonMeasure(Constraints constraints) Reports the size this widget wants withinconstraints.protected voidonMouseEvent(MouseEvent event) Mouse events (bubbling); callevent.consume()when handled.protected voidpaintChildren(Canvas canvas) Children pass; override to clip (e.g.voidrevealRect(float x, float y, float rectWidth, float rectHeight) Scrolls the minimum so the rect (in viewport coordinates) becomes visible.voidscrollBy(float dx, float dy) Scrolls by a delta in logical points (clamped).voidscrollTo(float newOffsetX, float newOffsetY) Scrolls to an absolute offset (clamped to the content).setBarLayout(ScrollGutters.Layout layout) Sets whether the bars float over the content or reserve a strip of their own (defaultScrollGutters.Layout.OVERLAY).setScrollbarPolicy(ScrollBar.Policy policy) Sets the scrollbar visibility policy (defaultScrollBar.Policy.AUTO).floatVisible height in logical points, excluding anything the content overflows by.floatThe width content is actually shown in: the box, less any reserved gutter.Methods inherited from class limn.scene.Widget
acceptsTextInput, add, baselineOffset, baselineOffsetOf, caretRect, children, clipboard, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedByTraversal, height, hitTest, imageCursor, invalidate, invalidate, isEnabled, isFocusable, isFocused, isShowing, isVisible, layoutBox, layoutDirection, locale, localToSceneX, localToSceneY, markNeedsContainedLayout, markNeedsLayout, measure, moveChild, neutralBase, onAttached, onCharTyped, onDetached, onFileDrop, onFocusGained, onFocusLost, onPaint, onPaintOverlay, onPreedit, overlayPassesPointer, 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
-
ScrollView
Wrapschild, scrolling on both axes as its content overflows. -
ScrollView
Wrapschild, scrolling only on the axes enabled here.
-
-
Method Details
-
setScrollbarPolicy
Sets the scrollbar visibility policy (defaultScrollBar.Policy.AUTO). -
setBarLayout
Sets whether the bars float over the content or reserve a strip of their own (defaultScrollGutters.Layout.OVERLAY). -
barLayout
Whether the scrollbars overlay the content or reserve a gutter. -
viewportWidth
public float viewportWidth()The width content is actually shown in: the box, less any reserved gutter. Every offset, clamp and reveal is measured against this rather than againstWidget.width(), or a reserved bar would hide the last column it exists to keep clear. -
viewportHeight
public float viewportHeight()Visible height in logical points, excluding anything the content overflows by. -
offsetX
public float offsetX()Horizontal scroll position in logical points,0at the leading edge: the left edge in a left-to-right subtree and the right edge in a right-to-left one. The range is[0, maxOffsetX()]in both, so "scrolled to the start" is0either way. -
offsetY
public float offsetY()Vertical scroll position in logical points,0at the top. -
maxOffsetX
public float maxOffsetX()Largest validoffsetX();0when the content fits. -
maxOffsetY
public float maxOffsetY()Largest validoffsetY();0when the content fits. -
scrollBy
public void scrollBy(float dx, float dy) Scrolls by a delta in logical points (clamped). -
revealRect
public void revealRect(float x, float y, float rectWidth, float rectHeight) Scrolls the minimum so the rect (in viewport coordinates) becomes visible.- Specified by:
revealRectin interfaceScrollable
-
scrollTo
public void scrollTo(float newOffsetX, float newOffsetY) Scrolls to an absolute offset (clamped to the content). UI thread only. -
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. -
onLayout
protected void onLayout()Description copied from class:WidgetContainers position children here (measure +Widget.layoutBox(float, float, float, float)per child). -
clipsChildren
protected boolean clipsChildren()Description copied from class:WidgetWhetherWidget.paintChildren(limn.graphics.Canvas)clips its children to this widget's bounds (scroll views, list viewports, tab strips). Partial rendering uses it to clamp a descendant'sWidget.invalidate()damage to the visible region; a widget scrolled out of view damages nothing. Any override that clips inpaintChildrenshould also override this.- Overrides:
clipsChildrenin classWidget
-
paintChildren
Description copied from class:WidgetChildren pass; override to clip (e.g. scroll views).- Overrides:
paintChildrenin classWidget
-
onMouseEvent
Description copied from class:WidgetMouse events (bubbling); callevent.consume()when handled.- Overrides:
onMouseEventin classWidget
-
onKeyEvent
Description copied from class:WidgetKey events (focused widget first, then ancestors).- Overrides:
onKeyEventin classWidget
-