From 0b83d9932b5b8b93837d9c0683b19e5de5587a43 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 9 Feb 2025 19:59:03 +0300 Subject: tab indicator: Use full column height --- src/layout/scrolling.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index 45323ec7..f3916d46 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -3470,6 +3470,30 @@ impl Column { 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) @@ -3486,8 +3510,6 @@ impl Column { // many changes to the code for too little benefit (it's mostly invisible anyway). let enabled = self.display_mode == ColumnDisplay::Tabbed && !self.is_fullscreen; - let area_size = self.tiles[active_idx].animated_tile_size(); - self.tab_indicator.update_render_elements( enabled, Rectangle::new(self.tiles_origin(), area_size), -- cgit