forge
Explore
Log in

Don't you dare go Hollow

layout/scrolling: Extract two variables

Browse files at this commit

abd7f1dce3b4134801560259e3476260f9425b91Ivan MolodetskikhParent: 1d87da0
src/layout/scrolling.rsmodified+7 -9
@@ -3821,11 +3821,13 @@ impl<W: LayoutElement> Column<W> {
3821 };3821 };
3822 let current_tile_px = tile.tile_height_for_window_height(current_window_px);3822 let current_tile_px = tile.tile_height_for_window_height(current_window_px);
3823 3823
3824- let full = self.working_area.size.h - self.options.gaps;3824+ let working_size = self.working_area.size.h;
3825+ let gaps = self.options.gaps;
3826+ let full = working_size - gaps;
3825 let current_prop = if full == 0. {3827 let current_prop = if full == 0. {
3826 1.3828 1.
3827 } else {3829 } else {
3828- (current_tile_px + self.options.gaps) / full3830+ (current_tile_px + gaps) / full
3829 };3831 };
3830 3832
3831 // FIXME: fix overflows then remove limits.3833 // FIXME: fix overflows then remove limits.
@@ -3834,16 +3836,13 @@ impl<W: LayoutElement> Column<W> {
3834 let mut window_height = match change {3836 let mut window_height = match change {
3835 SizeChange::SetFixed(fixed) => f64::from(fixed),3837 SizeChange::SetFixed(fixed) => f64::from(fixed),
3836 SizeChange::SetProportion(proportion) => {3838 SizeChange::SetProportion(proportion) => {
3837- let tile_height = (self.working_area.size.h - self.options.gaps)3839+ let tile_height = (working_size - gaps) * (proportion / 100.) - gaps;
3838- * (proportion / 100.)
3839- - self.options.gaps;
3840 tile.window_height_for_tile_height(tile_height)3840 tile.window_height_for_tile_height(tile_height)
3841 }3841 }
3842 SizeChange::AdjustFixed(delta) => current_window_px + f64::from(delta),3842 SizeChange::AdjustFixed(delta) => current_window_px + f64::from(delta),
3843 SizeChange::AdjustProportion(delta) => {3843 SizeChange::AdjustProportion(delta) => {
3844 let proportion = current_prop + delta / 100.;3844 let proportion = current_prop + delta / 100.;
3845- let tile_height =3845+ let tile_height = (working_size - gaps) * proportion - gaps;
3846- (self.working_area.size.h - self.options.gaps) * proportion - self.options.gaps;
3847 tile.window_height_for_tile_height(tile_height)3846 tile.window_height_for_tile_height(tile_height)
3848 }3847 }
3849 };3848 };
@@ -3856,8 +3855,7 @@ impl<W: LayoutElement> Column<W> {
3856 .filter(|(idx, _)| *idx != tile_idx)3855 .filter(|(idx, _)| *idx != tile_idx)
3857 .map(|(_, tile)| f64::max(1., tile.min_size().h) + self.options.gaps)3856 .map(|(_, tile)| f64::max(1., tile.min_size().h) + self.options.gaps)
3858 .sum::<f64>();3857 .sum::<f64>();
3859- let height_left =3858+ let height_left = working_size - gaps - min_height_taken - gaps;
3860- self.working_area.size.h - self.options.gaps - min_height_taken - self.options.gaps;
3861 let height_left = f64::max(1., tile.window_height_for_tile_height(height_left));3859 let height_left = f64::max(1., tile.window_height_for_tile_height(height_left));
3862 window_height = f64::min(height_left, window_height);3860 window_height = f64::min(height_left, window_height);
3863 3861