Struct ScrollMomentum
pub struct ScrollMomentum { /* private fields */ }Expand description
Deterministic single-axis momentum used by virtualized collection widgets. Wheel input moves immediately; line-wheel impulses additionally feed this decay curve so detented wheels can traverse long collections without requiring one event per row.
Implementations§
§impl ScrollMomentum
impl ScrollMomentum
pub fn set_view(&mut self, extent: f64, scrolls: bool, motion: EffectiveMotion)
pub fn set_view(&mut self, extent: f64, scrolls: bool, motion: EffectiveMotion)
The view extent long the give past the ends is measured against,
whether the content scrolls along it (content that fits gives
nowhere), and the motion the person allows (reduced: no give).
pub fn give(&self, now: Instant) -> f64
pub fn give(&self, now: Instant) -> f64
How far past an end the content is drawn at now, in whole device
pixels: negative before the start.
pub fn give_needs_frame(&self, now: Instant) -> bool
pub fn give_needs_frame(&self, now: Instant) -> bool
Whether the give wants a frame: it springs back, or was drawn otherwise than it stands now.
pub fn new() -> ScrollMomentum
pub fn push(&mut self, delta: f64) -> f64
pub fn push(&mut self, delta: f64) -> f64
Add a logical-pixel wheel impulse. Return the immediate delta so the caller can apply it in the same input frame.
pub fn fling(&mut self, velocity: f64)
pub fn fling(&mut self, velocity: f64)
Continue from a content-space drag velocity after pointer release. The velocity is clamped to the same ceiling as accumulated wheel impulses, keeping a bad timestamp or synthetic pointer from launching the viewport an unbounded distance.
pub fn set_device_scale(&mut self, device_per_unit: f64)
pub fn set_device_scale(&mut self, device_per_unit: f64)
How many device pixels one logical pixel is on the display the owner draws to (its event context’s scale factor).
pub fn advance(&mut self, now: Instant) -> f64
pub fn advance(&mut self, now: Instant) -> f64
Advance the glide to now (the frame’s time) and return the
logical-pixel displacement since the last step or since it started,
in whole device pixels, carrying the rest to the next frame. A host
that copies what stays on screen (crate::scroll_copy) moves whole
pixels only: a glide in fractional steps would repaint its whole
viewport every frame, the frames that most need to be cheap.
pub fn advance_by(&mut self, elapsed: Duration) -> f64
pub fn advance_by(&mut self, elapsed: Duration) -> f64
Advance the glide by elapsed and return the logical-pixel
displacement, in whole device pixels like Self::advance: for a
driver that keeps its own frame clock.
pub fn rest_distance(&self) -> f64
pub fn rest_distance(&self) -> f64
How much further the glide moves before it rests, in logical
pixels, as Self::advance moves it: in whole device pixels, so
what was moved plus this is where it lands. 0 at rest.
pub fn stop(&mut self)
pub fn wheel(
&mut self,
delta: &MouseScrollDelta,
phase: TouchPhase,
reduce_motion: bool,
) -> WheelStep
pub fn wheel( &mut self, delta: &MouseScrollDelta, phase: TouchPhase, reduce_motion: bool, ) -> WheelStep
Classify one vertical wheel event. Line (detented) wheels accelerate
through Self::push; pixel (touchpad, touchscreen) deltas, in the
display’s pixels, track the finger exactly in logical pixels (set the
display’s scale first, Self::set_device_scale) and, when the
gesture’s Ended phase arrives
while still moving, continue as a fling. reduce_motion keeps every
movement 1:1 with the input.
pub fn wheel_applied(&mut self, delta: f64, moved: f64) -> bool
pub fn wheel_applied(&mut self, delta: f64, moved: f64) -> bool
Report how far the WheelStep::Scroll delta moved the content;
returns whether the view moved, the content or its give. What
fingers asked past an end pulls the content through the rubber band
(Self::set_view); a delta refused whole with no give (at an edge,
under reduced motion) stops momentum and forgets the gesture so an
outer scroll region can take it over, fling included.
pub fn is_active(&self) -> bool
Trait Implementations§
§impl Clone for ScrollMomentum
impl Clone for ScrollMomentum
§fn clone(&self) -> ScrollMomentum
fn clone(&self) -> ScrollMomentum
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ScrollMomentum
impl Debug for ScrollMomentum
§impl Default for ScrollMomentum
impl Default for ScrollMomentum
§fn default() -> ScrollMomentum
fn default() -> ScrollMomentum
Auto Trait Implementations§
impl !Freeze for ScrollMomentum
impl !RefUnwindSafe for ScrollMomentum
impl Send for ScrollMomentum
impl !Sync for ScrollMomentum
impl Unpin for ScrollMomentum
impl UnsafeUnpin for ScrollMomentum
impl UnwindSafe for ScrollMomentum
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§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.§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.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more