pub struct Motion<T> { /* private fields */ }Expand description
A value the runtime animates for a widget.
Start a transition with ctx.animate(&mut motion, target, spec) and read
the value while painting with motion.get(ctx). The runtime invalidates the
widget every frame until the transition ends, so the widget needs no
animation-frame handling of its own. The value is a function of time, so
reading it at a frame’s time gives what is on screen then.
Transitions follow the MotionPolicy; retargeting mid-flight keeps
momentum (see MotionValue).
Implementations§
Source§impl<T> Motion<T>where
T: Copy,
impl<T> Motion<T>where
T: Copy,
pub const fn new(value: T) -> Motion<T>
Sourcepub const fn invalidating(self, kind: InvalidationKind) -> Motion<T>
pub const fn invalidating(self, kind: InvalidationKind) -> Motion<T>
What the runtime invalidates each frame while this animates: Paint
(the default) for values read while painting, Transform or Effect
for layer properties, Measure for sizes.
Sourcepub const fn movement(self) -> Motion<T>
pub const fn movement(self) -> Motion<T>
Mark this as movement, such as a sliding indicator: reduced motion finishes it immediately instead of animating it.
pub const fn invalidation(&self) -> InvalidationKind
pub const fn is_movement(&self) -> bool
Source§impl<T> Motion<T>
impl<T> Motion<T>
Sourcepub fn get(&self, clock: &impl FrameClock) -> T
pub fn get(&self, clock: &impl FrameClock) -> T
The value at the time of the frame clock is producing.
Sourcepub fn is_animating(&self, clock: &impl FrameClock) -> bool
pub fn is_animating(&self, clock: &impl FrameClock) -> bool
Whether a transition is running at the time of clock’s frame.
Sourcepub fn start(
&mut self,
target: T,
time: f64,
spec: AnimationSpec,
) -> Option<f64>
pub fn start( &mut self, target: T, time: f64, spec: AnimationSpec, ) -> Option<f64>
Start toward target at time with spec under the motion policy.
Returns when the transition ends if one started. Contexts’ animate
methods call this and keep the widget invalidated until then.
Sourcepub fn start_after(
&mut self,
target: T,
time: f64,
delay: f64,
spec: AnimationSpec,
) -> Option<f64>
pub fn start_after( &mut self, target: T, time: f64, delay: f64, spec: AnimationSpec, ) -> Option<f64>
Like Motion::start, delay seconds after time. The delay
follows the policy’s time scale, and is skipped when the policy makes
the transition instant.
Trait Implementations§
impl<T> Copy for Motion<T>where
T: Copy,
impl<T> StructuralPartialEq for Motion<T>where
T: PartialEq,
Auto Trait Implementations§
impl<T> Forget for Motion<T>
impl<T> Freeze for Motion<T>where
MotionValue<T>: Freeze,
impl<T> Move for Motion<T>
impl<T> RefUnwindSafe for Motion<T>where
MotionValue<T>: RefUnwindSafe,
impl<T> Send for Motion<T>where
MotionValue<T>: Send,
impl<T> Sync for Motion<T>where
MotionValue<T>: Sync,
impl<T> Unpin for Motion<T>where
MotionValue<T>: Unpin,
impl<T> UnsafeUnpin for Motion<T>where
MotionValue<T>: UnsafeUnpin,
impl<T> UnwindSafe for Motion<T>where
MotionValue<T>: UnwindSafe,
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.