Use clamped animations where it makes sense
Browse files at this commit5383a0591f22b9640a570e299a73706eb4a27ffcParent: 0c686094 changed files +8 -8
- src/layout/closing_window.rs +2 -2
- src/layout/tile.rs +1 -1
- src/layout/workspace.rs +4 -2
- src/ui/config_error_notification.rs +1 -3
src/layout/closing_window.rsmodified+2 -2
| @@ -125,7 +125,7 @@ impl ClosingWindow { | |||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | pub fn are_animations_ongoing(&self) -> bool { | 127 | pub fn are_animations_ongoing(&self) -> bool { |
| 128 | - !self.anim.is_done() | 128 | + !self.anim.is_clamped_done() |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | pub fn render( | 131 | pub fn render( |
| @@ -134,7 +134,7 @@ impl ClosingWindow { | |||
| 134 | scale: Scale<f64>, | 134 | scale: Scale<f64>, |
| 135 | target: RenderTarget, | 135 | target: RenderTarget, |
| 136 | ) -> ClosingWindowRenderElement { | 136 | ) -> ClosingWindowRenderElement { |
| 137 | - let val = self.anim.value(); | 137 | + let val = self.anim.clamped_value(); |
| 138 | 138 | ||
| 139 | let block_out = match self.block_out_from { | 139 | let block_out = match self.block_out_from { |
| 140 | None => false, | 140 | None => false, |
src/layout/tile.rsmodified+1 -1
| @@ -387,7 +387,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 387 | renderer, | 387 | renderer, |
| 388 | scale.x as i32, | 388 | scale.x as i32, |
| 389 | &elements, | 389 | &elements, |
| 390 | - anim.value().clamp(0., 1.) as f32, | 390 | + anim.clamped_value().clamp(0., 1.) as f32, |
| 391 | ); | 391 | ); |
| 392 | self.window() | 392 | self.window() |
| 393 | .set_offscreen_element_id(Some(elem.id().clone())); | 393 | .set_offscreen_element_id(Some(elem.id().clone())); |
src/layout/workspace.rsmodified+4 -2
| @@ -956,8 +956,10 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 956 | 956 | ||
| 957 | // FIXME: this is a bit cursed since it's relying on Tile's internal details. | 957 | // FIXME: this is a bit cursed since it's relying on Tile's internal details. |
| 958 | let (starting_alpha, starting_scale) = if let Some(anim) = tile.open_animation() { | 958 | let (starting_alpha, starting_scale) = if let Some(anim) = tile.open_animation() { |
| 959 | - let val = anim.value(); | 959 | + ( |
| 960 | - (val.clamp(0., 1.) as f32, (val / 2. + 0.5).max(0.)) | 960 | + anim.clamped_value().clamp(0., 1.) as f32, |
| 961 | + (anim.value() / 2. + 0.5).max(0.), | ||
| 962 | + ) | ||
| 961 | } else { | 963 | } else { |
| 962 | (1., 1.) | 964 | (1., 1.) |
| 963 | }; | 965 | }; |
src/ui/config_error_notification.rsmodified+1 -3
| @@ -119,9 +119,7 @@ impl ConfigErrorNotification { | |||
| 119 | } | 119 | } |
| 120 | State::Hiding(anim) => { | 120 | State::Hiding(anim) => { |
| 121 | anim.set_current_time(target_presentation_time); | 121 | anim.set_current_time(target_presentation_time); |
| 122 | - // HACK: prevent bounciness on hiding. This is better done with a clamp property on | 122 | + if anim.is_clamped_done() { |
| 123 | - // the spring animation. | ||
| 124 | - if anim.is_done() || anim.value() <= 0. { | ||
| 125 | self.state = State::Hidden; | 123 | self.state = State::Hidden; |
| 126 | } | 124 | } |
| 127 | } | 125 | } |