Remove position from overlay::Element

This commit is contained in:
Héctor Ramón Jiménez 2024-02-01 01:08:21 +01:00
parent 7bbe450217
commit 738aa47547
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
27 changed files with 230 additions and 283 deletions

View file

@ -346,16 +346,15 @@ mod modal {
state: &'b mut widget::Tree,
layout: Layout<'_>,
_renderer: &Renderer,
translation: Vector,
) -> Option<overlay::Element<'b, Message, Theme, Renderer>> {
Some(overlay::Element::new(
layout.position(),
Box::new(Overlay {
content: &mut self.modal,
tree: &mut state.children[1],
size: layout.bounds().size(),
on_blur: self.on_blur.clone(),
}),
))
Some(overlay::Element::new(Box::new(Overlay {
position: layout.position() + translation,
content: &mut self.modal,
tree: &mut state.children[1],
size: layout.bounds().size(),
on_blur: self.on_blur.clone(),
})))
}
fn mouse_interaction(
@ -392,6 +391,7 @@ mod modal {
}
struct Overlay<'a, 'b, Message, Theme, Renderer> {
position: Point,
content: &'b mut Element<'a, Message, Theme, Renderer>,
tree: &'b mut widget::Tree,
size: Size,
@ -409,8 +409,6 @@ mod modal {
&mut self,
renderer: &Renderer,
_bounds: Size,
position: Point,
_translation: Vector,
) -> layout::Node {
let limits = layout::Limits::new(Size::ZERO, self.size)
.width(Length::Fill)
@ -423,7 +421,7 @@ mod modal {
.align(Alignment::Center, Alignment::Center, limits.max());
layout::Node::with_children(self.size, vec![child])
.move_to(position)
.move_to(self.position)
}
fn on_event(
@ -530,6 +528,7 @@ mod modal {
self.tree,
layout.children().next().unwrap(),
renderer,
Vector::ZERO,
)
}
}