flo_animation/traits/animation.rs
1use super::edit::*;
2use super::layer::*;
3use super::editable::*;
4
5use std::time::Duration;
6
7///
8/// Represents an animation
9///
10pub trait Animation :
11 Send+Sync {
12 ///
13 /// Retrieves the frame size of this animation
14 ///
15 fn size(&self) -> (f64, f64);
16
17 ///
18 /// Retrieves the length of this animation
19 ///
20 fn duration(&self) -> Duration;
21
22 ///
23 /// Retrieves the duration of a single frame
24 ///
25 fn frame_length(&self) -> Duration;
26
27 ///
28 /// Retrieves the IDs of the layers in this object
29 ///
30 fn get_layer_ids(&self) -> Vec<u64>;
31
32 ///
33 /// Retrieves the layer with the specified ID from this animation
34 ///
35 fn get_layer_with_id<'a>(&'a self, layer_id: u64) -> Option<Reader<'a, Layer>>;
36
37 ///
38 /// Retrieves the log for this animation
39 ///
40 fn get_log<'a>(&'a self) -> Reader<'a, EditLog<AnimationEdit>>;
41
42 ///
43 /// Retrieves an edit log that can be used to alter this animation
44 ///
45 fn edit<'a>(&'a self) -> Editor<'a, PendingEditLog<AnimationEdit>>;
46
47 ///
48 /// Retrieves an edit log that can be used to edit a layer in this animation
49 ///
50 fn edit_layer<'a>(&'a self, layer_id: u64) -> Editor<'a, PendingEditLog<LayerEdit>>;
51}
52
53///
54/// Trait implemented by objects that support editing the data associated with an animation
55///
56/// Normally edits are made by sending them via the `edit()` method in
57/// `Animation`. This used to edit the actual data structure associated
58/// with an animation.
59///
60pub trait MutableAnimation :
61 Send {
62 ///
63 /// Sets the canvas size of this animation
64 ///
65 fn set_size(&mut self, size: (f64, f64));
66
67 ///
68 /// Creates a new layer with a particular ID
69 ///
70 /// Has no effect if the layer ID is already in use
71 ///
72 fn add_layer(&mut self, new_layer_id: u64);
73
74 ///
75 /// Removes the layer with the specified ID
76 ///
77 fn remove_layer(&mut self, old_layer_id: u64);
78
79 ///
80 /// Opens a particular layer for editing
81 ///
82 fn edit_layer<'a>(&'a mut self, layer_id: u64) -> Option<Editor<'a, Layer>>;
83}