layout: Pre-subtract gaps during height distribution
Browse files at this commit7a6ab31ad762f1f911dafb9fc0ade83d19c66d45Parent: 2f73dd51 changed file +8 -7
- src/layout/workspace.rs +8 -7
src/layout/workspace.rsmodified+8 -7
| @@ -3026,7 +3026,8 @@ impl<W: LayoutElement> Column<W> { | |||
| 3026 | } | 3026 | } |
| 3027 | }) | 3027 | }) |
| 3028 | .collect::<Vec<_>>(); | 3028 | .collect::<Vec<_>>(); |
| 3029 | - let mut height_left = self.working_area.size.h - self.options.gaps; | 3029 | + let gaps_left = self.options.gaps * (self.tiles.len() + 1) as f64; |
| 3030 | + let mut height_left = self.working_area.size.h - gaps_left; | ||
| 3030 | let mut auto_tiles_left = self.tiles.len(); | 3031 | let mut auto_tiles_left = self.tiles.len(); |
| 3031 | 3032 | ||
| 3032 | // Subtract all fixed-height tiles. | 3033 | // Subtract all fixed-height tiles. |
| @@ -3044,7 +3045,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 3044 | *h = f64::max(*h, min_size.h); | 3045 | *h = f64::max(*h, min_size.h); |
| 3045 | } | 3046 | } |
| 3046 | 3047 | ||
| 3047 | - height_left -= *h + self.options.gaps; | 3048 | + height_left -= *h; |
| 3048 | auto_tiles_left -= 1; | 3049 | auto_tiles_left -= 1; |
| 3049 | } | 3050 | } |
| 3050 | } | 3051 | } |
| @@ -3072,7 +3073,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 3072 | } | 3073 | } |
| 3073 | 3074 | ||
| 3074 | // Compute the current auto height. | 3075 | // Compute the current auto height. |
| 3075 | - let auto = height_left_2 / auto_tiles_left_2 as f64 - self.options.gaps; | 3076 | + let auto = height_left_2 / auto_tiles_left_2 as f64; |
| 3076 | let mut auto = tile.tile_height_for_window_height( | 3077 | let mut auto = tile.tile_height_for_window_height( |
| 3077 | tile.window_height_for_tile_height(auto).round().max(1.), | 3078 | tile.window_height_for_tile_height(auto).round().max(1.), |
| 3078 | ); | 3079 | ); |
| @@ -3081,13 +3082,13 @@ impl<W: LayoutElement> Column<W> { | |||
| 3081 | if min_size.h > 0. && min_size.h > auto { | 3082 | if min_size.h > 0. && min_size.h > auto { |
| 3082 | auto = min_size.h; | 3083 | auto = min_size.h; |
| 3083 | *h = WindowHeight::Fixed(auto); | 3084 | *h = WindowHeight::Fixed(auto); |
| 3084 | - height_left -= auto + self.options.gaps; | 3085 | + height_left -= auto; |
| 3085 | auto_tiles_left -= 1; | 3086 | auto_tiles_left -= 1; |
| 3086 | unsatisfied_min = true; | 3087 | unsatisfied_min = true; |
| 3087 | } | 3088 | } |
| 3088 | 3089 | ||
| 3089 | - height_left_2 -= auto + self.options.gaps; | ||
| 3090 | auto_tiles_left_2 -= 1; | 3090 | auto_tiles_left_2 -= 1; |
| 3091 | + height_left_2 -= auto; | ||
| 3091 | } | 3092 | } |
| 3092 | 3093 | ||
| 3093 | // If some min height was unsatisfied, then we allocated the tile more than the auto | 3094 | // If some min height was unsatisfied, then we allocated the tile more than the auto |
| @@ -3104,13 +3105,13 @@ impl<W: LayoutElement> Column<W> { | |||
| 3104 | } | 3105 | } |
| 3105 | 3106 | ||
| 3106 | // Compute the current auto height. | 3107 | // Compute the current auto height. |
| 3107 | - let auto = height_left / auto_tiles_left as f64 - self.options.gaps; | 3108 | + let auto = height_left / auto_tiles_left as f64; |
| 3108 | let auto = tile.tile_height_for_window_height( | 3109 | let auto = tile.tile_height_for_window_height( |
| 3109 | tile.window_height_for_tile_height(auto).round().max(1.), | 3110 | tile.window_height_for_tile_height(auto).round().max(1.), |
| 3110 | ); | 3111 | ); |
| 3111 | 3112 | ||
| 3112 | *h = WindowHeight::Fixed(auto); | 3113 | *h = WindowHeight::Fixed(auto); |
| 3113 | - height_left -= auto + self.options.gaps; | 3114 | + height_left -= auto; |
| 3114 | auto_tiles_left -= 1; | 3115 | auto_tiles_left -= 1; |
| 3115 | } | 3116 | } |
| 3116 | 3117 | ||