aboutsummaryrefslogtreecommitdiff
path: root/src/animation.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-02-07 16:32:38 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-02-07 16:32:38 +0400
commit753a90430abbdf166a86b95c5c69aa1e68b3c412 (patch)
tree78491ad15f528bb30b8a7755b6d7a45f1ad17270 /src/animation.rs
parentf9085db5648bc6bad7fb0abf45e2a11f2e03d1af (diff)
downloadniri-753a90430abbdf166a86b95c5c69aa1e68b3c412.tar.gz
niri-753a90430abbdf166a86b95c5c69aa1e68b3c412.tar.bz2
niri-753a90430abbdf166a86b95c5c69aa1e68b3c412.zip
animation: Accept ms as u32
Less boilerplate elsewhere.
Diffstat (limited to 'src/animation.rs')
-rw-r--r--src/animation.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/animation.rs b/src/animation.rs
index bf0536e2..404c3d85 100644
--- a/src/animation.rs
+++ b/src/animation.rs
@@ -25,15 +25,17 @@ pub enum Curve {
}
impl Animation {
- pub fn new(from: f64, to: f64, over: Duration) -> Self {
+ pub fn new(from: f64, to: f64, over_ms: u32) -> Self {
// FIXME: ideally we shouldn't use current time here because animations started within the
// same frame cycle should have the same start time to be synchronized.
let now = get_monotonic_time();
+ let duration = Duration::from_millis(u64::from(over_ms))
+ .mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed));
Self {
from,
to,
- duration: over.mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed)),
+ duration,
start_time: now,
current_time: now,
curve: Curve::EaseOutCubic,