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