forge
Explore
Log in

Don't you dare go Hollow

layout: Accept anim_config in remove_column_by_idx

Browse files at this commit

4b837f429c525d37785b17a29fec7d137cd7a1feIvan MolodetskikhParent: a480087
src/layout/mod.rsmodified+1 -1
@@ -2176,7 +2176,7 @@ impl<W: LayoutElement> Layout<W> {
2176 if !ws.has_windows() {2176 if !ws.has_windows() {
2177 return;2177 return;
2178 }2178 }
2179- let column = ws.remove_column_by_idx(ws.active_column_idx);2179+ let column = ws.remove_column_by_idx(ws.active_column_idx, None);
2180 2180
2181 let workspace_idx = monitors[new_idx].active_workspace_idx;2181 let workspace_idx = monitors[new_idx].active_workspace_idx;
2182 self.add_column_by_idx(new_idx, workspace_idx, column, true);2182 self.add_column_by_idx(new_idx, workspace_idx, column, true);
src/layout/monitor.rsmodified+3 -3
@@ -570,7 +570,7 @@ impl<W: LayoutElement> Monitor<W> {
570 return;570 return;
571 }571 }
572 572
573- let column = workspace.remove_column_by_idx(workspace.active_column_idx);573+ let column = workspace.remove_column_by_idx(workspace.active_column_idx, None);
574 self.add_column(new_idx, column, true);574 self.add_column(new_idx, column, true);
575 }575 }
576 576
@@ -587,7 +587,7 @@ impl<W: LayoutElement> Monitor<W> {
587 return;587 return;
588 }588 }
589 589
590- let column = workspace.remove_column_by_idx(workspace.active_column_idx);590+ let column = workspace.remove_column_by_idx(workspace.active_column_idx, None);
591 self.add_column(new_idx, column, true);591 self.add_column(new_idx, column, true);
592 }592 }
593 593
@@ -604,7 +604,7 @@ impl<W: LayoutElement> Monitor<W> {
604 return;604 return;
605 }605 }
606 606
607- let column = workspace.remove_column_by_idx(workspace.active_column_idx);607+ let column = workspace.remove_column_by_idx(workspace.active_column_idx, None);
608 self.add_column(new_idx, column, true);608 self.add_column(new_idx, column, true);
609 }609 }
610 610
src/layout/workspace.rsmodified+27 -7
@@ -1254,16 +1254,21 @@ impl<W: LayoutElement> Workspace<W> {
1254 tile1254 tile
1255 }1255 }
1256 1256
1257- pub fn remove_column_by_idx(&mut self, column_idx: usize) -> Column<W> {1257+ pub fn remove_column_by_idx(
1258+ &mut self,
1259+ column_idx: usize,
1260+ anim_config: Option<niri_config::Animation>,
1261+ ) -> Column<W> {
1258 // Animate movement of the other columns.1262 // Animate movement of the other columns.
1263+ let movement_config = anim_config.unwrap_or(self.options.animations.window_movement.0);
1259 let offset = self.column_x(column_idx + 1) - self.column_x(column_idx);1264 let offset = self.column_x(column_idx + 1) - self.column_x(column_idx);
1260 if self.active_column_idx <= column_idx {1265 if self.active_column_idx <= column_idx {
1261 for col in &mut self.columns[column_idx + 1..] {1266 for col in &mut self.columns[column_idx + 1..] {
1262- col.animate_move_from(offset);1267+ col.animate_move_from_with_config(offset, movement_config);
1263 }1268 }
1264 } else {1269 } else {
1265 for col in &mut self.columns[..column_idx] {1270 for col in &mut self.columns[..column_idx] {
1266- col.animate_move_from(-offset);1271+ col.animate_move_from_with_config(-offset, movement_config);
1267 }1272 }
1268 }1273 }
1269 1274
@@ -1301,6 +1306,8 @@ impl<W: LayoutElement> Workspace<W> {
1301 return column;1306 return column;
1302 }1307 }
1303 1308
1309+ let view_config = anim_config.unwrap_or(self.options.animations.horizontal_view_movement.0);
1310+
1304 if column_idx < self.active_column_idx {1311 if column_idx < self.active_column_idx {
1305 // A column to the left was removed; preserve the current position.1312 // A column to the left was removed; preserve the current position.
1306 // FIXME: preserve activate_prev_column_on_removal.1313 // FIXME: preserve activate_prev_column_on_removal.
@@ -1313,16 +1320,29 @@ impl<W: LayoutElement> Workspace<W> {
1313 if 0 < column_idx {1320 if 0 < column_idx {
1314 let prev_offset = self.activate_prev_column_on_removal.unwrap();1321 let prev_offset = self.activate_prev_column_on_removal.unwrap();
1315 1322
1316- self.activate_column(self.active_column_idx - 1);1323+ self.activate_column_with_anim_config(self.active_column_idx - 1, view_config);
1317 1324
1318 // Restore the view offset but make sure to scroll the view in case the1325 // Restore the view offset but make sure to scroll the view in case the
1319 // previous window had resized.1326 // previous window had resized.
1320 let current_x = self.view_pos();1327 let current_x = self.view_pos();
1321- self.animate_view_offset(current_x, self.active_column_idx, prev_offset);1328+ self.animate_view_offset_with_config(
1322- self.animate_view_offset_to_column(current_x, self.active_column_idx, None);1329+ current_x,
1330+ self.active_column_idx,
1331+ prev_offset,
1332+ view_config,
1333+ );
1334+ self.animate_view_offset_to_column_with_config(
1335+ current_x,
1336+ self.active_column_idx,
1337+ None,
1338+ view_config,
1339+ );
1323 }1340 }
1324 } else {1341 } else {
1325- self.activate_column(min(self.active_column_idx, self.columns.len() - 1));1342+ self.activate_column_with_anim_config(
1343+ min(self.active_column_idx, self.columns.len() - 1),
1344+ view_config,
1345+ );
1326 }1346 }
1327 1347
1328 column1348 column