forge
Explore
Log in

Don't you dare go Hollow

Animate movement and resize on window closing in a column

Browse files at this commit

c163e581672cd16829dce54a0793d5f09be9cc59Ivan MolodetskikhParent: a9094b4
src/layout/workspace.rsmodified+22 -4
@@ -840,7 +840,7 @@ impl<W: LayoutElement> Workspace<W> {
840 }840 }
841 841
842 column.active_tile_idx = min(column.active_tile_idx, column.tiles.len() - 1);842 column.active_tile_idx = min(column.active_tile_idx, column.tiles.len() - 1);
843- column.update_tile_sizes(false);843+ column.update_tile_sizes(true);
844 844
845 window845 window
846 }846 }
@@ -1022,14 +1022,22 @@ impl<W: LayoutElement> Workspace<W> {
1022 return;1022 return;
1023 };1023 };
1024 1024
1025- let col_idx = self1025+ let (col_idx, tile_idx) = self
1026 .columns1026 .columns
1027 .iter()1027 .iter()
1028- .position(|col| col.contains(window))1028+ .enumerate()
1029+ .find_map(|(col_idx, col)| {
1030+ col.tiles
1031+ .iter()
1032+ .position(|tile| tile.window().id() == window)
1033+ .map(|tile_idx| (col_idx, tile_idx))
1034+ })
1029 .unwrap();1035 .unwrap();
1030 1036
1031- let removing_last = self.columns[col_idx].tiles.len() == 1;1037+ let col = &self.columns[col_idx];
1038+ let removing_last = col.tiles.len() == 1;
1032 let offset = self.column_x(col_idx + 1) - self.column_x(col_idx);1039 let offset = self.column_x(col_idx + 1) - self.column_x(col_idx);
1040+ let offset_y = col.tile_y(tile_idx + 1) - col.tile_y(tile_idx);
1033 1041
1034 let mut center = Point::from((0, 0));1042 let mut center = Point::from((0, 0));
1035 center.x += tile.tile_size().w / 2;1043 center.x += tile.tile_size().w / 2;
@@ -1090,6 +1098,16 @@ impl<W: LayoutElement> Workspace<W> {
1090 }1098 }
1091 }1099 }
1092 }1100 }
1101+
1102+ // Also move other windows in a column.
1103+ let col = &mut self.columns[col_idx];
1104+ for tile in &mut col.tiles[tile_idx + 1..] {
1105+ tile.animate_move_from_with_config(
1106+ Point::from((0, offset_y)),
1107+ self.options.animations.window_resize,
1108+ niri_config::Animation::default_window_resize(),
1109+ );
1110+ }
1093 }1111 }
1094 1112
1095 pub fn prepare_for_resize_animation(&mut self, window: &W::Id) {1113 pub fn prepare_for_resize_animation(&mut self, window: &W::Id) {