refactor: track virtual offset in the layout

This commit is contained in:
Ashley Wulber 2025-03-20 10:10:02 -04:00 committed by Michael Murphy
parent 91eae67dd5
commit a3525ef56e
9 changed files with 200 additions and 78 deletions

View file

@ -131,7 +131,11 @@ where
operation.container(Some(&self.id), layout.bounds(), &mut |operation| {
self.content.as_widget().operate(
&mut tree.children[0],
layout.children().next().unwrap(),
layout
.children()
.next()
.unwrap()
.with_virtual_offset(layout.virtual_offset()),
renderer,
operation,
);
@ -165,7 +169,11 @@ where
self.content.as_widget_mut().on_event(
&mut tree.children[0],
event.clone(),
layout.children().next().unwrap(),
layout
.children()
.next()
.unwrap()
.with_virtual_offset(layout.virtual_offset()),
cursor_position,
renderer,
clipboard,
@ -185,7 +193,7 @@ where
let content_layout = layout.children().next().unwrap();
self.content.as_widget().mouse_interaction(
&tree.children[0],
content_layout,
content_layout.with_virtual_offset(layout.virtual_offset()),
cursor_position,
viewport,
renderer,
@ -208,7 +216,7 @@ where
renderer,
theme,
renderer_style,
content_layout,
content_layout.with_virtual_offset(layout.virtual_offset()),
cursor_position,
viewport,
);
@ -223,7 +231,11 @@ where
) -> Option<overlay::Element<'b, Message, Theme, Renderer>> {
self.content.as_widget_mut().overlay(
&mut tree.children[0],
layout.children().next().unwrap(),
layout
.children()
.next()
.unwrap()
.with_virtual_offset(layout.virtual_offset()),
renderer,
translation,
)
@ -239,7 +251,7 @@ where
let content_layout = layout.children().next().unwrap();
self.content.as_widget().drag_destinations(
&state.children[0],
content_layout,
content_layout.with_virtual_offset(layout.virtual_offset()),
renderer,
dnd_rectangles,
);
@ -263,7 +275,11 @@ where
) -> iced_accessibility::A11yTree {
let c_layout = layout.children().next().unwrap();
let c_state = &state.children[0];
self.content.as_widget().a11y_nodes(c_layout, c_state, p)
self.content.as_widget().a11y_nodes(
c_layout.with_virtual_offset(layout.virtual_offset()),
c_state,
p,
)
}
}