Fix layout translation in overlay::Group

This bug produced improper positioning of overlays of elements inside a
`Scrollable`.
This commit is contained in:
Héctor Ramón Jiménez 2023-01-30 05:01:28 +01:00
parent a28bc3eaf0
commit a50cc32d09
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
7 changed files with 33 additions and 18 deletions

View file

@ -53,8 +53,14 @@ where
}
/// Computes the layout of the [`Element`] in the given bounds.
pub fn layout(&self, renderer: &Renderer, bounds: Size) -> layout::Node {
self.overlay.layout(renderer, bounds, self.position)
pub fn layout(
&self,
renderer: &Renderer,
bounds: Size,
translation: Vector,
) -> layout::Node {
self.overlay
.layout(renderer, bounds, self.position + translation)
}
/// Processes a runtime [`Event`].

View file

@ -66,13 +66,15 @@ where
&self,
renderer: &Renderer,
bounds: Size,
_position: Point,
position: Point,
) -> layout::Node {
let translation = position - Point::ORIGIN;
layout::Node::with_children(
bounds,
self.children
.iter()
.map(|child| child.layout(renderer, bounds))
.map(|child| child.layout(renderer, bounds, translation))
.collect(),
)
}