pub struct SliverGeometry {
pub scroll_extent: f64,
pub paint_extent: f64,
pub paint_origin: f64,
pub layout_extent: f64,
pub max_paint_extent: f64,
pub hit_test_extent: f64,
pub visible: bool,
pub has_visual_overflow: bool,
pub scroll_offset_correction: Option<f64>,
pub cache_extent: f64,
}Expand description
The sliver protocol a scrolling viewport lays its children out with —
a widget implements SliverWidget and overrides
Widget::as_sliver to answer SliverConstraints with a
SliverGeometry; a viewport lays such a child out through
ChildPod::layout_sliver_child. Lifted so an app’s own sliver needs no
direct frust-core dependency.
What a sliver reports back from layout: how far it scrolls, how much of
the viewport it painted, and where the next sliver starts — Flutter’s
SliverGeometry.
All extents are logical pixels along the constraints’ axis.
Fields§
§scroll_extent: f64The (estimated) total scrollable extent of the sliver’s content
(Flutter’s scrollExtent).
paint_extent: f64How much of the remaining paint extent the sliver painted — its visible
size along the axis (Flutter’s paintExtent).
paint_origin: f64Where the sliver’s first visible pixel sits relative to its layout
position, e.g. negative to paint over an earlier sliver (Flutter’s
paintOrigin).
layout_extent: f64The distance from this sliver’s first visible pixel to the next sliver’s
— usually paint_extent; less for a sliver the next one should overlap
(Flutter’s layoutExtent).
max_paint_extent: f64The (estimated) paint extent the sliver would provide given infinite
remaining paint extent (Flutter’s maxPaintExtent).
hit_test_extent: f64The distance from the paint start to the end of the region that accepts
hits — usually paint_extent (Flutter’s hitTestExtent).
visible: boolWhether the sliver should be painted at all — usually
paint_extent > 0 (Flutter’s visible).
has_visual_overflow: boolWhether the sliver painted outside its paint extent, so the viewport
must clip it (Flutter’s hasVisualOverflow).
scroll_offset_correction: Option<f64>A non-zero amount the viewport must adjust its scroll offset by before
re-running the whole layout, when the sliver found its earlier extent
estimate wrong (Flutter’s scrollOffsetCorrection).
cache_extent: f64How much of the remaining cache extent the sliver consumed — at least
layout_extent (Flutter’s cacheExtent).
Implementations§
Source§impl SliverGeometry
impl SliverGeometry
Sourcepub const ZERO: SliverGeometry
pub const ZERO: SliverGeometry
The geometry of an empty sliver: no extent of any kind and not visible
(Flutter’s SliverGeometry.zero).
Sourcepub fn new(
scroll_extent: f64,
paint_extent: f64,
max_paint_extent: f64,
) -> SliverGeometry
pub fn new( scroll_extent: f64, paint_extent: f64, max_paint_extent: f64, ) -> SliverGeometry
A geometry with Flutter’s constructor defaults for everything but the
three extents: layout_extent and hit_test_extent equal
paint_extent, cache_extent equals layout_extent, visible is
paint_extent > 0, and the rest is zero.
Sourcepub fn debug_assert_valid(&self, constraints: &SliverConstraints)
pub fn debug_assert_valid(&self, constraints: &SliverConstraints)
Debug-assert the geometry is well formed and fits constraints —
Flutter’s SliverGeometry.debugAssertIsValid plus the paint-extent
check of RenderSliver.debugAssertDoesMeetConstraints.
Checks that scroll_extent, paint_extent, layout_extent,
cache_extent and hit_test_extent are non-negative (NaN fails); that
layout_extent <= paint_extent, paint_extent <= max_paint_extent,
paint_extent <= constraints.remaining_paint_extent and
layout_extent <= cache_extent, each within
PRECISION_ERROR_TOLERANCE; and that a scroll_offset_correction is
finite and non-zero. Compiles to nothing without debug_assertions.
Trait Implementations§
Source§impl Clone for SliverGeometry
impl Clone for SliverGeometry
Source§fn clone(&self) -> SliverGeometry
fn clone(&self) -> SliverGeometry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SliverGeometry
Source§impl Debug for SliverGeometry
impl Debug for SliverGeometry
Source§impl PartialEq for SliverGeometry
impl PartialEq for SliverGeometry
impl StructuralPartialEq for SliverGeometry
Auto Trait Implementations§
impl Freeze for SliverGeometry
impl RefUnwindSafe for SliverGeometry
impl Send for SliverGeometry
impl Sync for SliverGeometry
impl Unpin for SliverGeometry
impl UnsafeUnpin for SliverGeometry
impl UnwindSafe for SliverGeometry
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.