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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use std::collections::{HashMap, VecDeque};
use super::{Easing, Action, AnimationError};
use yoga::StyleUnit;
#[derive(Clone, Debug)]
pub struct TaskProperties {
pub started: HashMap<String, StyleUnit>,
pub worked: HashMap<String, StyleUnit>,
}
#[derive(Clone, Debug)]
pub struct Task {
pub properties: TaskProperties,
pub queue: VecDeque<Action>,
pub finished: bool,
}
#[derive(Clone, Debug)]
pub struct SingleTask {
pub easing: Easing,
pub finished: bool,
pub duration: u32,
pub elapsed: u32,
pub target: f32,
pub start: f32,
}
impl Task {
pub fn run(&mut self, delta_time: f32) -> Result<bool, AnimationError> {
let mut pop_action = false;
if let Some(task) = self.queue.front_mut() {
if let Ok(status) = task.next(&mut self.properties, delta_time) {
pop_action = status;
}
} else {
self.finished = true;
return Ok(true);
}
if pop_action {
let finished = self.queue.pop_front().is_none();
self.finished = finished;
Ok(finished)
} else {
Ok(false)
}
}
}
impl SingleTask {
pub fn run(&mut self, delta_time: f32) -> Result<bool, AnimationError> {
Ok(true)
}
}