use crate::rendering::composition::expressions::ExpressionVariant;
use crate::rendering::composition::server::{CompositionProperty, IServerClockItem, ServerCompositor, ServerObjectId};
use std::rc::Rc;
use std::time::Duration;
pub trait IAnimationInstance: IServerClockItem + 'static {
fn target_object(&self) -> ServerObjectId;
fn resolve(&self, _compositor: &Rc<ServerCompositor>) {}
fn evaluate(&self, now: Duration, current_value: ExpressionVariant) -> ExpressionVariant;
fn initialize(&self, started_at: Duration, starting_value: ExpressionVariant, property: &'static CompositionProperty);
fn activate(&self);
fn deactivate(&self);
fn invalidate(&self);
}
pub struct AnimationInstanceFactory(Box<dyn FnOnce() -> Rc<dyn IAnimationInstance> + Send>);
impl AnimationInstanceFactory {
pub fn new(create: impl FnOnce() -> Rc<dyn IAnimationInstance> + Send + 'static) -> Self {
Self(Box::new(create))
}
pub fn create(self) -> Rc<dyn IAnimationInstance> {
(self.0)()
}
}