From 73e9ef5fe20825ed12f1bb05ba10e7eb69bc7662 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 17 Apr 2024 14:06:32 +0400 Subject: Resolve animation defaults during parsing --- src/layout/monitor.rs | 6 ++---- src/layout/tile.rs | 20 ++++---------------- src/layout/workspace.rs | 36 +++++++++--------------------------- 3 files changed, 15 insertions(+), 47 deletions(-) (limited to 'src/layout') diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 7a19673e..604dcab3 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -127,8 +127,7 @@ impl Monitor { current_idx, idx as f64, 0., - self.options.animations.workspace_switch, - niri_config::Animation::default_workspace_switch(), + self.options.animations.workspace_switch.0, ))); } @@ -882,8 +881,7 @@ impl Monitor { gesture.current_idx, new_idx as f64, velocity, - self.options.animations.workspace_switch, - niri_config::Animation::default_workspace_switch(), + self.options.animations.workspace_switch.0, ))); true diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 87c168b0..16779c10 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -150,13 +150,7 @@ impl Tile { let change = self.window.size().to_point() - size_from.to_point(); let change = max(change.x.abs(), change.y.abs()); if change > RESIZE_ANIMATION_THRESHOLD { - let anim = Animation::new( - 0., - 1., - 0., - self.options.animations.window_resize, - niri_config::Animation::default_window_resize(), - ); + let anim = Animation::new(0., 1., 0., self.options.animations.window_resize.0); self.resize_animation = Some(ResizeAnimation { anim, size_from, @@ -230,8 +224,7 @@ impl Tile { 0., 1., 0., - self.options.animations.window_open, - niri_config::Animation::default_window_open(), + self.options.animations.window_open.0, )); } @@ -244,23 +237,18 @@ impl Tile { } pub fn animate_move_from(&mut self, from: Point) { - self.animate_move_from_with_config( - from, - self.options.animations.window_movement, - niri_config::Animation::default_window_movement(), - ); + self.animate_move_from_with_config(from, self.options.animations.window_movement.0); } pub fn animate_move_from_with_config( &mut self, from: Point, config: niri_config::Animation, - default: niri_config::Animation, ) { let current_offset = self.render_offset(); self.move_animation = Some(MoveAnimation { - anim: Animation::new(1., 0., 0., config, default), + anim: Animation::new(1., 0., 0., config), from: from + current_offset, }); } diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 271f6639..7474d650 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -525,8 +525,7 @@ impl Workspace { self.view_offset as f64, new_view_offset as f64, 0., - self.options.animations.horizontal_view_movement, - niri_config::Animation::default_horizontal_view_movement(), + self.options.animations.horizontal_view_movement.0, ))); } @@ -857,8 +856,7 @@ impl Workspace { for tile in &mut column.tiles[window_idx + 1..] { tile.animate_move_from_with_config( Point::from((0, offset_y)), - self.options.animations.window_resize, - niri_config::Animation::default_window_resize(), + self.options.animations.window_resize.0, ); } @@ -1034,16 +1032,14 @@ impl Workspace { for col in &mut self.columns[col_idx + 1..] { col.animate_move_from_with_config( offset, - self.options.animations.window_resize, - niri_config::Animation::default_window_resize(), + self.options.animations.window_resize.0, ); } } else { for col in &mut self.columns[..=col_idx] { col.animate_move_from_with_config( -offset, - self.options.animations.window_resize, - niri_config::Animation::default_window_resize(), + self.options.animations.window_resize.0, ); } } @@ -1074,10 +1070,7 @@ impl Workspace { // offset animation if the target was the same; maybe we shouldn't replace in this // case? if started_animation { - anim.replace_config( - self.options.animations.window_resize, - niri_config::Animation::default_window_resize(), - ); + anim.replace_config(self.options.animations.window_resize.0); } } } @@ -1149,13 +1142,7 @@ impl Workspace { (1., 1.) }; - let anim = Animation::new( - 1., - 0., - 0., - self.options.animations.window_close, - niri_config::Animation::default_window_close(), - ); + let anim = Animation::new(1., 0., 0., self.options.animations.window_close.0); let res = ClosingWindow::new( renderer, @@ -2021,8 +2008,7 @@ impl Workspace { current_view_offset + delta, target_view_offset as f64, velocity, - self.options.animations.horizontal_view_movement, - niri_config::Animation::default_horizontal_view_movement(), + self.options.animations.horizontal_view_movement.0, ))); // HACK: deal with things like snapping to the right edge of a larger-than-view window. @@ -2188,8 +2174,7 @@ impl Column { pub fn animate_move_from(&mut self, from_x_offset: i32) { self.animate_move_from_with_config( from_x_offset, - self.options.animations.window_movement, - niri_config::Animation::default_window_movement(), + self.options.animations.window_movement.0, ); } @@ -2197,7 +2182,6 @@ impl Column { &mut self, from_x_offset: i32, config: niri_config::Animation, - default: niri_config::Animation, ) { let current_offset = self.move_animation.as_ref().map_or(0., Animation::value); @@ -2206,7 +2190,6 @@ impl Column { 0., 0., config, - default, )); } @@ -2257,8 +2240,7 @@ impl Column { for tile in &mut self.tiles[tile_idx + 1..] { tile.animate_move_from_with_config( Point::from((0, offset)), - self.options.animations.window_resize, - niri_config::Animation::default_window_resize(), + self.options.animations.window_resize.0, ); } } -- cgit