diff options
author | 2021-11-29 16:22:01 +0700 | |
---|---|---|
committer | 2021-11-29 16:22:01 +0700 | |
commit | bbd9355450bc2df3a2c0e37cc900ba00b26255af (patch) | |
tree | a6cf758c934638e3dd9586781dfb62e1cf028572 /native/src/widget/scrollable.rs | |
parent | f7792d89d64c39cdde9da030bec80fb6f461a0e3 (diff) | |
download | iced-bbd9355450bc2df3a2c0e37cc900ba00b26255af.tar.gz iced-bbd9355450bc2df3a2c0e37cc900ba00b26255af.tar.bz2 iced-bbd9355450bc2df3a2c0e37cc900ba00b26255af.zip |
Introduce `Shell` type in `iced_native`
Widgets now can invalidate the current layout of the application on demand.
Diffstat (limited to '')
-rw-r--r-- | native/src/widget/scrollable.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index 2bf2ea5e..fac8af9e 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -8,7 +8,7 @@ use crate::touch; use crate::widget::Column; use crate::{ Alignment, Background, Clipboard, Color, Element, Hasher, Layout, Length, - Padding, Point, Rectangle, Size, Vector, Widget, + Padding, Point, Rectangle, Shell, Size, Vector, Widget, }; use std::{f32, hash::Hash, u32}; @@ -144,14 +144,14 @@ impl<'a, Message, Renderer: crate::Renderer> Scrollable<'a, Message, Renderer> { &self, bounds: Rectangle, content_bounds: Rectangle, - messages: &mut Vec<Message>, + shell: &mut Shell<'_, Message>, ) { if content_bounds.height <= bounds.height { return; } if let Some(on_scroll) = &self.on_scroll { - messages.push(on_scroll( + shell.publish(on_scroll( self.state.offset.absolute(bounds, content_bounds) / (content_bounds.height - bounds.height), )); @@ -251,7 +251,7 @@ where cursor_position: Point, renderer: &Renderer, clipboard: &mut dyn Clipboard, - messages: &mut Vec<Message>, + shell: &mut Shell<'_, Message>, ) -> event::Status { let bounds = layout.bounds(); let is_mouse_over = bounds.contains(cursor_position); @@ -286,7 +286,7 @@ where cursor_position, renderer, clipboard, - messages, + shell, ) }; @@ -307,7 +307,7 @@ where } } - self.notify_on_scroll(bounds, content_bounds, messages); + self.notify_on_scroll(bounds, content_bounds, shell); return event::Status::Captured; } @@ -336,7 +336,7 @@ where self.notify_on_scroll( bounds, content_bounds, - messages, + shell, ); } } @@ -377,7 +377,7 @@ where content_bounds, ); - self.notify_on_scroll(bounds, content_bounds, messages); + self.notify_on_scroll(bounds, content_bounds, shell); return event::Status::Captured; } @@ -409,7 +409,7 @@ where self.notify_on_scroll( bounds, content_bounds, - messages, + shell, ); return event::Status::Captured; |