pub struct Tween { /* private fields */ }Expand description
Smooth scalar tween between 0.0 and 1.0 (or any pair of values the
caller interprets). Drives animations such as the scroll-bar hover
expansion and toggle-switch on/off slide.
Implementations§
Source§impl Tween
impl Tween
Sourcepub const fn new(initial: f64, duration_secs: f64) -> Self
pub const fn new(initial: f64, duration_secs: f64) -> Self
New tween that starts at initial with the same value as its target
(no animation in flight).
Sourcepub fn set_target(&mut self, new_target: f64)
pub fn set_target(&mut self, new_target: f64)
Update the target. If it differs from the current target, re-anchors the animation at the current interpolated value so reversals are smooth.
Widgets that own a Tween must also report tween.is_animating() from
Widget::needs_draw() so retained parents repaint every frame until
the tween settles. Tween::tick is the draw-request point; set_target
intentionally does not invalidate because many widgets retarget from
paint while synchronizing with external state.
Sourcepub fn tick(&mut self) -> f64
pub fn tick(&mut self) -> f64
Advance the animation based on elapsed wall time and return the new
interpolated value. Ease-out cubic. While in flight this also calls
request_draw so the host keeps drawing frames until completion.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Whether the tween still needs frames to reach its target.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tween
impl RefUnwindSafe for Tween
impl Send for Tween
impl Sync for Tween
impl Unpin for Tween
impl UnsafeUnpin for Tween
impl UnwindSafe for Tween
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,
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>, which can then be
downcast into Box<dyn 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>, which 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.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().