pub struct SchedulerHandle { /* private fields */ }Expand description
A weak handle to the animation scheduler
This is passed to components that need to register animations. It won’t prevent the scheduler from being dropped.
Implementations§
Source§impl SchedulerHandle
impl SchedulerHandle
Sourcepub fn register_spring(&self, spring: Spring) -> Option<SpringId>
pub fn register_spring(&self, spring: Spring) -> Option<SpringId>
Register a spring and return its ID
Sourcepub fn set_spring_target(&self, id: SpringId, target: f32)
pub fn set_spring_target(&self, id: SpringId, target: f32)
Update a spring’s target
Sourcepub fn get_spring_value(&self, id: SpringId) -> Option<f32>
pub fn get_spring_value(&self, id: SpringId) -> Option<f32>
Get current spring value
Sourcepub fn is_spring_settled(&self, id: SpringId) -> bool
pub fn is_spring_settled(&self, id: SpringId) -> bool
Check if a spring has settled (at rest at target)
Returns true if the spring exists and has settled, or if the spring
doesn’t exist (considered settled since there’s nothing animating).
Sourcepub fn remove_spring(&self, id: SpringId)
pub fn remove_spring(&self, id: SpringId)
Remove a spring
Sourcepub fn register_keyframe(
&self,
keyframe: KeyframeAnimation,
) -> Option<KeyframeId>
pub fn register_keyframe( &self, keyframe: KeyframeAnimation, ) -> Option<KeyframeId>
Register a keyframe animation and return its ID
Sourcepub fn get_keyframe_value(&self, id: KeyframeId) -> Option<f32>
pub fn get_keyframe_value(&self, id: KeyframeId) -> Option<f32>
Get current keyframe animation value
Sourcepub fn get_keyframe_progress(&self, id: KeyframeId) -> Option<f32>
pub fn get_keyframe_progress(&self, id: KeyframeId) -> Option<f32>
Get keyframe animation progress (0.0 to 1.0)
Sourcepub fn is_keyframe_playing(&self, id: KeyframeId) -> bool
pub fn is_keyframe_playing(&self, id: KeyframeId) -> bool
Check if keyframe animation is playing
Sourcepub fn start_keyframe(&self, id: KeyframeId)
pub fn start_keyframe(&self, id: KeyframeId)
Start a keyframe animation
Sourcepub fn stop_keyframe(&self, id: KeyframeId)
pub fn stop_keyframe(&self, id: KeyframeId)
Stop a keyframe animation
Sourcepub fn remove_keyframe(&self, id: KeyframeId)
pub fn remove_keyframe(&self, id: KeyframeId)
Remove a keyframe animation
Sourcepub fn register_timeline(&self, timeline: Timeline) -> Option<TimelineId>
pub fn register_timeline(&self, timeline: Timeline) -> Option<TimelineId>
Register a timeline and return its ID
Sourcepub fn is_timeline_playing(&self, id: TimelineId) -> bool
pub fn is_timeline_playing(&self, id: TimelineId) -> bool
Check if timeline is playing
Sourcepub fn start_timeline(&self, id: TimelineId)
pub fn start_timeline(&self, id: TimelineId)
Start a timeline
Sourcepub fn stop_timeline(&self, id: TimelineId)
pub fn stop_timeline(&self, id: TimelineId)
Stop a timeline
Sourcepub fn remove_timeline(&self, id: TimelineId)
pub fn remove_timeline(&self, id: TimelineId)
Remove a timeline
Sourcepub fn with_timeline<F, R>(&self, id: TimelineId, f: F) -> Option<R>
pub fn with_timeline<F, R>(&self, id: TimelineId, f: F) -> Option<R>
Access a timeline to add entries or get values
The closure receives a mutable reference to the timeline. Returns None if the scheduler is dropped or timeline doesn’t exist.
Sourcepub fn register_tick_callback<F>(&self, callback: F) -> Option<TickCallbackId>
pub fn register_tick_callback<F>(&self, callback: F) -> Option<TickCallbackId>
Register a tick callback that runs each frame
The callback receives delta time in seconds. Use this to integrate custom systems (like ECS) with the animation scheduler’s background thread.
Returns None if the scheduler has been dropped.
§Example
let world = Arc::new(Mutex::new(World::new()));
let world_clone = world.clone();
let id = handle.register_tick_callback(move |dt| {
let mut world = world_clone.lock().unwrap();
// Run ECS systems with delta time
world.run_systems(dt);
});Sourcepub fn remove_tick_callback(&self, id: TickCallbackId)
pub fn remove_tick_callback(&self, id: TickCallbackId)
Remove a tick callback
Trait Implementations§
Source§impl AnimationAccess for SchedulerHandle
Implement AnimationAccess for SchedulerHandle
impl AnimationAccess for SchedulerHandle
Implement AnimationAccess for SchedulerHandle
This allows the handle to be used with ValueContext for resolving dynamic animation values at render time.
Source§impl Clone for SchedulerHandle
impl Clone for SchedulerHandle
Source§fn clone(&self) -> SchedulerHandle
fn clone(&self) -> SchedulerHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SchedulerHandle
impl RefUnwindSafe for SchedulerHandle
impl Send for SchedulerHandle
impl Sync for SchedulerHandle
impl Unpin for SchedulerHandle
impl UnsafeUnpin for SchedulerHandle
impl UnwindSafe for SchedulerHandle
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>. 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.