forge
Explore
Log in

Don't you dare go Hollow

animation: Accept ms as u32

Browse files at this commit

753a90430abbdf166a86b95c5c69aa1e68b3c412Ivan MolodetskikhParent: f9085db
Less boilerplate elsewhere.
src/animation.rsmodified+4 -2
@@ -25,15 +25,17 @@ pub enum Curve {
25 }25 }
26 26
27 impl Animation {27 impl Animation {
28- pub fn new(from: f64, to: f64, over: Duration) -> Self {28+ pub fn new(from: f64, to: f64, over_ms: u32) -> Self {
29 // FIXME: ideally we shouldn't use current time here because animations started within the29 // FIXME: ideally we shouldn't use current time here because animations started within the
30 // same frame cycle should have the same start time to be synchronized.30 // same frame cycle should have the same start time to be synchronized.
31 let now = get_monotonic_time();31 let now = get_monotonic_time();
32 32
33+ let duration = Duration::from_millis(u64::from(over_ms))
34+ .mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed));
33 Self {35 Self {
34 from,36 from,
35 to,37 to,
36- duration: over.mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed)),38+ duration,
37 start_time: now,39 start_time: now,
38 current_time: now,40 current_time: now,
39 curve: Curve::EaseOutCubic,41 curve: Curve::EaseOutCubic,
src/config_error_notification.rsmodified+3 -3
@@ -58,7 +58,7 @@ impl ConfigErrorNotification {
58 self.buffers.borrow_mut().clear();58 self.buffers.borrow_mut().clear();
59 }59 }
60 60
61- self.state = State::Showing(Animation::new(0., 1., Duration::from_millis(250)));61+ self.state = State::Showing(Animation::new(0., 1., 250));
62 }62 }
63 63
64 pub fn show(&mut self) {64 pub fn show(&mut self) {
@@ -68,7 +68,7 @@ impl ConfigErrorNotification {
68 }68 }
69 69
70 // Show from scratch even if already showing to bring attention.70 // Show from scratch even if already showing to bring attention.
71- self.state = State::Showing(Animation::new(0., 1., Duration::from_millis(250)));71+ self.state = State::Showing(Animation::new(0., 1., 250));
72 }72 }
73 73
74 pub fn hide(&mut self) {74 pub fn hide(&mut self) {
@@ -76,7 +76,7 @@ impl ConfigErrorNotification {
76 return;76 return;
77 }77 }
78 78
79- self.state = State::Hiding(Animation::new(1., 0., Duration::from_millis(250)));79+ self.state = State::Hiding(Animation::new(1., 0., 250));
80 }80 }
81 81
82 pub fn advance_animations(&mut self, target_presentation_time: Duration) {82 pub fn advance_animations(&mut self, target_presentation_time: Duration) {
src/layout/mod.rsmodified+1 -1
@@ -1577,7 +1577,7 @@ impl<W: LayoutElement> Layout<W> {
1577 monitor.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(1577 monitor.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
1578 current_idx,1578 current_idx,
1579 idx as f64,1579 idx as f64,
1580- Duration::from_millis(250),1580+ 250,
1581 )));1581 )));
1582 1582
1583 return Some(monitor.output.clone());1583 return Some(monitor.output.clone());
src/layout/monitor.rsmodified+1 -1
@@ -96,7 +96,7 @@ impl<W: LayoutElement> Monitor<W> {
96 self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(96 self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
97 current_idx,97 current_idx,
98 idx as f64,98 idx as f64,
99- Duration::from_millis(250),99+ 250,
100 )));100 )));
101 }101 }
102 102
src/layout/tile.rsmodified+1 -2
@@ -114,8 +114,7 @@ impl<W: LayoutElement> Tile<W> {
114 }114 }
115 115
116 pub fn start_open_animation(&mut self) {116 pub fn start_open_animation(&mut self) {
117- self.open_animation =117+ self.open_animation = Some(Animation::new(0., 1., 150).with_curve(Curve::EaseOutExpo));
118- Some(Animation::new(0., 1., Duration::from_millis(150)).with_curve(Curve::EaseOutExpo));
119 }118 }
120 119
121 pub fn window(&self) -> &W {120 pub fn window(&self) -> &W {
src/layout/workspace.rsmodified+1 -1
@@ -401,7 +401,7 @@ impl<W: LayoutElement> Workspace<W> {
401 self.view_offset_anim = Some(Animation::new(401 self.view_offset_anim = Some(Animation::new(
402 self.view_offset as f64,402 self.view_offset as f64,
403 new_view_offset as f64,403 new_view_offset as f64,
404- Duration::from_millis(250),404+ 250,
405 ));405 ));
406 }406 }
407 407