diff --git a/examples/grid/src/main.rs b/examples/grid/src/main.rs index 596b0c65..e73d24f0 100644 --- a/examples/grid/src/main.rs +++ b/examples/grid/src/main.rs @@ -86,11 +86,11 @@ impl Sandbox for App { let col_spacing_slider = slider(0.0..=100.0, self.column_spacing, Message::ColumnSpacing).width(Length::Fill); - let debug_mode_check = checkbox("", self.debug_layout, Message::DebugToggled); + let debug_mode_check = checkbox("", self.debug_layout).on_toggle(Message::DebugToggled); let fill_checkboxes = row![ - checkbox("Width", self.fill_width, Message::FillWidth), - checkbox("Height", self.fill_height, Message::FillHeight) + checkbox("Width", self.fill_width).on_toggle(Message::FillWidth), + checkbox("Height", self.fill_height).on_toggle(Message::FillHeight) ] .spacing(10); diff --git a/src/native/card.rs b/src/native/card.rs index 8eb1aa60..1f74caea 100644 --- a/src/native/card.rs +++ b/src/native/card.rs @@ -14,7 +14,7 @@ use iced_widget::{ renderer, touch, widget::{Operation, Tree}, Alignment, Border, Clipboard, Color, Element, Event, Layout, Length, Padding, Pixels, - Point, Rectangle, Shadow, Shell, Size, Widget, + Point, Rectangle, Shadow, Shell, Size, Vector, Widget, }, text::LineHeight, }; @@ -583,6 +583,7 @@ where tree: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { let mut children = vec![&mut self.head, &mut self.body]; if let Some(foot) = &mut self.foot { @@ -594,7 +595,9 @@ where .zip(layout.children()) .filter_map(|((child, state), layout)| { layout.children().next().and_then(|child_layout| { - child.as_widget_mut().overlay(state, child_layout, renderer) + child + .as_widget_mut() + .overlay(state, child_layout, renderer, translation) }) }) .collect::>(); diff --git a/src/native/color_picker.rs b/src/native/color_picker.rs index 44915e33..b9736eb7 100644 --- a/src/native/color_picker.rs +++ b/src/native/color_picker.rs @@ -17,7 +17,7 @@ use iced_widget::{ self, tree::{self, Tag, Tree}, }, - Clipboard, Color, Element, Event, Layout, Length, Point, Rectangle, Shell, Widget, + Clipboard, Color, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget, }, renderer::Renderer, }; @@ -242,14 +242,17 @@ where state: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { let picker_state: &mut State = state.state.downcast_mut(); if !self.show_picker { - return self - .underlay - .as_widget_mut() - .overlay(&mut state.children[0], layout, renderer); + return self.underlay.as_widget_mut().overlay( + &mut state.children[0], + layout, + renderer, + translation, + ); } let bounds = layout.bounds(); diff --git a/src/native/context_menu.rs b/src/native/context_menu.rs index b91847c9..59822abf 100644 --- a/src/native/context_menu.rs +++ b/src/native/context_menu.rs @@ -6,7 +6,7 @@ use iced_widget::core::{ mouse::{self, Button, Cursor}, overlay, renderer, widget::{tree, Operation, Tree}, - Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Widget, + Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget, }; use crate::native::overlay::ContextMenuOverlay; @@ -218,23 +218,31 @@ where state: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { let s: &mut State = state.state.downcast_mut(); if !s.show { - return self - .underlay - .as_widget_mut() - .overlay(&mut state.children[0], layout, renderer); + return self.underlay.as_widget_mut().overlay( + &mut state.children[0], + layout, + renderer, + translation, + ); } let position = s.cursor_position; let content = (self.overlay)(); content.as_widget().diff(&mut state.children[1]); - Some( - ContextMenuOverlay::new(&mut state.children[1], content, self.style.clone(), s) - .overlay(position), + ContextMenuOverlay::new( + position + translation, + &mut state.children[1], + content, + self.style.clone(), + s, + ) + .overlay(), ) } } diff --git a/src/native/date_picker.rs b/src/native/date_picker.rs index dcb84dd9..340413f7 100644 --- a/src/native/date_picker.rs +++ b/src/native/date_picker.rs @@ -16,7 +16,7 @@ use iced_widget::{ self, tree::{Tag, Tree}, }, - Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Widget, + Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget, }, renderer::Renderer, text, @@ -249,14 +249,17 @@ where state: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { let picker_state: &mut State = state.state.downcast_mut(); if !self.show_picker { - return self - .underlay - .as_widget_mut() - .overlay(&mut state.children[0], layout, renderer); + return self.underlay.as_widget_mut().overlay( + &mut state.children[0], + layout, + renderer, + translation, + ); } let bounds = layout.bounds(); diff --git a/src/native/floating_element.rs b/src/native/floating_element.rs index 180e0e5e..4ecedd0a 100644 --- a/src/native/floating_element.rs +++ b/src/native/floating_element.rs @@ -10,7 +10,7 @@ use iced_widget::core::{ mouse::{self, Cursor}, overlay, renderer, widget::{Operation, Tree}, - Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Widget, + Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Vector, Widget, }; pub mod anchor; @@ -211,27 +211,30 @@ where state: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { if self.hidden { - return self - .underlay - .as_widget_mut() - .overlay(&mut state.children[0], layout, renderer); + return self.underlay.as_widget_mut().overlay( + &mut state.children[0], + layout, + renderer, + translation, + ); } if state.children.len() == 2 { let bounds = layout.bounds(); - Some(overlay::Element::new( - bounds.position(), - Box::new(FloatingElementOverlay::new( + Some(overlay::Element::new(Box::new( + FloatingElementOverlay::new( + layout.position() + translation, &mut state.children[1], &mut self.element, &self.anchor, &self.offset, bounds, - )), - )) + ), + ))) } else { None } diff --git a/src/native/grid/widget.rs b/src/native/grid/widget.rs index ccccc9b9..765cbb3d 100644 --- a/src/native/grid/widget.rs +++ b/src/native/grid/widget.rs @@ -5,7 +5,7 @@ use iced_widget::core::{ overlay::Group, renderer::Style, widget::{Operation, Tree}, - Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Size, Widget, + Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Size, Vector, Widget, }; use super::{layout::layout, types::Grid}; @@ -159,13 +159,16 @@ where tree: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { let children = self .elements_iter_mut() .zip(&mut tree.children) .zip(layout.children()) .filter_map(|((child, state), layout)| { - child.as_widget_mut().overlay(state, layout, renderer) + child + .as_widget_mut() + .overlay(state, layout, renderer, translation) }) .collect::>(); diff --git a/src/native/modal.rs b/src/native/modal.rs index 5f59222e..887cca3e 100644 --- a/src/native/modal.rs +++ b/src/native/modal.rs @@ -10,7 +10,7 @@ use iced_widget::core::{ mouse::{self, Cursor}, overlay, renderer, widget::{Operation, Tree}, - Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Widget, + Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Vector, Widget, }; pub use crate::style::modal::StyleSheet; @@ -232,28 +232,27 @@ where state: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { if let Some(overlay) = &mut self.overlay { - let bounds = layout.bounds(); - let position = Point::new(bounds.x, bounds.y); overlay.as_widget().diff(&mut state.children[1]); - Some(overlay::Element::new( - position, - Box::new(ModalOverlay::new( - &mut state.children[1], - overlay, - self.backdrop.clone(), - self.esc.clone(), - self.style.clone(), - self.horizontal_alignment, - self.vertical_alignment, - )), - )) + Some(overlay::Element::new(Box::new(ModalOverlay::new( + &mut state.children[1], + overlay, + self.backdrop.clone(), + self.esc.clone(), + self.style.clone(), + self.horizontal_alignment, + self.vertical_alignment, + )))) } else { - self.underlay - .as_widget_mut() - .overlay(&mut state.children[0], layout, renderer) + self.underlay.as_widget_mut().overlay( + &mut state.children[0], + layout, + renderer, + translation, + ) } } diff --git a/src/native/overlay/color_picker.rs b/src/native/overlay/color_picker.rs index b451f550..b19bc8b6 100644 --- a/src/native/overlay/color_picker.rs +++ b/src/native/overlay/color_picker.rs @@ -118,7 +118,7 @@ where /// Turn this [`ColorPickerOverlay`] into an overlay [`Element`](overlay::Element). #[must_use] pub fn overlay(self) -> overlay::Element<'a, Message, Theme, Renderer> { - overlay::Element::new(self.position, Box::new(self)) + overlay::Element::new(Box::new(self)) } /// The event handling for the HSV color area. @@ -552,13 +552,7 @@ where Message: 'static + Clone, Theme: 'a + StyleSheet + button::StyleSheet + widget::text::StyleSheet, { - fn layout( - &mut self, - renderer: &Renderer, - bounds: Size, - position: Point, - _translation: Vector, - ) -> Node { + fn layout(&mut self, renderer: &Renderer, bounds: Size) -> Node { let (max_width, max_height) = if bounds.width > bounds.height { (600.0, 300.0) } else { @@ -598,10 +592,10 @@ where .bounds(); // ----------- Block 1 ---------------------- - let block1_node = block1_layout(self, renderer, block1_bounds, position); + let block1_node = block1_layout(self, renderer, block1_bounds, self.position); // ----------- Block 2 ---------------------- - let block2_node = block2_layout(self, renderer, block2_bounds, position); + let block2_node = block2_layout(self, renderer, block2_bounds, self.position); let (width, height) = if bounds.width > bounds.height { ( @@ -618,7 +612,7 @@ where let mut node = Node::with_children(Size::new(width, height), vec![block1_node, block2_node]); - node.center_and_bounce(position, bounds); + node.center_and_bounce(self.position, bounds); node } diff --git a/src/native/overlay/context_menu.rs b/src/native/overlay/context_menu.rs index 4f064ce7..a8937540 100644 --- a/src/native/overlay/context_menu.rs +++ b/src/native/overlay/context_menu.rs @@ -13,7 +13,7 @@ use iced_widget::core::{ overlay, renderer, touch, widget::tree::Tree, window, Border, Clipboard, Color, Element, Event, Layout, Point, Rectangle, Shadow, Shell, - Size, Vector, + Size, }; /// The overlay of the [`ContextMenu`](crate::native::ContextMenu). @@ -28,6 +28,8 @@ pub struct ContextMenuOverlay< Renderer: 'a + core::Renderer, Theme: StyleSheet, { + // The position of the element + position: Point, /// The state of the [`ContextMenuOverlay`]. tree: &'a mut Tree, /// The content of the [`ContextMenuOverlay`]. @@ -46,6 +48,7 @@ where { /// Creates a new [`ContextMenuOverlay`]. pub(crate) fn new( + position: Point, tree: &'a mut Tree, content: C, style: ::Style, @@ -55,6 +58,7 @@ where C: Into>, { ContextMenuOverlay { + position, tree, content: content.into(), style, @@ -63,8 +67,8 @@ where } /// Turn this [`ContextMenuOverlay`] into an overlay [`Element`](overlay::Element). - pub fn overlay(self, position: Point) -> overlay::Element<'a, Message, Theme, Renderer> { - overlay::Element::new(position, Box::new(self)) + pub fn overlay(self) -> overlay::Element<'a, Message, Theme, Renderer> { + overlay::Element::new(Box::new(self)) } } @@ -75,13 +79,7 @@ where Renderer: 'a + core::Renderer, Theme: StyleSheet, { - fn layout( - &mut self, - renderer: &Renderer, - bounds: Size, - position: Point, - _translation: Vector, - ) -> Node { + fn layout(&mut self, renderer: &Renderer, bounds: Size) -> Node { let limits = Limits::new(Size::ZERO, bounds); let max_size = limits.max(); @@ -91,7 +89,7 @@ where .layout(self.tree, renderer, &limits); // Try to stay inside borders - let mut position = position; + let mut position = self.position; if position.x + content.size().width > bounds.width { position.x = f32::max(0.0, position.x - content.size().width); } diff --git a/src/native/overlay/date_picker.rs b/src/native/overlay/date_picker.rs index c7f20333..dbc673fb 100644 --- a/src/native/overlay/date_picker.rs +++ b/src/native/overlay/date_picker.rs @@ -29,7 +29,7 @@ use iced_widget::{ touch, widget::tree::Tree, Alignment, Border, Clipboard, Color, Element, Event, Layout, Length, Overlay, Padding, - Point, Rectangle, Renderer as _, Shadow, Shell, Size, Vector, Widget, + Point, Rectangle, Renderer as _, Shadow, Shell, Size, Widget, }, renderer::Renderer, text, Button, Column, Container, Row, Text, @@ -113,7 +113,7 @@ where /// Turn this [`DatePickerOverlay`] into an overlay [`Element`](overlay::Element). #[must_use] pub fn overlay(self) -> overlay::Element<'a, Message, Theme, Renderer> { - overlay::Element::new(self.position, Box::new(self)) + overlay::Element::new(Box::new(self)) } /// String representation of the current year. @@ -369,13 +369,7 @@ where Theme: 'a + StyleSheet + button::StyleSheet + text::StyleSheet + container::StyleSheet, { #[allow(clippy::too_many_lines)] - fn layout( - &mut self, - renderer: &Renderer, - bounds: Size, - position: Point, - _translation: Vector, - ) -> Node { + fn layout(&mut self, renderer: &Renderer, bounds: Size) -> Node { let limits = Limits::new(Size::ZERO, bounds) .shrink(Padding::from(PADDING)) .width(Length::Fill) @@ -528,7 +522,7 @@ where ), vec![col, cancel_button, submit_button], ); - node.center_and_bounce(position, bounds); + node.center_and_bounce(self.position, bounds); node } diff --git a/src/native/overlay/floating_element.rs b/src/native/overlay/floating_element.rs index 09b21a91..ba8c3280 100644 --- a/src/native/overlay/floating_element.rs +++ b/src/native/overlay/floating_element.rs @@ -22,6 +22,8 @@ pub struct FloatingElementOverlay< Theme = iced_widget::Theme, Renderer = iced_widget::Renderer, > { + // The position of the element + position: Point, /// The state of the element. state: &'b mut Tree, /// The floating element @@ -41,6 +43,7 @@ where /// Creates a new [`FloatingElementOverlay`] containing the given /// [`Element`](iced_widget::core::Element). pub fn new( + position: Point, state: &'b mut Tree, element: &'b mut Element<'a, Message, Theme, Renderer>, anchor: &'b Anchor, @@ -48,6 +51,7 @@ where underlay_bounds: Rectangle, ) -> Self { FloatingElementOverlay { + position, state, element, anchor, @@ -62,13 +66,7 @@ impl<'a, 'b, Message, Theme, Renderer> core::Overlay where Renderer: core::Renderer, { - fn layout( - &mut self, - renderer: &Renderer, - _bounds: Size, - position: Point, - _translation: Vector, - ) -> layout::Node { + fn layout(&mut self, renderer: &Renderer, _bounds: Size) -> layout::Node { // Constrain overlay to fit inside the underlay's bounds let limits = layout::Limits::new(Size::ZERO, self.underlay_bounds.size()) .width(Length::Fill) @@ -79,37 +77,46 @@ where .layout(self.state, renderer, &limits); let position = match self.anchor { - Anchor::NorthWest => Point::new(position.x + self.offset.x, position.y + self.offset.y), + Anchor::NorthWest => Point::new( + self.position.x + self.offset.x, + self.position.y + self.offset.y, + ), Anchor::NorthEast => Point::new( - position.x + self.underlay_bounds.width - node.bounds().width - self.offset.x, - position.y + self.offset.y, + self.position.x + self.underlay_bounds.width - node.bounds().width - self.offset.x, + self.position.y + self.offset.y, ), Anchor::SouthWest => Point::new( - position.x + self.offset.x, - position.y + self.underlay_bounds.height - node.bounds().height - self.offset.y, + self.position.x + self.offset.x, + self.position.y + self.underlay_bounds.height + - node.bounds().height + - self.offset.y, ), Anchor::SouthEast => Point::new( - position.x + self.underlay_bounds.width - node.bounds().width - self.offset.x, - position.y + self.underlay_bounds.height - node.bounds().height - self.offset.y, + self.position.x + self.underlay_bounds.width - node.bounds().width - self.offset.x, + self.position.y + self.underlay_bounds.height + - node.bounds().height + - self.offset.y, ), Anchor::North => Point::new( - position.x + self.underlay_bounds.width / 2.0 - node.bounds().width / 2.0 + self.position.x + self.underlay_bounds.width / 2.0 - node.bounds().width / 2.0 + self.offset.x, - position.y + self.offset.y, + self.position.y + self.offset.y, ), Anchor::East => Point::new( - position.x + self.underlay_bounds.width - node.bounds().width - self.offset.x, - position.y + self.underlay_bounds.height / 2.0 - node.bounds().height / 2.0 + self.position.x + self.underlay_bounds.width - node.bounds().width - self.offset.x, + self.position.y + self.underlay_bounds.height / 2.0 - node.bounds().height / 2.0 + self.offset.y, ), Anchor::South => Point::new( - position.x + self.underlay_bounds.width / 2.0 - node.bounds().width / 2.0 + self.position.x + self.underlay_bounds.width / 2.0 - node.bounds().width / 2.0 + self.offset.x, - position.y + self.underlay_bounds.height - node.bounds().height - self.offset.y, + self.position.y + self.underlay_bounds.height + - node.bounds().height + - self.offset.y, ), Anchor::West => Point::new( - position.x + self.offset.x, - position.y + self.underlay_bounds.height / 2.0 - node.bounds().height / 2.0 + self.position.x + self.offset.x, + self.position.y + self.underlay_bounds.height / 2.0 - node.bounds().height / 2.0 + self.offset.y, ), }; @@ -171,6 +178,6 @@ where ) -> Option> { self.element .as_widget_mut() - .overlay(self.state, layout, renderer) + .overlay(self.state, layout, renderer, Vector::ZERO) } } diff --git a/src/native/overlay/modal.rs b/src/native/overlay/modal.rs index dc078e9e..b554d072 100644 --- a/src/native/overlay/modal.rs +++ b/src/native/overlay/modal.rs @@ -6,8 +6,8 @@ use iced_widget::core::{ mouse::{self, Cursor}, renderer, touch, widget::Tree, - Alignment, Border, Clipboard, Color, Element, Event, Layout, Overlay, Point, Rectangle, Shadow, - Shell, Size, Vector, + Alignment, Border, Clipboard, Color, Element, Event, Layout, Overlay, Rectangle, Shadow, Shell, + Size, }; use crate::style::modal::StyleSheet; @@ -69,13 +69,7 @@ where Renderer: core::Renderer, Theme: StyleSheet, { - fn layout( - &mut self, - renderer: &Renderer, - bounds: Size, - _position: Point, - _translation: Vector, - ) -> layout::Node { + fn layout(&mut self, renderer: &Renderer, bounds: Size) -> layout::Node { let limits = layout::Limits::new(Size::ZERO, bounds); let mut content = self .content diff --git a/src/native/overlay/time_picker.rs b/src/native/overlay/time_picker.rs index c73f328b..214c544b 100644 --- a/src/native/overlay/time_picker.rs +++ b/src/native/overlay/time_picker.rs @@ -121,7 +121,7 @@ where /// Turn this [`TimePickerOverlay`] into an overlay [`Element`](overlay::Element). #[must_use] pub fn overlay(self) -> overlay::Element<'a, Message, Theme, Renderer> { - overlay::Element::new(self.position, Box::new(self)) + overlay::Element::new(Box::new(self)) } /// The event handling for the clock. @@ -509,13 +509,7 @@ where Message: 'static + Clone, Theme: 'a + StyleSheet + button::StyleSheet + text::StyleSheet + container::StyleSheet, { - fn layout( - &mut self, - renderer: &Renderer, - bounds: Size, - position: Point, - _translation: Vector, - ) -> Node { + fn layout(&mut self, renderer: &Renderer, bounds: Size) -> Node { let limits = Limits::new(Size::ZERO, bounds) .shrink(Padding::from(PADDING)) .width(Length::Fill) @@ -603,7 +597,7 @@ where vec![clock, digital_clock, cancel_button, submit_button], ); - node.center_and_bounce(position, bounds); + node.center_and_bounce(self.position, bounds); node } diff --git a/src/native/split.rs b/src/native/split.rs index 0ede7cd8..3cecd24d 100644 --- a/src/native/split.rs +++ b/src/native/split.rs @@ -14,7 +14,7 @@ use iced_widget::{ Operation, Tree, }, Border, Clipboard, Color, Element, Event, Layout, Length, Padding, Point, Rectangle, - Shadow, Shell, Size, Widget, + Shadow, Shell, Size, Vector, Widget, }, Container, Row, }; @@ -498,6 +498,7 @@ where state: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { let mut children = layout.children(); let first_layout = children.next()?; @@ -513,11 +514,14 @@ where first .as_widget_mut() - .overlay(&mut first_state[0], first_layout, renderer) + .overlay(&mut first_state[0], first_layout, renderer, translation) .or_else(|| { - second - .as_widget_mut() - .overlay(&mut second_state[0], second_layout, renderer) + second.as_widget_mut().overlay( + &mut second_state[0], + second_layout, + renderer, + translation, + ) }) } } diff --git a/src/native/tabs.rs b/src/native/tabs.rs index b69ac6fa..0317c098 100644 --- a/src/native/tabs.rs +++ b/src/native/tabs.rs @@ -20,7 +20,7 @@ use iced_widget::{ tree::{State, Tag}, Operation, Tree, }, - Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Size, Widget, + Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Size, Vector, Widget, }, runtime::Font, text, Row, @@ -558,6 +558,7 @@ where state: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { let layout = match self.tab_bar_position { TabBarPosition::Top => layout.children().nth(1), @@ -569,7 +570,14 @@ where self.tabs .get_mut(idx) .map(Element::as_widget_mut) - .and_then(|w| w.overlay(&mut state.children[1].children[idx], layout, renderer)) + .and_then(|w| { + w.overlay( + &mut state.children[1].children[idx], + layout, + renderer, + translation, + ) + }) }) } diff --git a/src/native/time_picker.rs b/src/native/time_picker.rs index eb25b2a1..889ba2c3 100644 --- a/src/native/time_picker.rs +++ b/src/native/time_picker.rs @@ -13,7 +13,7 @@ use iced_widget::{ mouse::{self, Cursor}, overlay, renderer, widget::tree::{self, Tag, Tree}, - Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Widget, + Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget, }, renderer::Renderer, text, @@ -263,14 +263,17 @@ where state: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { let picker_state: &mut State = state.state.downcast_mut(); if !self.show_picker { - return self - .underlay - .as_widget_mut() - .overlay(&mut state.children[0], layout, renderer); + return self.underlay.as_widget_mut().overlay( + &mut state.children[0], + layout, + renderer, + translation, + ); } let bounds = layout.bounds(); diff --git a/src/native/wrap.rs b/src/native/wrap.rs index e82eb928..332b8ed6 100644 --- a/src/native/wrap.rs +++ b/src/native/wrap.rs @@ -8,7 +8,7 @@ use iced_widget::core::{ renderer, widget::{Operation, Tree}, Alignment, Clipboard, Element, Event, Layout, Length, Padding, Point, Rectangle, Shell, Size, - Widget, + Vector, Widget, }; use std::marker::PhantomData; @@ -217,13 +217,16 @@ where state: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option> { self.elements .iter_mut() .zip(&mut state.children) .zip(layout.children()) .find_map(|((child, state), layout)| { - child.as_widget_mut().overlay(state, layout, renderer) + child + .as_widget_mut() + .overlay(state, layout, renderer, translation) }) }