use super::Easing;
use std::time::Duration;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum AnimationType {
#[default]
Fade,
Scale,
Slide,
Bounce,
Rotate,
Blink,
None,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum AnimationDirection {
#[default]
Up,
Down,
Left,
Right,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AnimationState {
Running,
Completed,
}
#[derive(Debug, Clone)]
pub struct WindowAnimation {
pub animation_type: AnimationType,
pub duration: Duration,
pub easing: Easing,
pub direction: AnimationDirection,
}
impl Default for WindowAnimation {
fn default() -> Self {
Self {
animation_type: AnimationType::Fade,
duration: Duration::from_millis(200),
easing: Easing::EaseOut,
direction: AnimationDirection::Up,
}
}
}
impl WindowAnimation {
pub fn fade(duration: Duration) -> Self {
Self { animation_type: AnimationType::Fade, duration, ..Default::default() }
}
pub fn scale(duration: Duration) -> Self {
Self { animation_type: AnimationType::Scale, duration, ..Default::default() }
}
pub fn slide(direction: AnimationDirection, duration: Duration) -> Self {
Self { animation_type: AnimationType::Slide, duration, direction, ..Default::default() }
}
pub fn bounce(duration: Duration) -> Self {
Self {
animation_type: AnimationType::Bounce,
duration,
easing: Easing::Bounce,
..Default::default()
}
}
pub fn with_easing(mut self, easing: Easing) -> Self {
self.easing = easing;
self
}
}