Implement window open animations

This commit is contained in:
Ivan Molodetskikh
2024-02-07 11:32:02 +04:00
parent 49ce791d13
commit f9085db564
10 changed files with 462 additions and 11 deletions
+26 -4
View File
@@ -230,7 +230,7 @@ impl<W: LayoutElement> Workspace<W> {
}
pub fn are_animations_ongoing(&self) -> bool {
self.view_offset_anim.is_some()
self.view_offset_anim.is_some() || self.columns.iter().any(Column::are_animations_ongoing)
}
pub fn update_config(&mut self, options: Rc<Options>) {
@@ -507,6 +507,16 @@ impl<W: LayoutElement> Workspace<W> {
x
}
fn visual_column_x(&self, column_idx: usize) -> i32 {
let mut x = 0;
for column in self.columns.iter().take(column_idx) {
x += column.visual_width() + self.options.gaps;
}
x
}
pub fn add_window(
&mut self,
window: W,
@@ -978,13 +988,13 @@ impl<W: LayoutElement> Workspace<W> {
}
fn tiles_in_render_order(&self) -> impl Iterator<Item = (&'_ Tile<W>, Point<i32, Logical>)> {
let view_pos = self.view_pos();
let view_pos = self.visual_column_x(self.active_column_idx) + self.view_offset;
// Start with the active window since it's drawn on top.
let col = &self.columns[self.active_column_idx];
let tile = &col.tiles[col.active_tile_idx];
let tile_pos = Point::from((
self.column_x(self.active_column_idx) - view_pos,
self.visual_column_x(self.active_column_idx) - view_pos,
col.tile_y(col.active_tile_idx),
));
let first = iter::once((tile, tile_pos));
@@ -997,7 +1007,7 @@ impl<W: LayoutElement> Workspace<W> {
// Keep track of column X position.
.map(move |(col_idx, col)| {
let rv = (col_idx, col, x);
x += col.width() + self.options.gaps;
x += col.visual_width() + self.options.gaps;
rv
})
.flat_map(move |(col_idx, col, x)| {
@@ -1279,6 +1289,10 @@ impl<W: LayoutElement> Column<W> {
}
}
pub fn are_animations_ongoing(&self) -> bool {
self.tiles.iter().any(Tile::are_animations_ongoing)
}
pub fn contains(&self, window: &W) -> bool {
self.tiles.iter().map(Tile::window).any(|win| win == window)
}
@@ -1477,6 +1491,14 @@ impl<W: LayoutElement> Column<W> {
.unwrap()
}
fn visual_width(&self) -> i32 {
self.tiles
.iter()
.map(|tile| tile.visual_tile_size().w)
.max()
.unwrap()
}
fn focus_up(&mut self) {
self.active_tile_idx = self.active_tile_idx.saturating_sub(1);
}