summaryrefslogtreecommitdiffstats
path: root/native/src/overlay
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-01-30 05:01:28 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-01-30 05:11:59 +0100
commita50cc32d09ddff1d061701074908c28d5c5509ba (patch)
treec53742f5ce8d958e636b15d74a4781fc99e219be /native/src/overlay
parenta28bc3eaf05d59ef35ae5c182fa68478356364fd (diff)
downloadiced-a50cc32d09ddff1d061701074908c28d5c5509ba.tar.gz
iced-a50cc32d09ddff1d061701074908c28d5c5509ba.tar.bz2
iced-a50cc32d09ddff1d061701074908c28d5c5509ba.zip
Fix layout translation in `overlay::Group`
This bug produced improper positioning of overlays of elements inside a `Scrollable`.
Diffstat (limited to 'native/src/overlay')
-rw-r--r--native/src/overlay/element.rs10
-rw-r--r--native/src/overlay/group.rs6
2 files changed, 12 insertions, 4 deletions
diff --git a/native/src/overlay/element.rs b/native/src/overlay/element.rs
index bdf7766e..237d25d1 100644
--- a/native/src/overlay/element.rs
+++ b/native/src/overlay/element.rs
@@ -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`].
diff --git a/native/src/overlay/group.rs b/native/src/overlay/group.rs
index 5c9cf809..1126f0cf 100644
--- a/native/src/overlay/group.rs
+++ b/native/src/overlay/group.rs
@@ -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(),
)
}