fix: update for applet widgets and grid
This commit is contained in:
parent
71e2c7c99e
commit
7554540b78
3 changed files with 76 additions and 73 deletions
|
|
@ -320,38 +320,25 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
self.children
|
||||
for (((i, child), state), c_layout) in self
|
||||
.children
|
||||
.iter_mut()
|
||||
.enumerate()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.map(|(((i, child), state), c_layout)| {
|
||||
let mut cursor_virtual = cursor;
|
||||
if matches!(
|
||||
event,
|
||||
Event::Mouse(mouse::Event::CursorMoved { .. } | mouse::Event::CursorEntered)
|
||||
| Event::Touch(
|
||||
iced_core::touch::Event::FingerMoved { .. }
|
||||
| iced_core::touch::Event::FingerPressed { .. }
|
||||
)
|
||||
) && cursor.is_over(c_layout.bounds())
|
||||
{
|
||||
my_state.hovered = Some(i);
|
||||
return child.as_widget_mut().update(
|
||||
state,
|
||||
&event,
|
||||
c_layout.with_virtual_offset(layout.virtual_offset()),
|
||||
cursor_virtual,
|
||||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
);
|
||||
} else if my_state.hovered.is_some_and(|h| i != h) {
|
||||
cursor_virtual = mouse::Cursor::Unavailable;
|
||||
}
|
||||
|
||||
child.as_widget_mut().update(
|
||||
{
|
||||
let mut cursor_virtual = cursor;
|
||||
if matches!(
|
||||
event,
|
||||
Event::Mouse(mouse::Event::CursorMoved { .. } | mouse::Event::CursorEntered)
|
||||
| Event::Touch(
|
||||
iced_core::touch::Event::FingerMoved { .. }
|
||||
| iced_core::touch::Event::FingerPressed { .. }
|
||||
)
|
||||
) && cursor.is_over(c_layout.bounds())
|
||||
{
|
||||
my_state.hovered = Some(i);
|
||||
return child.as_widget_mut().update(
|
||||
state,
|
||||
&event,
|
||||
c_layout.with_virtual_offset(layout.virtual_offset()),
|
||||
|
|
@ -360,8 +347,22 @@ where
|
|||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
)
|
||||
});
|
||||
);
|
||||
} else if my_state.hovered.is_some_and(|h| i != h) {
|
||||
cursor_virtual = mouse::Cursor::Unavailable;
|
||||
}
|
||||
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
&event,
|
||||
c_layout.with_virtual_offset(layout.virtual_offset()),
|
||||
cursor_virtual,
|
||||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn mouse_interaction(
|
||||
|
|
|
|||
|
|
@ -309,39 +309,26 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
self.children
|
||||
for (((i, child), state), c_layout) in self
|
||||
.children
|
||||
.iter_mut()
|
||||
.enumerate()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.map(|(((i, child), state), c_layout)| {
|
||||
let mut cursor_virtual = cursor;
|
||||
{
|
||||
let mut cursor_virtual = cursor;
|
||||
|
||||
if matches!(
|
||||
event,
|
||||
Event::Mouse(mouse::Event::CursorMoved { .. } | mouse::Event::CursorEntered)
|
||||
| Event::Touch(
|
||||
iced_core::touch::Event::FingerMoved { .. }
|
||||
| iced_core::touch::Event::FingerPressed { .. }
|
||||
)
|
||||
) && cursor.is_over(c_layout.bounds())
|
||||
{
|
||||
my_state.hovered = Some(i);
|
||||
return child.as_widget_mut().update(
|
||||
state,
|
||||
&event,
|
||||
c_layout.with_virtual_offset(layout.virtual_offset()),
|
||||
cursor_virtual,
|
||||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
);
|
||||
} else if my_state.hovered.is_some_and(|h| i != h) {
|
||||
cursor_virtual = mouse::Cursor::Unavailable;
|
||||
}
|
||||
|
||||
child.as_widget_mut().update(
|
||||
if matches!(
|
||||
event,
|
||||
Event::Mouse(mouse::Event::CursorMoved { .. } | mouse::Event::CursorEntered)
|
||||
| Event::Touch(
|
||||
iced_core::touch::Event::FingerMoved { .. }
|
||||
| iced_core::touch::Event::FingerPressed { .. }
|
||||
)
|
||||
) && cursor.is_over(c_layout.bounds())
|
||||
{
|
||||
my_state.hovered = Some(i);
|
||||
return child.as_widget_mut().update(
|
||||
state,
|
||||
&event,
|
||||
c_layout.with_virtual_offset(layout.virtual_offset()),
|
||||
|
|
@ -350,8 +337,22 @@ where
|
|||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
)
|
||||
});
|
||||
);
|
||||
} else if my_state.hovered.is_some_and(|h| i != h) {
|
||||
cursor_virtual = mouse::Cursor::Unavailable;
|
||||
}
|
||||
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
&event,
|
||||
c_layout.with_virtual_offset(layout.virtual_offset()),
|
||||
cursor_virtual,
|
||||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn mouse_interaction(
|
||||
|
|
|
|||
|
|
@ -189,22 +189,23 @@ impl<Message: 'static + Clone> Widget<Message, crate::Theme, Renderer> for Grid<
|
|||
shell: &mut Shell<'_, Message>,
|
||||
viewport: &Rectangle,
|
||||
) {
|
||||
self.children
|
||||
for ((child, state), c_layout) in self
|
||||
.children
|
||||
.iter_mut()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.map(|((child, state), c_layout)| {
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event,
|
||||
c_layout.with_virtual_offset(layout.virtual_offset()),
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
)
|
||||
});
|
||||
{
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event,
|
||||
c_layout.with_virtual_offset(layout.virtual_offset()),
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn mouse_interaction(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue