diff options
author | 2020-10-22 14:07:07 -0500 | |
---|---|---|
committer | 2020-10-22 14:07:07 -0500 | |
commit | 09e67c5c2701e7eeeb0bdb924966f8442c698b6a (patch) | |
tree | b46bec5f9bea50e74d83a31eed67499004048137 /graphics | |
parent | 23647d2f50f0e177b93cf09c72886a90702df982 (diff) | |
download | iced-09e67c5c2701e7eeeb0bdb924966f8442c698b6a.tar.gz iced-09e67c5c2701e7eeeb0bdb924966f8442c698b6a.tar.bz2 iced-09e67c5c2701e7eeeb0bdb924966f8442c698b6a.zip |
Replace hard-coded params with struct members
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/src/widget/scrollable.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/graphics/src/widget/scrollable.rs b/graphics/src/widget/scrollable.rs index b149db0a..0a3191fa 100644 --- a/graphics/src/widget/scrollable.rs +++ b/graphics/src/widget/scrollable.rs @@ -15,9 +15,6 @@ pub use iced_style::scrollable::{Scrollbar, Scroller, StyleSheet}; pub type Scrollable<'a, Message, Backend> = iced_native::Scrollable<'a, Message, Renderer<Backend>>; -const SCROLLBAR_WIDTH: u16 = 10; -const SCROLLBAR_MARGIN: u16 = 2; - impl<B> scrollable::Renderer for Renderer<B> where B: Backend, @@ -29,13 +26,16 @@ where bounds: Rectangle, content_bounds: Rectangle, offset: u32, + scrollbar_width: u16, + scrollbar_margin: u16, + _scroller_width: u16, ) -> Option<scrollable::Scrollbar> { if content_bounds.height > bounds.height { let scrollbar_bounds = Rectangle { x: bounds.x + bounds.width - - f32::from(SCROLLBAR_WIDTH + 2 * SCROLLBAR_MARGIN), + - f32::from(scrollbar_width + 2 * scrollbar_margin), y: bounds.y, - width: f32::from(SCROLLBAR_WIDTH + 2 * SCROLLBAR_MARGIN), + width: f32::from(scrollbar_width + 2 * scrollbar_margin), height: bounds.height, }; @@ -44,14 +44,15 @@ where let y_offset = offset as f32 * ratio; let scroller_bounds = Rectangle { - x: scrollbar_bounds.x + f32::from(SCROLLBAR_MARGIN), + x: scrollbar_bounds.x + f32::from(scrollbar_margin), y: scrollbar_bounds.y + y_offset, - width: scrollbar_bounds.width - f32::from(2 * SCROLLBAR_MARGIN), + width: scrollbar_bounds.width - f32::from(2 * scrollbar_margin), height: scrollbar_height, }; Some(scrollable::Scrollbar { bounds: scrollbar_bounds, + margin: scrollbar_margin, scroller: scrollable::Scroller { bounds: scroller_bounds, }, @@ -110,9 +111,9 @@ where let scrollbar = if is_scrollbar_visible { Primitive::Quad { bounds: Rectangle { - x: scrollbar.bounds.x + f32::from(SCROLLBAR_MARGIN), + x: scrollbar.bounds.x + f32::from(scrollbar.margin), width: scrollbar.bounds.width - - f32::from(2 * SCROLLBAR_MARGIN), + - f32::from(2 * scrollbar.margin), ..scrollbar.bounds }, background: style |