Synchronize column removal anim on consume left/right
Browse files at this commit568c35ff876f126bb66ec7d7fb59a62424e6f8b5Parent: c4f600b3 changed files +49 -18
- src/layout/mod.rs +1 -1
- src/layout/monitor.rs +3 -3
- src/layout/workspace.rs +45 -14
src/layout/mod.rsmodified+1 -1
| @@ -1427,7 +1427,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1427 | let width = column.width; | 1427 | let width = column.width; |
| 1428 | let is_full_width = column.is_full_width; | 1428 | let is_full_width = column.is_full_width; |
| 1429 | let window = ws | 1429 | let window = ws |
| 1430 | - .remove_tile_by_idx(ws.active_column_idx, column.active_tile_idx) | 1430 | + .remove_tile_by_idx(ws.active_column_idx, column.active_tile_idx, None) |
| 1431 | .into_window(); | 1431 | .into_window(); |
| 1432 | 1432 | ||
| 1433 | let workspace_idx = monitors[new_idx].active_workspace_idx; | 1433 | let workspace_idx = monitors[new_idx].active_workspace_idx; |
src/layout/monitor.rsmodified+3 -3
| @@ -346,7 +346,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 346 | let width = column.width; | 346 | let width = column.width; |
| 347 | let is_full_width = column.is_full_width; | 347 | let is_full_width = column.is_full_width; |
| 348 | let window = workspace | 348 | let window = workspace |
| 349 | - .remove_tile_by_idx(workspace.active_column_idx, column.active_tile_idx) | 349 | + .remove_tile_by_idx(workspace.active_column_idx, column.active_tile_idx, None) |
| 350 | .into_window(); | 350 | .into_window(); |
| 351 | 351 | ||
| 352 | self.add_window(new_idx, window, true, width, is_full_width); | 352 | self.add_window(new_idx, window, true, width, is_full_width); |
| @@ -369,7 +369,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 369 | let width = column.width; | 369 | let width = column.width; |
| 370 | let is_full_width = column.is_full_width; | 370 | let is_full_width = column.is_full_width; |
| 371 | let window = workspace | 371 | let window = workspace |
| 372 | - .remove_tile_by_idx(workspace.active_column_idx, column.active_tile_idx) | 372 | + .remove_tile_by_idx(workspace.active_column_idx, column.active_tile_idx, None) |
| 373 | .into_window(); | 373 | .into_window(); |
| 374 | 374 | ||
| 375 | self.add_window(new_idx, window, true, width, is_full_width); | 375 | self.add_window(new_idx, window, true, width, is_full_width); |
| @@ -392,7 +392,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 392 | let width = column.width; | 392 | let width = column.width; |
| 393 | let is_full_width = column.is_full_width; | 393 | let is_full_width = column.is_full_width; |
| 394 | let window = workspace | 394 | let window = workspace |
| 395 | - .remove_tile_by_idx(workspace.active_column_idx, column.active_tile_idx) | 395 | + .remove_tile_by_idx(workspace.active_column_idx, column.active_tile_idx, None) |
| 396 | .into_window(); | 396 | .into_window(); |
| 397 | 397 | ||
| 398 | self.add_window(new_idx, window, true, width, is_full_width); | 398 | self.add_window(new_idx, window, true, width, is_full_width); |
src/layout/workspace.rsmodified+45 -14
| @@ -912,7 +912,12 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 912 | } | 912 | } |
| 913 | } | 913 | } |
| 914 | 914 | ||
| 915 | - pub fn remove_tile_by_idx(&mut self, column_idx: usize, window_idx: usize) -> Tile<W> { | 915 | + pub fn remove_tile_by_idx( |
| 916 | + &mut self, | ||
| 917 | + column_idx: usize, | ||
| 918 | + window_idx: usize, | ||
| 919 | + anim_config: Option<niri_config::Animation>, | ||
| 920 | + ) -> Tile<W> { | ||
| 916 | let offset = self.column_x(column_idx + 1) - self.column_x(column_idx); | 921 | let offset = self.column_x(column_idx + 1) - self.column_x(column_idx); |
| 917 | 922 | ||
| 918 | let column = &mut self.columns[column_idx]; | 923 | let column = &mut self.columns[column_idx]; |
| @@ -942,13 +947,14 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 942 | } | 947 | } |
| 943 | 948 | ||
| 944 | // Animate movement of the other columns. | 949 | // Animate movement of the other columns. |
| 950 | + let movement_config = anim_config.unwrap_or(self.options.animations.window_movement.0); | ||
| 945 | if self.active_column_idx <= column_idx { | 951 | if self.active_column_idx <= column_idx { |
| 946 | for col in &mut self.columns[column_idx + 1..] { | 952 | for col in &mut self.columns[column_idx + 1..] { |
| 947 | - col.animate_move_from(offset); | 953 | + col.animate_move_from_with_config(offset, movement_config); |
| 948 | } | 954 | } |
| 949 | } else { | 955 | } else { |
| 950 | for col in &mut self.columns[..column_idx] { | 956 | for col in &mut self.columns[..column_idx] { |
| 951 | - col.animate_move_from(-offset); | 957 | + col.animate_move_from_with_config(-offset, movement_config); |
| 952 | } | 958 | } |
| 953 | } | 959 | } |
| 954 | 960 | ||
| @@ -957,6 +963,9 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 957 | return tile; | 963 | return tile; |
| 958 | } | 964 | } |
| 959 | 965 | ||
| 966 | + let view_config = | ||
| 967 | + anim_config.unwrap_or(self.options.animations.horizontal_view_movement.0); | ||
| 968 | + | ||
| 960 | if column_idx < self.active_column_idx { | 969 | if column_idx < self.active_column_idx { |
| 961 | // A column to the left was removed; preserve the current position. | 970 | // A column to the left was removed; preserve the current position. |
| 962 | // FIXME: preserve activate_prev_column_on_removal. | 971 | // FIXME: preserve activate_prev_column_on_removal. |
| @@ -969,16 +978,29 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 969 | if 0 < column_idx { | 978 | if 0 < column_idx { |
| 970 | let prev_offset = self.activate_prev_column_on_removal.unwrap(); | 979 | let prev_offset = self.activate_prev_column_on_removal.unwrap(); |
| 971 | 980 | ||
| 972 | - self.activate_column(self.active_column_idx - 1); | 981 | + self.activate_column_with_anim_config(self.active_column_idx - 1, view_config); |
| 973 | 982 | ||
| 974 | // Restore the view offset but make sure to scroll the view in case the | 983 | // Restore the view offset but make sure to scroll the view in case the |
| 975 | // previous window had resized. | 984 | // previous window had resized. |
| 976 | let current_x = self.view_pos(); | 985 | let current_x = self.view_pos(); |
| 977 | - self.animate_view_offset(current_x, self.active_column_idx, prev_offset); | 986 | + self.animate_view_offset_with_config( |
| 978 | - self.animate_view_offset_to_column(current_x, self.active_column_idx, None); | 987 | + current_x, |
| 988 | + self.active_column_idx, | ||
| 989 | + prev_offset, | ||
| 990 | + view_config, | ||
| 991 | + ); | ||
| 992 | + self.animate_view_offset_to_column_with_config( | ||
| 993 | + current_x, | ||
| 994 | + self.active_column_idx, | ||
| 995 | + None, | ||
| 996 | + view_config, | ||
| 997 | + ); | ||
| 979 | } | 998 | } |
| 980 | } else { | 999 | } else { |
| 981 | - self.activate_column(min(self.active_column_idx, self.columns.len() - 1)); | 1000 | + self.activate_column_with_anim_config( |
| 1001 | + min(self.active_column_idx, self.columns.len() - 1), | ||
| 1002 | + view_config, | ||
| 1003 | + ); | ||
| 982 | } | 1004 | } |
| 983 | 1005 | ||
| 984 | return tile; | 1006 | return tile; |
| @@ -1061,7 +1083,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1061 | let column = &self.columns[column_idx]; | 1083 | let column = &self.columns[column_idx]; |
| 1062 | 1084 | ||
| 1063 | let window_idx = column.position(window).unwrap(); | 1085 | let window_idx = column.position(window).unwrap(); |
| 1064 | - self.remove_tile_by_idx(column_idx, window_idx) | 1086 | + self.remove_tile_by_idx(column_idx, window_idx, None) |
| 1065 | .into_window() | 1087 | .into_window() |
| 1066 | } | 1088 | } |
| 1067 | 1089 | ||
| @@ -1404,7 +1426,11 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1404 | // Make sure the previous (target) column is activated so the animation looks right. | 1426 | // Make sure the previous (target) column is activated so the animation looks right. |
| 1405 | self.activate_prev_column_on_removal = Some(self.static_view_offset() + offset_x); | 1427 | self.activate_prev_column_on_removal = Some(self.static_view_offset() + offset_x); |
| 1406 | let offset_x = offset_x + self.columns[source_col_idx].render_offset().x; | 1428 | let offset_x = offset_x + self.columns[source_col_idx].render_offset().x; |
| 1407 | - let tile = self.remove_tile_by_idx(source_col_idx, 0); | 1429 | + let tile = self.remove_tile_by_idx( |
| 1430 | + source_col_idx, | ||
| 1431 | + 0, | ||
| 1432 | + Some(self.options.animations.window_movement.0), | ||
| 1433 | + ); | ||
| 1408 | self.enter_output_for_window(tile.window()); | 1434 | self.enter_output_for_window(tile.window()); |
| 1409 | 1435 | ||
| 1410 | let next_col_idx = source_col_idx; | 1436 | let next_col_idx = source_col_idx; |
| @@ -1433,7 +1459,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1433 | 1459 | ||
| 1434 | let offset_x = source_column.render_offset().x; | 1460 | let offset_x = source_column.render_offset().x; |
| 1435 | 1461 | ||
| 1436 | - let tile = self.remove_tile_by_idx(source_col_idx, source_column.active_tile_idx); | 1462 | + let tile = self.remove_tile_by_idx(source_col_idx, source_column.active_tile_idx, None); |
| 1437 | 1463 | ||
| 1438 | self.add_tile_at( | 1464 | self.add_tile_at( |
| 1439 | self.active_column_idx, | 1465 | self.active_column_idx, |
| @@ -1477,7 +1503,11 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1477 | 1503 | ||
| 1478 | // Make sure the target column gets activated. | 1504 | // Make sure the target column gets activated. |
| 1479 | self.activate_prev_column_on_removal = None; | 1505 | self.activate_prev_column_on_removal = None; |
| 1480 | - let tile = self.remove_tile_by_idx(source_col_idx, 0); | 1506 | + let tile = self.remove_tile_by_idx( |
| 1507 | + source_col_idx, | ||
| 1508 | + 0, | ||
| 1509 | + Some(self.options.animations.window_movement.0), | ||
| 1510 | + ); | ||
| 1481 | self.enter_output_for_window(tile.window()); | 1511 | self.enter_output_for_window(tile.window()); |
| 1482 | 1512 | ||
| 1483 | let prev_next_x = self.column_x(target_column_idx + 1); | 1513 | let prev_next_x = self.column_x(target_column_idx + 1); |
| @@ -1502,7 +1532,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1502 | let width = source_column.width; | 1532 | let width = source_column.width; |
| 1503 | let is_full_width = source_column.is_full_width; | 1533 | let is_full_width = source_column.is_full_width; |
| 1504 | 1534 | ||
| 1505 | - let tile = self.remove_tile_by_idx(source_col_idx, source_column.active_tile_idx); | 1535 | + let tile = self.remove_tile_by_idx(source_col_idx, source_column.active_tile_idx, None); |
| 1506 | 1536 | ||
| 1507 | self.add_tile( | 1537 | self.add_tile( |
| 1508 | tile, | 1538 | tile, |
| @@ -1534,7 +1564,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1534 | - self.column_x(self.active_column_idx); | 1564 | - self.column_x(self.active_column_idx); |
| 1535 | let prev_y = self.columns[source_column_idx].tile_y(0); | 1565 | let prev_y = self.columns[source_column_idx].tile_y(0); |
| 1536 | 1566 | ||
| 1537 | - let tile = self.remove_tile_by_idx(source_column_idx, 0); | 1567 | + let tile = self.remove_tile_by_idx(source_column_idx, 0, None); |
| 1538 | self.enter_output_for_window(tile.window()); | 1568 | self.enter_output_for_window(tile.window()); |
| 1539 | 1569 | ||
| 1540 | let prev_next_x = self.column_x(self.active_column_idx + 1); | 1570 | let prev_next_x = self.column_x(self.active_column_idx + 1); |
| @@ -1581,7 +1611,8 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1581 | 1611 | ||
| 1582 | let width = source_column.width; | 1612 | let width = source_column.width; |
| 1583 | let is_full_width = source_column.is_full_width; | 1613 | let is_full_width = source_column.is_full_width; |
| 1584 | - let tile = self.remove_tile_by_idx(self.active_column_idx, source_column.active_tile_idx); | 1614 | + let tile = |
| 1615 | + self.remove_tile_by_idx(self.active_column_idx, source_column.active_tile_idx, None); | ||
| 1585 | 1616 | ||
| 1586 | self.add_tile( | 1617 | self.add_tile( |
| 1587 | tile, | 1618 | tile, |