pub struct RowHeights { /* private fields */ }Expand description
The heights a list slices by: a measured number per row
where one is known, an estimate everywhere else, and the prefix sums over
both.
The app owns it and hands the same one back every frame — a widget
composed from primitives keeps no state of its own, which is what keeps
it reachable from a scripting frontend. Rebuild it (or Self::clear)
when the rows themselves change.
Implementations§
Source§impl RowHeights
impl RowHeights
Sourcepub fn new(rows: usize, estimate: f32) -> Self
pub fn new(rows: usize, estimate: f32) -> Self
rows rows, none measured, each standing at estimate logical px
until it is. The estimate only has to be the right order of
magnitude: it decides how wrong the scrollbar is before the list has
been scrolled through, and nothing else.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn set_len(&mut self, rows: usize)
pub fn set_len(&mut self, rows: usize)
Grows or shrinks to rows, keeping what is still in range — rows
appended to a log keep every height already measured, and cost
nothing until something asks about them. A list whose rows changed
rather than grew wants Self::clear.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Forgets every measurement, keeping the length and the seed — the call for a list whose contents changed under the same indices.
Sourcepub fn set(&mut self, i: usize, h: f32)
pub fn set(&mut self, i: usize, h: f32)
Records row i’s height. Rows measured this way are what the
estimate for the others is the mean of.
Sourcepub fn measured(&self, i: usize) -> Option<f32>
pub fn measured(&self, i: usize) -> Option<f32>
Row i’s height as it was measured, or None for one standing at
the estimate.
Sourcepub fn estimate(&self) -> f32
pub fn estimate(&self) -> f32
What an unmeasured row stands at: the mean of the measured ones, or the caller’s seed before there are any.
Sourcepub fn set_width(&mut self, w: f32) -> bool
pub fn set_width(&mut self, w: f32) -> bool
Declares the content width the next measurements are for. A width
that differs from the cached one drops every height — the rows wrap
differently now — and returns true. list calls this from
the container’s own laid-out box.
Sourcepub fn offset_of(&mut self, i: usize) -> f32
pub fn offset_of(&mut self, i: usize) -> f32
The top of row i in content coordinates — the height of everything
above it. offset_of(len()) is the whole list’s height.
Source§impl RowHeights
impl RowHeights
Sourcepub fn slice(&mut self, reading: ListReading) -> ListSlice
pub fn slice(&mut self, reading: ListReading) -> ListSlice
Starts a frame’s slicing from reading: the content width (a new one
drops every height, since the rows rewrap), the anchors, and the
first range.