pub struct Progress { /* private fields */ }Expand description
A 0-to-1 progress value for widget state (hover, press, focus, toggle), animated by the runtime.
Start a transition with Progress::animate and read the value for the
frame being painted with Progress::get. The runtime repaints the widget
until the transition ends, so the widget needs no animation-frame
handling. Transitions follow the app’s MotionPolicy and keep momentum
when retargeted.
Implementations§
Source§impl Progress
impl Progress
pub const EPSILON: f32 = 1e-4
pub const fn new(value: f32) -> Self
Sourcepub const fn movement(self) -> Self
pub const fn movement(self) -> Self
Mark this as movement (a sliding indicator, for example): reduced motion finishes it immediately.
Sourcepub const fn invalidating(self, kind: InvalidationKind) -> Self
pub const fn invalidating(self, kind: InvalidationKind) -> Self
Invalidate kind instead of paint while animating, such as
Transform or Effect for progress read in layer properties.
Sourcepub fn get(&self, clock: &impl FrameClock) -> f32
pub fn get(&self, clock: &impl FrameClock) -> f32
The value at the time of the frame clock is producing.
pub fn target(&self) -> f32
pub fn is_animating(&self, clock: &impl FrameClock) -> bool
Sourcepub fn is_presented(&self, clock: &impl FrameClock) -> bool
pub fn is_presented(&self, clock: &impl FrameClock) -> bool
Whether anything shows at clock’s frame: the value is above zero,
heading above zero, or still animating.
Sourcepub fn animate(
&mut self,
target: f32,
spec: AnimationSpec,
ctx: &mut impl AnimateCtx,
) -> bool
pub fn animate( &mut self, target: f32, spec: AnimationSpec, ctx: &mut impl AnimateCtx, ) -> bool
Animate toward target (clamped to 0..=1) with spec. Returns
whether a transition started.
Sourcepub fn animate_after(
&mut self,
target: f32,
delay: f64,
spec: AnimationSpec,
ctx: &mut impl AnimateCtx,
) -> bool
pub fn animate_after( &mut self, target: f32, delay: f64, spec: AnimationSpec, ctx: &mut impl AnimateCtx, ) -> bool
Like Progress::animate, starting delay seconds from now.