diff options
author | 2024-02-06 13:55:42 -0500 | |
---|---|---|
committer | 2024-02-12 19:03:32 +0100 | |
commit | 0f920e0435932c0b6927c771424b2ba495ddb46e (patch) | |
tree | 36ff23cfa2ec6ec82457e521f8ebaad7a99ebc32 /widget/src/scrollable.rs | |
parent | 891f29eea0cb32f0bee49fbace1757b82e1937f3 (diff) | |
download | iced-0f920e0435932c0b6927c771424b2ba495ddb46e.tar.gz iced-0f920e0435932c0b6927c771424b2ba495ddb46e.tar.bz2 iced-0f920e0435932c0b6927c771424b2ba495ddb46e.zip |
Introduce an appearance for a scrollable, ability to customize the scrollbar gap.
Update scrollable.rs
Diffstat (limited to 'widget/src/scrollable.rs')
-rw-r--r-- | widget/src/scrollable.rs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 207b2539..5c986757 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -15,7 +15,9 @@ use crate::core::{ }; use crate::runtime::Command; -pub use crate::style::scrollable::{Scrollbar, Scroller, StyleSheet}; +pub use crate::style::scrollable::{ + Appearance, Scrollbar, Scroller, StyleSheet, +}; pub use operation::scrollable::{AbsoluteOffset, RelativeOffset}; /// A widget that can vertically display an infinite amount of content with a @@ -878,6 +880,19 @@ pub fn draw<Theme, Renderer>( _ => mouse::Cursor::Unavailable, }; + // Draw background. + let appearence = theme.appearance(style); + + if let Some(background) = appearence.background { + renderer.fill_quad( + renderer::Quad { + bounds, + ..Default::default() + }, + background, + ); + } + // Draw inner content if scrollbars.active() { renderer.with_layer(bounds, |renderer| { @@ -971,6 +986,26 @@ pub fn draw<Theme, Renderer>( draw_scrollbar(renderer, style, &scrollbar); } + + //draw filler quad + if let (Some(x), Some(y)) = (scrollbars.x, scrollbars.y) { + let background = appearence.gap.or(appearence.background); + + if let Some(background) = background { + renderer.fill_quad( + renderer::Quad { + bounds: Rectangle { + x: y.bounds.x, + y: x.bounds.y, + width: y.bounds.width, + height: x.bounds.height, + }, + ..renderer::Quad::default() + }, + background, + ); + } + } }, ); } else { |