forge
Explore
Log in

Don't you dare go Hollow

Implement consume/expel animations

Browse files at this commit

b28810286649cadeb5178d958a91d45f1ea462c0Ivan MolodetskikhParent: ff42f9b
src/layout/workspace.rsmodified+93 -13
@@ -670,6 +670,7 @@ impl<W: LayoutElement> Workspace<W> {
670670 self.options.clone(),
671671 width,
672672 is_full_width,
673+ true,
673674 );
674675 let width = column.width();
675676 self.columns.insert(col_idx, column);
@@ -747,6 +748,7 @@ impl<W: LayoutElement> Workspace<W> {
747748 self.options.clone(),
748749 width,
749750 is_full_width,
751+ true,
750752 );
751753 self.columns.insert(idx, column);
752754
@@ -1313,31 +1315,57 @@ impl<W: LayoutElement> Workspace<W> {
13131315 return;
13141316 }
13151317
1316- let source_column = &self.columns[self.active_column_idx];
1318+ let source_col_idx = self.active_column_idx;
1319+ let source_column = &self.columns[source_col_idx];
1320+ let prev_y = source_column.tile_y(source_column.active_tile_idx);
1321+
13171322 if source_column.tiles.len() == 1 {
13181323 if self.active_column_idx == 0 {
13191324 return;
13201325 }
13211326
1327+ let offset_x = self.column_x(source_col_idx) - self.column_x(source_col_idx - 1);
1328+
13221329 // Move into adjacent column.
1323- let target_column_idx = self.active_column_idx - 1;
1324- let window = self.remove_window_by_idx(self.active_column_idx, 0);
1330+ let target_column_idx = source_col_idx - 1;
1331+
1332+ // Make sure the previous (target) column is activated so the animation looks right.
1333+ self.activate_prev_column_on_removal = Some(self.static_view_offset());
1334+ let window = self.remove_window_by_idx(source_col_idx, 0);
13251335 self.enter_output_for_window(&window);
13261336
1337+ let next_col_idx = source_col_idx;
1338+ let prev_next_x = self.column_x(next_col_idx);
1339+
13271340 let target_column = &mut self.columns[target_column_idx];
1341+ let offset_y = prev_y - target_column.tile_y(target_column.tiles.len());
1342+
13281343 target_column.add_window(window, true);
13291344 target_column.focus_last();
1330- self.activate_column(target_column_idx);
1345+
1346+ let new_tile = target_column.tiles.last_mut().unwrap();
1347+ new_tile.animate_move_from(Point::from((offset_x, offset_y)));
1348+
1349+ // Consuming a window into a column could've increased its width if the new window had a
1350+ // larger min width. Move the next columns to account for this.
1351+ let offset_next = prev_next_x - self.column_x(next_col_idx);
1352+ for col in &mut self.columns[next_col_idx..] {
1353+ col.animate_move_from(offset_next);
1354+ }
13311355 } else {
13321356 // Move out of column.
13331357 let width = source_column.width;
13341358 let is_full_width = source_column.is_full_width;
1335- let window =
1336- self.remove_window_by_idx(self.active_column_idx, source_column.active_tile_idx);
1359+
1360+ let window = self.remove_window_by_idx(source_col_idx, source_column.active_tile_idx);
13371361
13381362 self.add_window_at(self.active_column_idx, window, true, width, is_full_width);
13391363 // We added to the left, don't activate even further left on removal.
13401364 self.activate_prev_column_on_removal = None;
1365+
1366+ let new_col = &mut self.columns[self.active_column_idx];
1367+ let offset_y = prev_y - new_col.tile_y(0);
1368+ new_col.tiles[0].animate_move_from(Point::from((0, offset_y)));
13411369 }
13421370 }
13431371
@@ -1346,29 +1374,53 @@ impl<W: LayoutElement> Workspace<W> {
13461374 return;
13471375 }
13481376
1349- let source_column = &self.columns[self.active_column_idx];
1377+ let source_col_idx = self.active_column_idx;
1378+ let offset_x = self.column_x(source_col_idx) - self.column_x(source_col_idx + 1);
1379+
1380+ let source_column = &self.columns[source_col_idx];
1381+ let prev_y = source_column.tile_y(source_column.active_tile_idx);
1382+
13501383 if source_column.tiles.len() == 1 {
13511384 if self.active_column_idx + 1 == self.columns.len() {
13521385 return;
13531386 }
13541387
13551388 // Move into adjacent column.
1356- let target_column_idx = self.active_column_idx;
1357- let window = self.remove_window_by_idx(self.active_column_idx, 0);
1389+ let target_column_idx = source_col_idx;
1390+
1391+ // Make sure the target column gets activated.
1392+ self.activate_prev_column_on_removal = None;
1393+ let window = self.remove_window_by_idx(source_col_idx, 0);
13581394 self.enter_output_for_window(&window);
13591395
1396+ let prev_next_x = self.column_x(target_column_idx + 1);
1397+
13601398 let target_column = &mut self.columns[target_column_idx];
1399+ let offset_y = prev_y - target_column.tile_y(target_column.tiles.len());
1400+
13611401 target_column.add_window(window, true);
13621402 target_column.focus_last();
1363- self.activate_column(target_column_idx);
1403+
1404+ let new_tile = target_column.tiles.last_mut().unwrap();
1405+ new_tile.animate_move_from(Point::from((offset_x, offset_y)));
1406+
1407+ // Consuming a window into a column could've increased its width if the new window had a
1408+ // larger min width. Move the next columns to account for this.
1409+ let offset_next = prev_next_x - self.column_x(target_column_idx + 1);
1410+ for col in &mut self.columns[target_column_idx + 1..] {
1411+ col.animate_move_from(offset_next);
1412+ }
13641413 } else {
13651414 // Move out of column.
13661415 let width = source_column.width;
13671416 let is_full_width = source_column.is_full_width;
1368- let window =
1369- self.remove_window_by_idx(self.active_column_idx, source_column.active_tile_idx);
1417+ let window = self.remove_window_by_idx(source_col_idx, source_column.active_tile_idx);
13701418
13711419 self.add_window(window, true, width, is_full_width);
1420+
1421+ let new_col = &mut self.columns[self.active_column_idx];
1422+ let offset_y = prev_y - new_col.tile_y(0);
1423+ new_col.tiles[0].animate_move_from(Point::from((offset_x, offset_y)));
13721424 }
13731425 }
13741426
@@ -1382,17 +1434,34 @@ impl<W: LayoutElement> Workspace<W> {
13821434 }
13831435
13841436 let source_column_idx = self.active_column_idx + 1;
1437+
1438+ let offset_x = self.column_x(source_column_idx) - self.column_x(self.active_column_idx);
1439+ let prev_y = self.columns[source_column_idx].tile_y(0);
1440+
13851441 let window = self.remove_window_by_idx(source_column_idx, 0);
13861442 self.enter_output_for_window(&window);
13871443
1444+ let prev_next_x = self.column_x(self.active_column_idx + 1);
1445+
13881446 let target_column = &mut self.columns[self.active_column_idx];
13891447 let was_fullscreen = target_column.tiles[target_column.active_tile_idx].is_fullscreen();
1448+ let offset_y = prev_y - target_column.tile_y(target_column.tiles.len());
13901449
13911450 target_column.add_window(window, true);
13921451
13931452 if !was_fullscreen {
13941453 self.view_offset_before_fullscreen = None;
13951454 }
1455+
1456+ let new_tile = target_column.tiles.last_mut().unwrap();
1457+ new_tile.animate_move_from(Point::from((offset_x, offset_y)));
1458+
1459+ // Consuming a window into a column could've increased its width if the new window had a
1460+ // larger min width. Move the next columns to account for this.
1461+ let offset_next = prev_next_x - self.column_x(self.active_column_idx + 1);
1462+ for col in &mut self.columns[self.active_column_idx + 1..] {
1463+ col.animate_move_from(offset_next);
1464+ }
13961465 }
13971466
13981467 pub fn expel_from_column(&mut self) {
@@ -1400,17 +1469,26 @@ impl<W: LayoutElement> Workspace<W> {
14001469 return;
14011470 }
14021471
1472+ let offset_x =
1473+ self.column_x(self.active_column_idx) - self.column_x(self.active_column_idx + 1);
1474+
14031475 let source_column = &self.columns[self.active_column_idx];
14041476 if source_column.tiles.len() == 1 {
14051477 return;
14061478 }
14071479
1480+ let prev_y = source_column.tile_y(source_column.active_tile_idx);
1481+
14081482 let width = source_column.width;
14091483 let is_full_width = source_column.is_full_width;
14101484 let window =
14111485 self.remove_window_by_idx(self.active_column_idx, source_column.active_tile_idx);
14121486
14131487 self.add_window(window, true, width, is_full_width);
1488+
1489+ let new_col = &mut self.columns[self.active_column_idx];
1490+ let offset_y = prev_y - new_col.tile_y(0);
1491+ new_col.tiles[0].animate_move_from(Point::from((offset_x, offset_y)));
14141492 }
14151493
14161494 pub fn center_column(&mut self) {
@@ -1608,6 +1686,7 @@ impl<W: LayoutElement> Workspace<W> {
16081686 self.options.clone(),
16091687 width,
16101688 is_full_width,
1689+ false,
16111690 ),
16121691 );
16131692
@@ -1942,6 +2021,7 @@ impl<W: LayoutElement> Column<W> {
19422021 options: Rc<Options>,
19432022 width: ColumnWidth,
19442023 is_full_width: bool,
2024+ animate_resize: bool,
19452025 ) -> Self {
19462026 let mut rv = Self {
19472027 tiles: vec![],
@@ -1959,7 +2039,7 @@ impl<W: LayoutElement> Column<W> {
19592039
19602040 let is_pending_fullscreen = window.is_pending_fullscreen();
19612041
1962- rv.add_window(window, false);
2042+ rv.add_window(window, animate_resize);
19632043
19642044 if is_pending_fullscreen {
19652045 rv.set_fullscreen(true);