diff options
| author | 2024-02-01 12:49:57 +0100 | |
|---|---|---|
| committer | 2024-02-01 12:49:57 +0100 | |
| commit | 264f20697b8f2844ab2efae1e6c33caaf8ffe468 (patch) | |
| tree | 4f262c1bc4d9b55f030146ec2a6f9b6cc421a6c5 /examples/modal/src | |
| parent | 7bbe4502170be1942c4e61d222e14401f724aa42 (diff) | |
| parent | 738aa47547818ebf57dc4f00099386a5a22a86d5 (diff) | |
| download | iced-264f20697b8f2844ab2efae1e6c33caaf8ffe468.tar.gz iced-264f20697b8f2844ab2efae1e6c33caaf8ffe468.tar.bz2 iced-264f20697b8f2844ab2efae1e6c33caaf8ffe468.zip  | |
Merge pull request #2226 from iced-rs/overlay-composition-reloaded
Remove `position` from `overlay::Element`
Diffstat (limited to 'examples/modal/src')
| -rw-r--r-- | examples/modal/src/main.rs | 23 | 
1 files changed, 11 insertions, 12 deletions
diff --git a/examples/modal/src/main.rs b/examples/modal/src/main.rs index c2a4132c..6fe951ee 100644 --- a/examples/modal/src/main.rs +++ b/examples/modal/src/main.rs @@ -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,              )          }      }  | 
