mod effects;
mod xml_gen;
pub use effects::{AnimationEffect, AnimationTrigger, EmphasisType, EntranceType, ExitType};
use crate::units::{DurationMs, ShapeId};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SlideAnimation {
pub target_shape_id: ShapeId,
pub effect: AnimationEffect,
pub trigger: AnimationTrigger,
pub duration_ms: DurationMs,
pub delay_ms: DurationMs,
}
impl SlideAnimation {
#[must_use]
pub const fn new(target_shape_id: ShapeId, effect: AnimationEffect) -> Self {
Self {
target_shape_id,
effect,
trigger: AnimationTrigger::OnClick,
duration_ms: DurationMs(500),
delay_ms: DurationMs(0),
}
}
#[must_use]
pub const fn with_trigger(mut self, trigger: AnimationTrigger) -> Self {
self.trigger = trigger;
self
}
#[must_use]
pub const fn with_duration(mut self, ms: DurationMs) -> Self {
self.duration_ms = ms;
self
}
#[must_use]
pub const fn with_delay(mut self, ms: DurationMs) -> Self {
self.delay_ms = ms;
self
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AnimationSequence {
pub(crate) animations: Vec<SlideAnimation>,
}
impl AnimationSequence {
#[must_use]
pub const fn new() -> Self {
Self {
animations: Vec::new(),
}
}
pub fn add(&mut self, animation: SlideAnimation) {
self.animations.push(animation);
}
#[must_use]
pub fn len(&self) -> usize {
self.animations.len()
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.animations.is_empty()
}
}
impl Default for AnimationSequence {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests;