forge
Explore
Log in

Don't you dare go Hollow

layout/scrolling: Extract tiles_origin()

Browse files at this commit

7d24ad23c2bc690b22b1f13ad4598dc8323d128bIvan MolodetskikhParent: 691bc06
src/layout/scrolling.rsmodified+14 -9
@@ -3934,6 +3934,14 @@ impl<W: LayoutElement> Column<W> {
3934 None3934 None
3935 }3935 }
3936 3936
3937+ fn tiles_origin(&self) -> Point<f64, Logical> {
3938+ if self.is_fullscreen {
3939+ Point::from((0., 0.))
3940+ } else {
3941+ Point::from((0., self.working_area.loc.y + self.options.gaps))
3942+ }
3943+ }
3944+
3937 // HACK: pass a self.data iterator in manually as a workaround for the lack of method partial3945 // HACK: pass a self.data iterator in manually as a workaround for the lack of method partial
3938 // borrowing. Note that this method's return value does not borrow the entire &Self!3946 // borrowing. Note that this method's return value does not borrow the entire &Self!
3939 fn tile_offsets_iter(3947 fn tile_offsets_iter(
@@ -3950,11 +3958,7 @@ impl<W: LayoutElement> Column<W> {
3950 } else {3958 } else {
3951 self.width()3959 self.width()
3952 };3960 };
3953- let mut y = 0.;3961+ let mut origin = self.tiles_origin();
3954-
3955- if !self.is_fullscreen {
3956- y = self.working_area.loc.y + self.options.gaps;
3957- }
3958 3962
3959 // Chain with a dummy value to be able to get one past all tiles' Y.3963 // Chain with a dummy value to be able to get one past all tiles' Y.
3960 let dummy = TileData {3964 let dummy = TileData {
@@ -3965,15 +3969,16 @@ impl<W: LayoutElement> Column<W> {
3965 let data = data.chain(iter::once(dummy));3969 let data = data.chain(iter::once(dummy));
3966 3970
3967 data.map(move |data| {3971 data.map(move |data| {
3968- let mut pos = Point::from((0., y));3972+ let mut pos = origin;
3969 3973
3970 if center {3974 if center {
3971- pos.x = (col_width - data.size.w) / 2.;3975+ pos.x += (col_width - data.size.w) / 2.;
3972 } else if data.interactively_resizing_by_left_edge {3976 } else if data.interactively_resizing_by_left_edge {
3973- pos.x = col_width - data.size.w;3977+ pos.x += col_width - data.size.w;
3974 }3978 }
3975 3979
3976- y += data.size.h + gaps;3980+ origin.y += data.size.h + gaps;
3981+
3977 pos3982 pos
3978 })3983 })
3979 }3984 }