diff options
author | 2020-10-22 16:05:44 -0500 | |
---|---|---|
committer | 2020-10-22 16:05:44 -0500 | |
commit | f05578c8f88b38cb538657e40c2feb725e72c7d8 (patch) | |
tree | 8a73a3cf39920bbd5dffaef7efcf609d5efc6fc0 /native | |
parent | 09e67c5c2701e7eeeb0bdb924966f8442c698b6a (diff) | |
download | iced-f05578c8f88b38cb538657e40c2feb725e72c7d8.tar.gz iced-f05578c8f88b38cb538657e40c2feb725e72c7d8.tar.bz2 iced-f05578c8f88b38cb538657e40c2feb725e72c7d8.zip |
Update scrollbar logic and introduce outer_bounds
Diffstat (limited to 'native')
-rw-r--r-- | native/src/widget/scrollable.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index 1cbc2bbf..cb181899 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -31,7 +31,7 @@ impl<'a, Message, Renderer: self::Renderer> Scrollable<'a, Message, Renderer> { height: Length::Shrink, max_height: u32::MAX, scrollbar_width: 10, - scrollbar_margin: 2, + scrollbar_margin: 0, scroller_width: 10, content: Column::new(), style: Renderer::Style::default(), @@ -459,6 +459,13 @@ impl State { /// [`Scrollable`]: struct.Scrollable.html #[derive(Debug)] pub struct Scrollbar { + /// The outer bounds of the scrollable, including the [`Scrollbar`] and + /// [`Scroller`]. + /// + /// [`Scrollbar`]: struct.Scrollbar.html + /// [`Scroller`]: struct.Scroller.html + pub outer_bounds: Rectangle, + /// The bounds of the [`Scrollbar`]. /// /// [`Scrollbar`]: struct.Scrollbar.html @@ -477,11 +484,11 @@ pub struct Scrollbar { impl Scrollbar { fn is_mouse_over(&self, cursor_position: Point) -> bool { - self.bounds.contains(cursor_position) + self.outer_bounds.contains(cursor_position) } fn grab_scroller(&self, cursor_position: Point) -> Option<f32> { - if self.bounds.contains(cursor_position) { + if self.outer_bounds.contains(cursor_position) { Some(if self.scroller.bounds.contains(cursor_position) { (cursor_position.y - self.scroller.bounds.y) / self.scroller.bounds.height |