mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
animation: Accept ms as u32
Less boilerplate elsewhere.
This commit is contained in:
+4
-2
@@ -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,
|
||||
|
||||
@@ -58,7 +58,7 @@ impl ConfigErrorNotification {
|
||||
self.buffers.borrow_mut().clear();
|
||||
}
|
||||
|
||||
self.state = State::Showing(Animation::new(0., 1., Duration::from_millis(250)));
|
||||
self.state = State::Showing(Animation::new(0., 1., 250));
|
||||
}
|
||||
|
||||
pub fn show(&mut self) {
|
||||
@@ -68,7 +68,7 @@ impl ConfigErrorNotification {
|
||||
}
|
||||
|
||||
// Show from scratch even if already showing to bring attention.
|
||||
self.state = State::Showing(Animation::new(0., 1., Duration::from_millis(250)));
|
||||
self.state = State::Showing(Animation::new(0., 1., 250));
|
||||
}
|
||||
|
||||
pub fn hide(&mut self) {
|
||||
@@ -76,7 +76,7 @@ impl ConfigErrorNotification {
|
||||
return;
|
||||
}
|
||||
|
||||
self.state = State::Hiding(Animation::new(1., 0., Duration::from_millis(250)));
|
||||
self.state = State::Hiding(Animation::new(1., 0., 250));
|
||||
}
|
||||
|
||||
pub fn advance_animations(&mut self, target_presentation_time: Duration) {
|
||||
|
||||
+1
-1
@@ -1577,7 +1577,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
monitor.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
|
||||
current_idx,
|
||||
idx as f64,
|
||||
Duration::from_millis(250),
|
||||
250,
|
||||
)));
|
||||
|
||||
return Some(monitor.output.clone());
|
||||
|
||||
@@ -96,7 +96,7 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
|
||||
current_idx,
|
||||
idx as f64,
|
||||
Duration::from_millis(250),
|
||||
250,
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -114,8 +114,7 @@ impl<W: LayoutElement> Tile<W> {
|
||||
}
|
||||
|
||||
pub fn start_open_animation(&mut self) {
|
||||
self.open_animation =
|
||||
Some(Animation::new(0., 1., Duration::from_millis(150)).with_curve(Curve::EaseOutExpo));
|
||||
self.open_animation = Some(Animation::new(0., 1., 150).with_curve(Curve::EaseOutExpo));
|
||||
}
|
||||
|
||||
pub fn window(&self) -> &W {
|
||||
|
||||
@@ -401,7 +401,7 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
self.view_offset_anim = Some(Animation::new(
|
||||
self.view_offset as f64,
|
||||
new_view_offset as f64,
|
||||
Duration::from_millis(250),
|
||||
250,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user