1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use vizia_id::{
    impl_generational_id, GenerationalId, GENERATIONAL_ID_GENERATION_MASK,
    GENERATIONAL_ID_INDEX_BITS, GENERATIONAL_ID_INDEX_MASK,
};

use crate::context::EventContext;

/// An ID used to reference style animations stored in the style store.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct Animation(u64);

impl_generational_id!(Animation);

pub trait AnimId {
    fn get(&self, cx: &EventContext) -> Option<Animation>;
}

impl AnimId for Animation {
    fn get(&self, _cx: &EventContext) -> Option<Animation> {
        Some(*self)
    }
}

impl AnimId for &'static str {
    fn get(&self, cx: &EventContext) -> Option<Animation> {
        cx.style.get_animation(self).copied()
    }
}