Remove now redundant Overlay::is_over

The `mouse_interaction` method can be properly used
now to encode hover status with the `None` and `Idle`
variants.
This commit is contained in:
Héctor Ramón Jiménez 2025-05-02 21:23:17 +02:00
parent a01beefa84
commit 9e934fe2a7
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
15 changed files with 92 additions and 256 deletions

View file

@ -443,6 +443,7 @@ mod toast {
let toasts = (!self.toasts.is_empty()).then(|| {
overlay::Element::new(Box::new(Overlay {
position: layout.bounds().position() + translation,
viewport: *viewport,
toasts: &mut self.toasts,
state: toasts_state,
instants,
@ -460,6 +461,7 @@ mod toast {
struct Overlay<'a, 'b, Message> {
position: Point,
viewport: Rectangle,
toasts: &'b mut [Element<'a, Message>],
state: &'b mut [Tree],
instants: &'b mut [Option<Instant>],
@ -595,7 +597,6 @@ mod toast {
&self,
layout: Layout<'_>,
cursor: mouse::Cursor,
viewport: &Rectangle,
renderer: &Renderer,
) -> mouse::Interaction {
self.toasts
@ -603,24 +604,25 @@ mod toast {
.zip(self.state.iter())
.zip(layout.children())
.map(|((child, state), layout)| {
child.as_widget().mouse_interaction(
state, layout, cursor, viewport, renderer,
)
child
.as_widget()
.mouse_interaction(
state,
layout,
cursor,
&self.viewport,
renderer,
)
.max(
cursor
.is_over(layout.bounds())
.then_some(mouse::Interaction::Idle)
.unwrap_or_default(),
)
})
.max()
.unwrap_or_default()
}
fn is_over(
&self,
layout: Layout<'_>,
_renderer: &Renderer,
cursor_position: Point,
) -> bool {
layout
.children()
.any(|layout| layout.bounds().contains(cursor_position))
}
}
impl<'a, Message> From<Manager<'a, Message>> for Element<'a, Message>