diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-04-15 21:19:09 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-04-15 21:19:09 +0400 |
| commit | 69f723d68aa28698488618e00688ef3a84e40819 (patch) | |
| tree | 3f7983e9257c87297dd699c84ac2077fefff386f /src/layout/workspace.rs | |
| parent | 568fbe26fe58be7de34e46ddb980a26d12e85ac6 (diff) | |
| download | niri-69f723d68aa28698488618e00688ef3a84e40819.tar.gz niri-69f723d68aa28698488618e00688ef3a84e40819.tar.bz2 niri-69f723d68aa28698488618e00688ef3a84e40819.zip | |
Implement vertical window move animations
Diffstat (limited to 'src/layout/workspace.rs')
| -rw-r--r-- | src/layout/workspace.rs | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 39e377b5..186b3d22 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -2250,9 +2250,19 @@ impl<W: LayoutElement> Column<W> { return; } + let mut ys = self.tile_ys().skip(self.active_tile_idx); + let active_y = ys.next().unwrap(); + let next_y = ys.next().unwrap(); + drop(ys); + self.tiles.swap(self.active_tile_idx, new_idx); self.heights.swap(self.active_tile_idx, new_idx); self.active_tile_idx = new_idx; + + // Animate the movement. + let new_active_y = self.tile_y(new_idx); + self.tiles[new_idx].animate_move_from(Point::from((0, active_y - new_active_y))); + self.tiles[new_idx + 1].animate_move_from(Point::from((0, active_y - next_y))); } fn move_down(&mut self) { @@ -2261,9 +2271,19 @@ impl<W: LayoutElement> Column<W> { return; } + let mut ys = self.tile_ys().skip(self.active_tile_idx); + let active_y = ys.next().unwrap(); + let next_y = ys.next().unwrap(); + drop(ys); + self.tiles.swap(self.active_tile_idx, new_idx); self.heights.swap(self.active_tile_idx, new_idx); self.active_tile_idx = new_idx; + + // Animate the movement. + let new_active_y = self.tile_y(new_idx); + self.tiles[new_idx].animate_move_from(Point::from((0, active_y - new_active_y))); + self.tiles[new_idx - 1].animate_move_from(Point::from((0, next_y - active_y))); } #[cfg(test)] @@ -2431,9 +2451,13 @@ impl<W: LayoutElement> Column<W> { y = self.working_area.loc.y + self.options.gaps; } - self.tiles.iter().map(move |tile| { + let heights = self.tiles.iter().map(|tile| tile.tile_size().h); + + // Chain an arbitrary height to be able to get the Y that the next tile past the end would + // have. + heights.chain(iter::once(0)).map(move |h| { let pos = y; - y += tile.tile_size().h + self.options.gaps; + y += h + self.options.gaps; pos }) } |
