diff options
author | 2021-10-28 17:55:07 +0700 | |
---|---|---|
committer | 2021-10-28 18:04:30 +0700 | |
commit | d127dbd08ec314e6a2c65961134bdc7b28a1e4aa (patch) | |
tree | b17e63e5a3272d5fa271a69b1876b13e4915a257 /native | |
parent | e42e1e2f57ddb455ceff0017e215ddacca978d37 (diff) | |
download | iced-d127dbd08ec314e6a2c65961134bdc7b28a1e4aa.tar.gz iced-d127dbd08ec314e6a2c65961134bdc7b28a1e4aa.tar.bz2 iced-d127dbd08ec314e6a2c65961134bdc7b28a1e4aa.zip |
Fix scrollbar clipping in `Scrollable` draw logic
Diffstat (limited to 'native')
-rw-r--r-- | native/src/widget/scrollable.rs | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index 563ea370..4b514818 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -514,32 +514,39 @@ where let is_scrollbar_visible = style.background.is_some() || style.border_width > 0.0; - renderer.with_layer(bounds, |renderer| { - if is_scrollbar_visible { - renderer.fill_rectangle(renderer::Quad { - bounds: scrollbar.bounds, - background: style - .background - .unwrap_or(Background::Color(Color::TRANSPARENT)), - border_radius: style.border_radius, - border_width: style.border_width, - border_color: style.border_color, - }); - } + renderer.with_layer( + Rectangle { + width: bounds.width + 2.0, + height: bounds.height + 2.0, + ..bounds + }, + |renderer| { + if is_scrollbar_visible { + renderer.fill_rectangle(renderer::Quad { + bounds: scrollbar.bounds, + background: style.background.unwrap_or( + Background::Color(Color::TRANSPARENT), + ), + border_radius: style.border_radius, + border_width: style.border_width, + border_color: style.border_color, + }); + } - if is_mouse_over - || self.state.is_scroller_grabbed() - || is_scrollbar_visible - { - renderer.fill_rectangle(renderer::Quad { - bounds: scrollbar.scroller.bounds, - background: Background::Color(style.scroller.color), - border_radius: style.scroller.border_radius, - border_width: style.scroller.border_width, - border_color: style.scroller.border_color, - }); - } - }); + if is_mouse_over + || self.state.is_scroller_grabbed() + || is_scrollbar_visible + { + renderer.fill_rectangle(renderer::Quad { + bounds: scrollbar.scroller.bounds, + background: Background::Color(style.scroller.color), + border_radius: style.scroller.border_radius, + border_width: style.scroller.border_width, + border_color: style.scroller.border_color, + }); + } + }, + ); } else { self.content.draw( renderer, |