Stop leaking impl details in scrollable Renderer
This commit is contained in:
parent
be488ac738
commit
a3c55f7517
2 changed files with 16 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
column, input::mouse, Element, Event, Hasher, Layout, Node, Point, Style,
|
column, input::mouse, Element, Event, Hasher, Layout, Node, Point,
|
||||||
Widget,
|
Rectangle, Style, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use iced_core::scrollable::State;
|
pub use iced_core::scrollable::State;
|
||||||
|
|
@ -86,7 +86,16 @@ where
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
) -> Renderer::Output {
|
) -> 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) {
|
fn hash_layout(&self, state: &mut Hasher) {
|
||||||
|
|
@ -98,7 +107,8 @@ pub trait Renderer: crate::Renderer + Sized {
|
||||||
fn draw<Message>(
|
fn draw<Message>(
|
||||||
&mut self,
|
&mut self,
|
||||||
scrollable: &Scrollable<'_, Message, Self>,
|
scrollable: &Scrollable<'_, Message, Self>,
|
||||||
layout: Layout<'_>,
|
bounds: Rectangle,
|
||||||
|
content_layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
) -> Self::Output;
|
) -> Self::Output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,11 @@ impl scrollable::Renderer for Renderer {
|
||||||
fn draw<Message>(
|
fn draw<Message>(
|
||||||
&mut self,
|
&mut self,
|
||||||
scrollable: &Scrollable<'_, Message, Self>,
|
scrollable: &Scrollable<'_, Message, Self>,
|
||||||
layout: Layout<'_>,
|
bounds: Rectangle,
|
||||||
|
content: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
) -> Self::Output {
|
) -> Self::Output {
|
||||||
let bounds = layout.bounds();
|
|
||||||
let is_mouse_over = bounds.contains(cursor_position);
|
let is_mouse_over = bounds.contains(cursor_position);
|
||||||
|
|
||||||
let content = layout.children().next().unwrap();
|
|
||||||
let content_bounds = content.bounds();
|
let content_bounds = content.bounds();
|
||||||
|
|
||||||
let offset = scrollable.state.offset(bounds, content_bounds);
|
let offset = scrollable.state.offset(bounds, content_bounds);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue