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) -> RowHeights
pub fn new(rows: usize, estimate: f32) -> RowHeights
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.
Trait Implementations§
Source§impl Clone for RowHeights
impl Clone for RowHeights
Source§fn clone(&self) -> RowHeights
fn clone(&self) -> RowHeights
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RowHeights
impl RefUnwindSafe for RowHeights
impl Send for RowHeights
impl Sync for RowHeights
impl Unpin for RowHeights
impl UnsafeUnpin for RowHeights
impl UnwindSafe for RowHeights
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.