summaryrefslogtreecommitdiffstats
path: root/widget/src/scrollable.rs
diff options
context:
space:
mode:
authorLibravatar Cory Forsstrom <cforsstrom18@gmail.com>2023-07-15 10:04:25 -0700
committerLibravatar Cory Forsstrom <cforsstrom18@gmail.com>2023-07-15 10:04:25 -0700
commit42c423b4a89613c4e1c552c891c1391a34837122 (patch)
treecd724464d59619f63ea24a0476cb342b0eca4caa /widget/src/scrollable.rs
parente462f48a5a0b5023c3ca52e23698f5e9b25d86dd (diff)
downloadiced-42c423b4a89613c4e1c552c891c1391a34837122.tar.gz
iced-42c423b4a89613c4e1c552c891c1391a34837122.tar.bz2
iced-42c423b4a89613c4e1c552c891c1391a34837122.zip
Add viewport to Widget::on_event
Diffstat (limited to 'widget/src/scrollable.rs')
-rw-r--r--widget/src/scrollable.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index e0aeeebd..f621fb26 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -278,6 +278,7 @@ where
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
+ _viewport: &Rectangle,
) -> event::Status {
update(
tree.state.downcast_mut::<State>(),
@@ -288,7 +289,7 @@ where
shell,
self.direction,
&self.on_scroll,
- |event, layout, cursor, clipboard, shell| {
+ |event, layout, cursor, clipboard, shell, viewport| {
self.content.as_widget_mut().on_event(
&mut tree.children[0],
event,
@@ -297,6 +298,7 @@ where
renderer,
clipboard,
shell,
+ viewport,
)
},
)
@@ -492,6 +494,7 @@ pub fn update<Message>(
mouse::Cursor,
&mut dyn Clipboard,
&mut Shell<'_, Message>,
+ &Rectangle,
) -> event::Status,
) -> event::Status {
let bounds = layout.bounds();
@@ -518,7 +521,20 @@ pub fn update<Message>(
_ => mouse::Cursor::Unavailable,
};
- update_content(event.clone(), content, cursor, clipboard, shell)
+ let translation = state.translation(direction, bounds, content_bounds);
+
+ update_content(
+ event.clone(),
+ content,
+ cursor,
+ clipboard,
+ shell,
+ &Rectangle {
+ y: bounds.y + translation.y,
+ x: bounds.x + translation.x,
+ ..bounds
+ },
+ )
};
if let event::Status::Captured = event_status {