Skip to main content

ScrollGeometry

Struct ScrollGeometry 

Source
pub struct ScrollGeometry {
    pub rect: Rect,
    pub content: Size,
    pub offset: Vec2,
    pub max_offset: Vec2,
}
Expand description

What the last layout resolved for a scroll container: where the container landed, how big its content came out, and the offset it clamped. All logical px, in the same viewport coordinates on_layout reports.

This is the geometry a view needs to build only the rows that can be seen — it is read during the next frame’s build, so it describes the frame before. See Core::scroll_geometry for what that costs and widgets::uniform_list for the uniform-row case done for you.

The four numbers describe one moment, which is what makes arithmetic on them safe: offset is always within max_offset, even immediately after a set_scroll wrote something wilder (the documented “a huge value jumps to the end” would otherwise hand a view an index a million rows past its data).

Fields§

§rect: Rect

The container’s own box, as the last layout placed and sized it — the same rect an on_layout on that node would have reported.

§content: Size

Its laid-out content, padding included. Bigger than rect on an axis exactly when that axis has somewhere left to scroll.

§offset: Vec2

Where the container is scrolled to (positive = content moved up / left): the retained offset clamped to max_offset, which is what the next layout will resolve it to unless the content changes size in the same frame. Core::scroll_offset is the unclamped retained number.

§max_offset: Vec2

How far offset can travel on each axis — zero on an axis that does not scroll, or whose content fits. offset == max_offset is “at the end”, which is how a log view asks whether it is still tailing.

Implementations§

Source§

impl ScrollGeometry

Source

pub fn to_value(&self) -> Value

{x, y, w, h, content_w, content_h, offset: {x, y}, max_offset: {x, y}} — the box’s rect flattened, its content’s size beside it.

Trait Implementations§

Source§

impl Clone for ScrollGeometry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ScrollGeometry

Source§

impl Debug for ScrollGeometry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ScrollGeometry

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ScrollGeometry

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.