Skip to main content

ferroui_base/animation/
key_frames.rs

1use crate::animation::KeyFrame;
2use crate::collections::{FerroList, ResetBehavior};
3use crate::Ref;
4use std::ops::Deref;
5
6/// A collection of [`KeyFrame`]s. Clearing it notifies a removal of every
7/// item.
8///
9/// The value is a shared handle: clones refer to the same collection, and
10/// handles compare by identity.
11#[derive(Clone, PartialEq, Debug)]
12pub struct KeyFrames(FerroList<Ref<KeyFrame>>);
13
14impl KeyFrames {
15    /// Creates an empty collection.
16    pub fn new() -> Self {
17        let list = FerroList::new();
18        list.set_reset_behavior(ResetBehavior::Remove);
19        Self(list)
20    }
21
22    /// Creates a collection holding `items`.
23    pub fn from_items(items: impl IntoIterator<Item = Ref<KeyFrame>>) -> Self {
24        let list = FerroList::from_items(items);
25        list.set_reset_behavior(ResetBehavior::Remove);
26        Self(list)
27    }
28}
29
30impl Default for KeyFrames {
31    fn default() -> Self {
32        Self::new()
33    }
34}
35
36impl Deref for KeyFrames {
37    type Target = FerroList<Ref<KeyFrame>>;
38
39    fn deref(&self) -> &Self::Target {
40        &self.0
41    }
42}