Skip to main content

waft_material/generated/
motion_defaults_m3.rs

1//! Port of material_ui's `generated/motion_defaults_m3.g.dart`: a Dart `part` of `motion.dart`, so its items are public through `motion.rs`.
2//!
3//! Generated from the Material token database upstream; port changes to the Dart generator's output by hand.
4
5use std::rc::Rc;
6use std::time::Duration;
7
8use waft_animation::{Cubic, Curve, Curves};
9
10/// The set of durations in the Material specification.
11///
12/// See also:
13///
14/// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
15/// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
16pub enum Durations {}
17
18impl Durations {
19    /// The short1 duration (50ms) in the Material specification.
20    ///
21    /// See also:
22    ///
23    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
24    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
25    pub const SHORT1: Duration = Duration::from_millis(50);
26
27    /// The short2 duration (100ms) in the Material specification.
28    ///
29    /// See also:
30    ///
31    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
32    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
33    pub const SHORT2: Duration = Duration::from_millis(100);
34
35    /// The short3 duration (150ms) in the Material specification.
36    ///
37    /// See also:
38    ///
39    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
40    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
41    pub const SHORT3: Duration = Duration::from_millis(150);
42
43    /// The short4 duration (200ms) in the Material specification.
44    ///
45    /// See also:
46    ///
47    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
48    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
49    pub const SHORT4: Duration = Duration::from_millis(200);
50
51    /// The medium1 duration (250ms) in the Material specification.
52    ///
53    /// See also:
54    ///
55    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
56    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
57    pub const MEDIUM1: Duration = Duration::from_millis(250);
58
59    /// The medium2 duration (300ms) in the Material specification.
60    ///
61    /// See also:
62    ///
63    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
64    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
65    pub const MEDIUM2: Duration = Duration::from_millis(300);
66
67    /// The medium3 duration (350ms) in the Material specification.
68    ///
69    /// See also:
70    ///
71    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
72    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
73    pub const MEDIUM3: Duration = Duration::from_millis(350);
74
75    /// The medium4 duration (400ms) in the Material specification.
76    ///
77    /// See also:
78    ///
79    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
80    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
81    pub const MEDIUM4: Duration = Duration::from_millis(400);
82
83    /// The long1 duration (450ms) in the Material specification.
84    ///
85    /// See also:
86    ///
87    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
88    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
89    pub const LONG1: Duration = Duration::from_millis(450);
90
91    /// The long2 duration (500ms) in the Material specification.
92    ///
93    /// See also:
94    ///
95    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
96    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
97    pub const LONG2: Duration = Duration::from_millis(500);
98
99    /// The long3 duration (550ms) in the Material specification.
100    ///
101    /// See also:
102    ///
103    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
104    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
105    pub const LONG3: Duration = Duration::from_millis(550);
106
107    /// The long4 duration (600ms) in the Material specification.
108    ///
109    /// See also:
110    ///
111    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
112    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
113    pub const LONG4: Duration = Duration::from_millis(600);
114
115    /// The extralong1 duration (700ms) in the Material specification.
116    ///
117    /// See also:
118    ///
119    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
120    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
121    pub const EXTRALONG1: Duration = Duration::from_millis(700);
122
123    /// The extralong2 duration (800ms) in the Material specification.
124    ///
125    /// See also:
126    ///
127    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
128    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
129    pub const EXTRALONG2: Duration = Duration::from_millis(800);
130
131    /// The extralong3 duration (900ms) in the Material specification.
132    ///
133    /// See also:
134    ///
135    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
136    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
137    pub const EXTRALONG3: Duration = Duration::from_millis(900);
138
139    /// The extralong4 duration (1000ms) in the Material specification.
140    ///
141    /// See also:
142    ///
143    /// * [M3 guidelines: Duration tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#c009dec6-f29b-4503-b9f0-482af14a8bbd)
144    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
145    pub const EXTRALONG4: Duration = Duration::from_millis(1000);
146}
147
148/// The set of easing curves in the Material specification.
149///
150/// See also:
151///
152/// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
153/// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
154/// * `Curves`, for a collection of non-Material animation easing curves.
155pub enum Easing {}
156
157macro_rules! easing_curves {
158    ($( $(#[$doc:meta])* $name:ident = $value:expr; )*) => {
159        impl Easing {
160            $(
161                $(#[$doc])*
162                pub fn $name() -> Rc<dyn Curve> {
163                    thread_local! {
164                        static CURVE: Rc<dyn Curve> = Rc::new($value);
165                    }
166                    CURVE.with(Rc::clone)
167                }
168            )*
169        }
170    };
171}
172
173easing_curves! {
174    /// The emphasizedAccelerate easing curve in the Material specification.
175    ///
176    /// See also:
177    ///
178    /// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
179    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
180    emphasized_accelerate = Cubic::new(0.3, 0.0, 0.8, 0.15);
181
182    /// The emphasizedDecelerate easing curve in the Material specification.
183    ///
184    /// See also:
185    ///
186    /// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
187    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
188    emphasized_decelerate = Cubic::new(0.05, 0.7, 0.1, 1.0);
189
190    /// The linear easing curve in the Material specification.
191    ///
192    /// See also:
193    ///
194    /// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
195    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
196    linear = Cubic::new(0.0, 0.0, 1.0, 1.0);
197
198    /// The standard easing curve in the Material specification.
199    ///
200    /// See also:
201    ///
202    /// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
203    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
204    standard = Cubic::new(0.2, 0.0, 0.0, 1.0);
205
206    /// The standardAccelerate easing curve in the Material specification.
207    ///
208    /// See also:
209    ///
210    /// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
211    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
212    standard_accelerate = Cubic::new(0.3, 0.0, 1.0, 1.0);
213
214    /// The standardDecelerate easing curve in the Material specification.
215    ///
216    /// See also:
217    ///
218    /// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
219    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
220    standard_decelerate = Cubic::new(0.0, 0.0, 0.0, 1.0);
221
222    /// The legacyDecelerate easing curve in the Material specification.
223    ///
224    /// See also:
225    ///
226    /// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
227    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
228    legacy_decelerate = Cubic::new(0.0, 0.0, 0.2, 1.0);
229
230    /// The legacyAccelerate easing curve in the Material specification.
231    ///
232    /// See also:
233    ///
234    /// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
235    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
236    legacy_accelerate = Cubic::new(0.4, 0.0, 1.0, 1.0);
237}
238
239impl Easing {
240    /// The legacy easing curve in the Material specification.
241    ///
242    /// Dart's `Cubic(0.4, 0.0, 0.2, 1.0)` is the same constant as `Curves.fastOutSlowIn`, so
243    /// this hands out that curve.
244    ///
245    /// See also:
246    ///
247    /// * [M3 guidelines: Easing tokens](https://m3.material.io/styles/motion/easing-and-duration/tokens-specs#433b1153-2ea3-4fe2-9748-803a47bc97ee)
248    /// * [M3 guidelines: Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration)
249    pub fn legacy() -> Rc<dyn Curve> {
250        Curves::fast_out_slow_in()
251    }
252}