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> {
21762176 if !ws.has_windows() {
21772177 return;
21782178 }
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);
21802180
21812181 let workspace_idx = monitors[new_idx].active_workspace_idx;
21822182 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> {
570570 return;
571571 }
572572
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);
574574 self.add_column(new_idx, column, true);
575575 }
576576
@@ -587,7 +587,7 @@ impl<W: LayoutElement> Monitor<W> {
587587 return;
588588 }
589589
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);
591591 self.add_column(new_idx, column, true);
592592 }
593593
@@ -604,7 +604,7 @@ impl<W: LayoutElement> Monitor<W> {
604604 return;
605605 }
606606
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);
608608 self.add_column(new_idx, column, true);
609609 }
610610
src/layout/workspace.rsmodified+27 -7
@@ -1254,16 +1254,21 @@ impl<W: LayoutElement> Workspace<W> {
12541254 tile
12551255 }
12561256
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> {
12581262 // Animate movement of the other columns.
1263+ let movement_config = anim_config.unwrap_or(self.options.animations.window_movement.0);
12591264 let offset = self.column_x(column_idx + 1) - self.column_x(column_idx);
12601265 if self.active_column_idx <= column_idx {
12611266 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);
12631268 }
12641269 } else {
12651270 for col in &mut self.columns[..column_idx] {
1266- col.animate_move_from(-offset);
1271+ col.animate_move_from_with_config(-offset, movement_config);
12671272 }
12681273 }
12691274
@@ -1301,6 +1306,8 @@ impl<W: LayoutElement> Workspace<W> {
13011306 return column;
13021307 }
13031308
1309+ let view_config = anim_config.unwrap_or(self.options.animations.horizontal_view_movement.0);
1310+
13041311 if column_idx < self.active_column_idx {
13051312 // A column to the left was removed; preserve the current position.
13061313 // FIXME: preserve activate_prev_column_on_removal.
@@ -1313,16 +1320,29 @@ impl<W: LayoutElement> Workspace<W> {
13131320 if 0 < column_idx {
13141321 let prev_offset = self.activate_prev_column_on_removal.unwrap();
13151322
1316- self.activate_column(self.active_column_idx - 1);
1323+ self.activate_column_with_anim_config(self.active_column_idx - 1, view_config);
13171324
13181325 // Restore the view offset but make sure to scroll the view in case the
13191326 // previous window had resized.
13201327 let current_x = self.view_pos();
1321- self.animate_view_offset(current_x, self.active_column_idx, prev_offset);
1322- self.animate_view_offset_to_column(current_x, self.active_column_idx, None);
1328+ self.animate_view_offset_with_config(
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+ );
13231340 }
13241341 } 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+ );
13261346 }
13271347
13281348 column