Create a new ScrollableViewportWidget.
If an axis is bi-coupled, that axis will not have a scrollbar.
Optional
properties: Readonly<ScrollableViewportWidgetProperties>Protected
Readonly
_childrenThis widget's children. Note that this is marked as readonly so that it cannot be accidentally replaced with a new array. This way, references to this array are always valid. If you want to clear this array, set the length to zero instead of creating a new instance. readonly still means that you can add/remove elements to/from the array.
See children for the public iterator getter.
Protected
_dirtyWidget will only be painted if dirty is true.
Protected
_flexflex but for internal use.
Protected
_layoutIf this is true, widget needs their layout resolved. If implementing a container, propagate this up.
Protected
_parentProtected
_rootPrivate
_scrollThe line height used for scrolling via wheel events.
Private
_scrollbarSee scrollbarMode. For internal use only
Protected
_viewportThe Viewport that this widget is currently painting to. A UI tree can have multiple Viewports due to ViewportWidget, so this is not equivalent to viewport.
Widgets not attached to a UI tree will have this property set to null.
Private
effectiveThe effective viewport height (ideal height not occupied by a non-overlay scrollbar), for scrollbar calculations. For internal use only.
Private
effectiveThe effective viewport width (ideal width not occupied by a non-overlay scrollbar), for scrollbar calculations. For internal use only.
Protected
forceForce child re-paint? Only used when not using a Viewport
Protected
heightHeight of widget in pixels.
Private
horizWas the horizontal scrollbar painted last frame?
Private
horizontalClickHelper used for checking if the horizontal scrollbar has been dragged
Protected
idealThe ideal height of the widget in pixels. See width.
Protected
idealThe ideal width of the widget in pixels; if non-integer widget dimensions were allowed, the widget would have this size. Use this for layout calculations, but never use this for painting so that subpixel issues are avoided.
Protected
idealXThe ideal absolute horizontal offset of the widget in pixels; if non-integer positions were allowed, the widget would have this position. Use this for layout calculations, but never use this for painting so that subpixel issues are avoided.
Protected
idealYThe ideal absolute vertical offset of the widget in pixels. See x.
Protected
Readonly
internalThe actual viewport object. Can be a ClippedViewport or a CanvasViewport.
Private
lastWhen was the last scroll attempt in milliseconds since Unix epoch?
The minimum height that this widget will try to expand to.
Will be automatically scaled depending on the current Root's resolution.
@layoutField
The minimum width that this widget will try to expand to.
Will be automatically scaled depending on the current Root's resolution.
@layoutField
Readonly
needsWidget will have its background automatically cleared when painting if needsClear is true. The background fill style used is canvasFill.
Readonly
propagatesWidget will get targetted events even if the target is not itself if it this is true. Useful for implementing container widgets.
Protected
reservedXThe amount of horizontal space to reserve. By default, no space is reserved. Useful for situations where additional parts are needed around the viewport, such as scrollbars in ScrollableViewportWidget.
Note that if scaling is being used, then these values are expected to already be scaled.
Should be set before handleResolveDimensions is called.
Protected
reservedYSimilar to reservedX, but vertical.
Private
startingWhat was the normalised offset when starting drag?
Private
startingWhat was the starting scroll value before dragging?
Protected
tabCan this widget be focused by pressing tab?
Readonly
useIs the internal viewport a CanvasViewport instance? If true, then the resolution of the Root will be inherited automatically.
Private
vertWas the vertical scrollbar painted last frame?
Private
verticalClickHelper used for checking if the vertical scrollbar has been dragged
Private
verticalIs the vertical scrollbar being dragged? If null, none is
Protected
widthWidth of widget in pixels.
Protected
xAbsolute horizontal offset of widget in pixels.
Protected
yAbsolute vertical offset of widget in pixels.
The accent fill style. Usually a saturated colour more saturated than primaryFill used for highlighting boxes which use PrimaryFill.
The accent fill style. Usually a saturated colour more saturated than primaryFill used for highlighting boxes which use PrimaryFill.
Public getter for _active. Can only be updated by calling updateActiveState, although this should never be done manually; only done automatically by container Widgets and Roots.
Check if this Widget is attached to a UI tree. If not, then this Widget must not be used. Must not be overridden.
The background fill style. Used for widgets with a background (as in, a background above the canvas background).
The background fill style. Used for widgets with a background (as in, a background above the canvas background).
The background glow fill style. Used for highlighting boxes which use backgroundFill.
The background glow fill style. Used for highlighting boxes which use backgroundFill.
The blink rate of text cursors in text input widgets like TextInput. Value in "blinks" per second.
The blink rate of text cursors in text input widgets like TextInput. Value in "blinks" per second.
The default text alignment mode of body text (most regular text).
The default text alignment mode of body text (most regular text).
The fill style used for body text (most regular text).
The fill style used for body text (most regular text).
The font style used for body text (most regular text).
The font style used for body text (most regular text).
The height of each line of text in body text (most regular text). If null, it will be automatically detected.
The height of each line of text in body text (most regular text). If null, it will be automatically detected.
The spacing between each line of text in body text (most regular text). If null, it will be automatically detected.
The spacing between each line of text in body text (most regular text). If null, it will be automatically detected.
The canvas background fill style.
The canvas background fill style.
This widget's child.
Get amount of children of this parent widget.
Get iterator for children of this parent widget. Cannot modify list of children via this iterator; for read-only purposes only.
Accessor for _constraints. Will also update the constraints of the Viewport, but may be different due to widthCoupling or heightCoupling.
The alignment in Container for when there is extra space.
The alignment in Container for when there is extra space.
The thickness of a text cursor in pixels.
The thickness of a text cursor in pixels.
Get the resolved dimensions. Returns a 2-tuple containing width and height.
Use idealDimensions for layout calculations.
Check if the widget is dirty. Returns _dirty, as long as dimensionless is not true.
Is this widget enabled? If it isn't, it will act as if it doesn't exist.
If getting, _enabled is returned.
Protected
fallbackThe fallback theme. If this theme has a missing property, the fallback theme's property will be used instead. This will automatically (un)subscribe to/from the fallback theme.
How much this widget will expand relative to other widgets in a flexbox container. If changed, sets _layoutDirty to true.
Is the height coupled to the child's? If not None, height constraints will be ignored or augmented.
Get the resolved ideal dimensions. Returns a 2-tuple containing idealWidth and idealHeight.
Use this for layout calculations, and dimensions for painting.
The inherited theme of this widget. Sets fallbackTheme.
The background fill style used for input widgets like TextInput.
The background fill style used for input widgets like TextInput.
The background fill style used for input widgets like TextInput when text is selected.
The background fill style used for input widgets like TextInput when text is selected.
The fill style used for text in input widgets like TextInput.
The fill style used for text in input widgets like TextInput.
The fill style used for text in input widgets like TextInput when disabled.
The fill style used for text in input widgets like TextInput when disabled.
The fill style used for text in input widgets like TextInput when invalid.
The fill style used for text in input widgets like TextInput when invalid.
The font style used for text in input widgets like TextInput.
The font style used for text in input widgets like TextInput.
The height of each line of text in input widgets like TextInput. If null, it will be automatically detected.
The height of each line of text in input widgets like TextInput. If null, it will be automatically detected.
The spacing between each line of text in input widgets like TextInput. If null, it will be automatically detected.
The spacing between each line of text in input widgets like TextInput. If null, it will be automatically detected.
Check if the widget's layout is dirty. Returns _layoutDirty.
The alignment in MultiContainer for when there is unused space.
The alignment in MultiContainer for when there is unused space.
The spacing length between widgets in MultiContainer.
The spacing length between widgets in MultiContainer.
Offset of child. Positional events will take this into account, as well as rendering. Unlike offset, this will clamp to possible scroll values to avoid issues.
Get the resolved position. Returns a 2-tuple containing x and y.
Use idealPosition for layout calculations.
The primary fill style. Usually a saturated colour used for filling boxes that need to stand out.
The primary fill style. Usually a saturated colour used for filling boxes that need to stand out.
Similar to checkboxInnerPadding, but for RadioButton.
Similar to checkboxInnerPadding, but for RadioButton.
Similar to checkboxLength, but for RadioButton.
Similar to checkboxLength, but for RadioButton.
The current scroll values. Similar to offset, but with normalised values (from 0 to 1).
The minimum length of the filled part of a ScrollableViewportWidget's scrollbar in percentage of total length.
The minimum length of the filled part of a ScrollableViewportWidget's scrollbar in percentage of total length.
The minimum length of the filled part of a ScrollableViewportWidget's scrollbar in pixels.
The minimum length of the filled part of a ScrollableViewportWidget's scrollbar in pixels.
The thickness of a ScrollableViewportWidget's scrollbar in pixels.
The thickness of a ScrollableViewportWidget's scrollbar in pixels.
The mode for how the scrollbar is shown.
Is the width coupled to the child's? If not None, width constraints will be ignored or augmented.
Protected
activateCalled after the Widget is attached to a UI tree, its parent is
active (or Root is enabled if this is the top
Widget), and the Widget itself is enabled; only called when all of the
previous conditions are fulfilled, not when one of the conditions is
fulfilled. Should be overridden for resource management, but
super.activate
must be called.
Must not be propagated to children by container Widgets. This is already done automatically by updateActiveState.
Marks dirty and layoutDirty as true.
Called when the Widget is attached to a UI tree. Should only be
overridden by container widgets to attach children or for resource
management, but super.attach
must still be called.
If the widget is already in a UI tree (already has a parent or is the root Widget, both checked via attached), then this method will throw an exception; a Widget cannot be in multiple UI trees.
The Root of the UI tree
The Viewport in this part of the UI tree. A UI tree can have multiple nested Viewports due to ViewportWidget
The new parent of this Widget. If null
, then this Widget has no parent and is the root Widget
Auto-scroll to this widget. Uses the whole widget as the auto-scroll bounds.
Private
clampProtected
clearPaiting utility: clears background of widget. Should not be overridden.
Rounds to nearest pixels; no subpixel clearing.
The background fill style used is canvasFill.
The fill style to use for clearing. If null (default), then the value of canvasFill is used
Protected
clearPaiting utility: end a clear operation (from clearStart). Should not be overridden.
The canvas fill rule for clipping. See the canvas clip documentation
Protected
clearPaiting utility: start a clear operation with no clipping path, the user has to add their own paths to the context. Should not be overridden.
The fill style to use for clearing. If null (default), then the value of canvasFill is used
Protected
deactivateCalled when the Widget is no longer active. Should be
overridden for resource management, but super.deactivate
must be
called.
Must not be propagated to children by container Widgets. This is already done automatically by updateActiveState.
Marks dirty and layoutDirty as true, and drops all foci set to this Widget if the Widget is attached.
Called when the Widget is detached from a UI tree. Should only be
overridden by container widgets to detach children or for resource
management, but super.detach
must still be called.
Sets _root, _viewport and _parent to null.
Drops all foci set to this Widget.
If the widget was not in a UI tree, then an exception is thrown.
Called when an event is passed to the Widget. Checks if the target matches the Widget, unless the Widget propagates events, or if the event is a PointerEvent and is in the bounds of the Widget. If neither of the conditions are true, the event is not captured (null is returned), else, the handleEvent method is called and its result is returned. Must not be overridden.
Returns the widget that captured the event or null if none captured the event.
Sets x, y, width and y from idealX, idealY, idealWidth and idealHeight by rounding them. If the final values have changed, _dirty is set to true.
Can be overridden, but super.finalizeBounds
must still be called; if
you have parts of the widget that can be pre-calculated when the layout
is known, such as the length and offset of a Checkbox, or
non-default dirty flags, such as backgroundDirty,
then this is the perfect method to override, since it's only called after
the layout is resolved to final (non-ideal) values, is only called if
needed (unlike postLayoutUpdate, which is always called after the
layout phase) and can be used to compare old and new positions and
dimensions.
Abstract container widgets such as Parent must always override
this and call finalizeBounds
on each child widget.
Force the widget to be fully re-painted and (by default) have layout resolved. For internal use only or for use by Parent widgets so that children get properly marked as dirty when added to a new container after reuse.
Should be overridden if the derived Widget has more dirty flags other
than the default ones (such as backgroundDirty),
but super.forceDirty
must be called.
Protected
getPrivate
getGet the ClickHelper of a scrollbar
Private
getGet the rectangles (filled and background) of a scrollbar
Returns a 2-tuple with 2 4-tuples. The first one is the scrollbar fill rectangle and the second one is the background fill rectangle. Each rectangle 4-tuple contains, respectively, horizontal offset, vertical offset, width and height
Protected
handleWidget event handling callback. If the event is to be captured, the capturer is returned, else, null.
By default, this will do nothing and capture the event if it is targetted at itself.
If overriding, return the widget that has captured the event (could be
this
, for example, or a child widget if implementing a container), or
null if no widget captured the event. Make sure to not capture any events
that you do not need, or you may have unexpected results; for example, if
you capture all dispatched events indiscriminately, a TabSelect
event may be captured and result in weird behaviour when the user
attempts to use tab to select another widget.
Private
handleProtected
handleWidget painting callback. By default does nothing. Do painting logic here when extending Widget. Even if _dirty is false, if this method is called, then the widget must still be painted. Should be overridden.
Was this widget force-painted? If calling a child's paint method, propagate this value
Protected
handleProtected
handleProtected
handleResolve the dimensions of the viewport widget, taking coupling modes and reserved space into account. Note that if space is reserved, then the resulting idealWidth and idealHeight will not include the reserved space. Child classes are expected to add the reserved space to the final dimensions themselves so that they can also be aware of the final non-reserved space.
Private
handleHandle a wheel scroll event. If scrolling fails due to being at the limit, this returns true if the last scroll attempt happened less than 200 milliseconds ago. This behaviour is disabled if fromDrag is true.
Returns true if this changed scroll was successful
Protected
onCalled when the fallback theme changes. Does nothing by default.
The property name of the theme property that was updated. If a general theme update, then this will be null and all theme properties should be treated as changed.
Called when the Widget is dirty and the Root is being rendered. Does nothing if dirty flag is not set, else, clears the background if needsClear is true, calls the handlePainting method and unsets the dirty flag. Automatically calls dryPaint if dimensionless is true. Must not be overridden.
Force re-paint even if _dirty is false
Protected
paintPainting utility: paints a circle. Should not be overridden. Coordinates are relative to the center of the circle. Uses ctx's current fillStyle. Does not restore the context state after finishing.
Private
paintGeneric update method which is called after layout is resolved. Calls handlePostLayoutUpdate if widget is enabled. Must not be overridden.
Generic update method which is called before layout is resolved. Calls handlePreLayoutUpdate if widget is enabled. Must not be overridden.
Wrapper for handleResolveDimensions. Does nothing if _enabled is false. If the resolved dimensions change, _dirty is set to true. _layoutDirty is set to false. If the widget is not loose and the layout has non-infinite max constraints, then the widget is stretched to fit max constraints. Must not be overridden.
Like resolveDimensions but for widgets at the top of the widget tree (the child of the Root). This retries dimension resolving if there is at least one unconstrained axis so that flex layout works even in infinite layout.
Set the ideal position of this widget (idealX and idealY). Does not set any flags of the widget.
Can be overridden, but super.resolvePosition
must always be called, and
the arguments must be preserved. Container widgets should override this
method such that resolvePosition
is called for each child of the
container.
Private
scrollbarUpdate the active state of the Widget. If the active state
changes from false
to true
, then activate is called.
If the active state changes from true
to false
, then
deactivate is called.
Container Widgets must override this so that the active state of each
child is updated, but super.updateActiveState
must still be called.
Each child's active state must only be updated if the container's active
state changed; this is indicated by the return value of this method.
Returns true if the active state changed.
Protected
updateGenerated using TypeDoc
A wrapper for a ViewportWidget with scrollbars.
Can be constrained to a specific type of children.