diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-10 13:10:36 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-10 07:29:33 -0800 |
| commit | 96a3ded2ec74954e9432f4b84bc8e125851dfb9e (patch) | |
| tree | a3ebe1a7dc480c28d6d7aacb44d1d1d2472bbff9 /src | |
| parent | a21196ec54a0e2bb59e0f52308c38eabe841b923 (diff) | |
| download | niri-96a3ded2ec74954e9432f4b84bc8e125851dfb9e.tar.gz niri-96a3ded2ec74954e9432f4b84bc8e125851dfb9e.tar.bz2 niri-96a3ded2ec74954e9432f4b84bc8e125851dfb9e.zip | |
scrolling: Extract tab_indicator_area()
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/scrolling.rs | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index f3916d46..ab0ad69a 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -3470,30 +3470,6 @@ impl<W: LayoutElement> Column<W> { tile.update_render_elements(is_active, tile_view_rect); } - // We'd like to use the active tile's animated size for the tab indicator, however we need - // to be mindful of the case where the active tile is smaller than some other tile in the - // column. The column assumes the size of the largest tile. - // - // We expect users to mainly resize tabbed columns by width, so matching the animated size - // is more important here. Besides, we always try to resize all windows in a column to the - // same width when possible, and also the animation for going into tabbed mode doesn't move - // tiles horizontally as much. - // - // For height though, it's a different story. First, users probably aren't resizing a - // tabbed column by height. Second, we don't match windows by height, so it's easy to have - // a smaller active tile than the rest of the column, e.g. by adding a fixed-size dialog. - // Then, switching to that dialog and back should ideally keep the tab indicator position - // fixed. Third, the animation for making a column tabbed moves tiles vertically, and using - // the active tile's animated size in this case only works for the topmost tile, and looks - // broken otherwise. - let mut max_height = 0.; - for tile in &self.tiles { - max_height = f64::max(max_height, tile.tile_size().h); - } - - let tile = &self.tiles[active_idx]; - let area_size = Size::from((tile.animated_tile_size().w, max_height)); - let config = self.tab_indicator.config(); let offsets = self.tile_offsets_iter(self.data.iter().copied()); let tabs = zip(&self.tiles, offsets) @@ -3512,7 +3488,7 @@ impl<W: LayoutElement> Column<W> { self.tab_indicator.update_render_elements( enabled, - Rectangle::new(self.tiles_origin(), area_size), + self.tab_indicator_area(), view_rect, self.tiles.len(), tabs, @@ -4506,6 +4482,34 @@ impl<W: LayoutElement> Column<W> { zip(tiles, offsets) } + fn tab_indicator_area(&self) -> Rectangle<f64, Logical> { + // We'd like to use the active tile's animated size for the tab indicator, however we need + // to be mindful of the case where the active tile is smaller than some other tile in the + // column. The column assumes the size of the largest tile. + // + // We expect users to mainly resize tabbed columns by width, so matching the animated size + // is more important here. Besides, we always try to resize all windows in a column to the + // same width when possible, and also the animation for going into tabbed mode doesn't move + // tiles horizontally as much. + // + // For height though, it's a different story. First, users probably aren't resizing a + // tabbed column by height. Second, we don't match windows by height, so it's easy to have + // a smaller active tile than the rest of the column, e.g. by adding a fixed-size dialog. + // Then, switching to that dialog and back should ideally keep the tab indicator position + // fixed. Third, the animation for making a column tabbed moves tiles vertically, and using + // the active tile's animated size in this case only works for the topmost tile, and looks + // broken otherwise. + let mut max_height = 0.; + for tile in &self.tiles { + max_height = f64::max(max_height, tile.tile_size().h); + } + + let tile = &self.tiles[self.active_tile_idx]; + let area_size = Size::from((tile.animated_tile_size().w, max_height)); + + Rectangle::new(self.tiles_origin(), area_size) + } + #[cfg(test)] fn verify_invariants(&self) { assert!(!self.tiles.is_empty(), "columns can't be empty"); |
