diff options
author | 2019-10-29 02:13:22 +0100 | |
---|---|---|
committer | 2019-10-29 02:13:22 +0100 | |
commit | a3c55f75174f9bc87f80d7fe6236a71138d2fd77 (patch) | |
tree | e4e85df49a9e47f2a339437f61373d1539259f77 | |
parent | be488ac73837c9a741d900617840ee5c4ed74d61 (diff) | |
download | iced-a3c55f75174f9bc87f80d7fe6236a71138d2fd77.tar.gz iced-a3c55f75174f9bc87f80d7fe6236a71138d2fd77.tar.bz2 iced-a3c55f75174f9bc87f80d7fe6236a71138d2fd77.zip |
Stop leaking impl details in scrollable `Renderer`
Diffstat (limited to '')
-rw-r--r-- | native/src/widget/scrollable.rs | 18 | ||||
-rw-r--r-- | wgpu/src/renderer/scrollable.rs | 6 |
2 files changed, 16 insertions, 8 deletions
diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index 95e8c74d..f9d75863 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -1,6 +1,6 @@ use crate::{ - column, input::mouse, Element, Event, Hasher, Layout, Node, Point, Style, - Widget, + column, input::mouse, Element, Event, Hasher, Layout, Node, Point, + Rectangle, Style, Widget, }; pub use iced_core::scrollable::State; @@ -86,7 +86,16 @@ where layout: Layout<'_>, cursor_position: Point, ) -> Renderer::Output { - self::Renderer::draw(renderer, &self, layout, cursor_position) + let bounds = layout.bounds(); + let content_layout = layout.children().next().unwrap(); + + self::Renderer::draw( + renderer, + &self, + bounds, + content_layout, + cursor_position, + ) } fn hash_layout(&self, state: &mut Hasher) { @@ -98,7 +107,8 @@ pub trait Renderer: crate::Renderer + Sized { fn draw<Message>( &mut self, scrollable: &Scrollable<'_, Message, Self>, - layout: Layout<'_>, + bounds: Rectangle, + content_layout: Layout<'_>, cursor_position: Point, ) -> Self::Output; } diff --git a/wgpu/src/renderer/scrollable.rs b/wgpu/src/renderer/scrollable.rs index 43dddeed..1327e577 100644 --- a/wgpu/src/renderer/scrollable.rs +++ b/wgpu/src/renderer/scrollable.rs @@ -7,13 +7,11 @@ impl scrollable::Renderer for Renderer { fn draw<Message>( &mut self, scrollable: &Scrollable<'_, Message, Self>, - layout: Layout<'_>, + bounds: Rectangle, + content: Layout<'_>, cursor_position: Point, ) -> Self::Output { - let bounds = layout.bounds(); let is_mouse_over = bounds.contains(cursor_position); - - let content = layout.children().next().unwrap(); let content_bounds = content.bounds(); let offset = scrollable.state.offset(bounds, content_bounds); |