Skip to main content

Module round_scroll_indicator

Module round_scroll_indicator 

Source
Expand description

The curved scroll indicator a round watch puts at 3 o’clock.

Every round-screen app needs this and none of it is guessable: the track is described by a height in dp rather than an angle, the thumb is a separate segment with a gap at each end rather than paint over a continuous rail, and a segment shorter than its own stroke turns into a shrinking, fading dot instead of a stubby arc.

The numbers and the arithmetic here were read out of androidx.wear.compose.material3 1.6.2 with javap -c and then checked against where the shipping Compose build actually puts pixels on 454x454 and 384x384 displays. The sources are named per item so the next person can re-derive them rather than trust this comment.

This module is deliberately pure geometry. It returns the segments to draw and takes no view of how they are drawn, so it costs nothing to a platform that never shows it and can be tested without a GPU.

Structs§

IndicatorArc
Where the track sits on a display of the given radius.
IndicatorGeometry
Where the thumb sits inside the track and how long it is, both as fractions of the whole track.
IndicatorItem
One row of a ScalingLazyColumn, as ScalingLazyListItemInfo reports it.
ScalingList
A scaling list as ScalingLazyColumnStateAdapter sees it. Device pixels.
ThumbLength
The thumb’s length, and the fact that Wear only measures it once.

Enums§

IndicatorPart
Which part of the indicator a segment belongs to, so a caller can colour the thumb and the track differently without re-deriving the order.
IndicatorSegment
One piece of the indicator, ready to draw.

Constants§

INDICATOR_EDGE_PADDING_DP
PaddingDefaults.edgePadding — how far the track’s outer edge stays off the display edge.
INDICATOR_GAP_DP
ScrollIndicatorDefaults.gapHeight — the blank left between the thumb and each end of the track.
INDICATOR_HEIGHT_DP
ScrollIndicatorDefaults.indicatorHeight — how far the track reaches up and down from 3 o’clock, as a straight-line height rather than an arc length.
INDICATOR_LARGE_SCREEN_DP
Wear’s own breakpoint: a display at least this wide gets the wider stroke.
INDICATOR_MAX_THUMB
INDICATOR_MIN_THUMB
ScrollIndicatorDefaults.minSizeFraction / maxSizeFraction — the thumb’s share of the track is clamped to this range however long the list is.
INDICATOR_NARROW_WIDTH_DP
INDICATOR_WIDTH_DP
ScrollIndicatorDefaults.indicatorWidth, whose two values are chosen by screen size.

Functions§

decimal_first_item_index
Where the first visible row sits, as a fractional item index.
decimal_last_item_index
Where the last visible row sits, as a fractional item index.
indicator_arc
Where the track’s centreline sits and how far it sweeps.
indicator_geometry
Works out the thumb for a list, or None when everything fits on screen and Wear shows nothing at all.
indicator_segments
The whole indicator as a list of drawable pieces: track, thumb, track.
indicator_width_dp
The stroke width Wear would use on a display this wide.
position_fraction
How far down the track the thumb’s leading edge sits, before the thumb’s own length is taken out of the travel. 0.0 at the top, 1.0 at the bottom.
scaling_list_geometry
The thumb for a ScalingLazyColumn, in the item-index space Wear uses.
scaling_list_items
The rows of a laid-out scaling list that are on screen, as the adapter reads them, for a list scaled by Wear’s own ramp.
scaling_list_items_with
scaling_list_items for a list whose ramp is not the default one.