refactor: include virtual offset in Layout

This commit is contained in:
Ashley Wulber 2025-03-19 23:11:48 -04:00
parent 7120db60ba
commit 5b0468e535
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
10 changed files with 251 additions and 98 deletions

View file

@ -239,10 +239,10 @@ where
.iter_mut()
.zip(&mut tree.children)
.zip(layout.children())
.for_each(|((child, state), layout)| {
.for_each(|((child, state), c_layout)| {
child
.as_widget_mut()
.operate(state, layout, renderer, operation);
.operate(state, c_layout.with_virtual_offset(layout.virtual_offset()), renderer, operation);
});
});
}
@ -258,14 +258,14 @@ where
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
) {
for ((child, tree), layout) in self
for ((child, tree), c_layout) in self
.children
.iter_mut()
.zip(&mut tree.children)
.zip(layout.children())
{
child.as_widget_mut().update(
tree, event, layout, cursor, renderer, clipboard, shell,
tree, event, c_layout.with_virtual_offset(layout.virtual_offset()), cursor, renderer, clipboard, shell,
viewport,
);
}
@ -283,10 +283,10 @@ where
.iter()
.zip(&tree.children)
.zip(layout.children())
.map(|((child, tree), layout)| {
.map(|((child, tree), c_layout)| {
child
.as_widget()
.mouse_interaction(tree, layout, cursor, viewport, renderer)
.mouse_interaction(tree, c_layout.with_virtual_offset(layout.virtual_offset()), cursor, viewport, renderer)
})
.max()
.unwrap_or_default()
@ -309,7 +309,7 @@ where
viewport
};
for ((child, tree), layout) in self
for ((child, tree), c_layout) in self
.children
.iter()
.zip(&tree.children)
@ -317,7 +317,7 @@ where
.filter(|(_, layout)| layout.bounds().intersects(viewport))
{
child.as_widget().draw(
tree, renderer, theme, style, layout, cursor, viewport,
tree, renderer, theme, style, c_layout.with_virtual_offset(layout.virtual_offset()), cursor, viewport,
);
}
}
@ -356,7 +356,11 @@ where
.zip(layout.children())
.zip(state.children.iter())
.map(|((c, c_layout), state)| {
c.as_widget().a11y_nodes(c_layout, state, cursor)
c.as_widget().a11y_nodes(
c_layout.with_virtual_offset(layout.virtual_offset()),
state,
cursor,
)
}),
)
}
@ -368,7 +372,7 @@ where
renderer: &Renderer,
dnd_rectangles: &mut crate::core::clipboard::DndDestinationRectangles,
) {
for ((e, layout), state) in self
for ((e, c_layout), state) in self
.children
.iter()
.zip(layout.children())
@ -376,7 +380,7 @@ where
{
e.as_widget().drag_destinations(
state,
layout,
c_layout.with_virtual_offset(layout.virtual_offset()),
renderer,
dnd_rectangles,
);