summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-04-23 02:29:04 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-04-23 02:29:48 +0200
commit67e181ce7bad516d2ff8fc34c989af2435fdc7b4 (patch)
tree0988bf1698b13f42efc2ccdba6ecae00ea4b46c8
parent15e15700ab456db5f3b14f9f7946c5cde28a6fec (diff)
downloadiced-67e181ce7bad516d2ff8fc34c989af2435fdc7b4.tar.gz
iced-67e181ce7bad516d2ff8fc34c989af2435fdc7b4.tar.bz2
iced-67e181ce7bad516d2ff8fc34c989af2435fdc7b4.zip
Fix clip bounds with nested `scrollable` widgets
-rw-r--r--widget/src/scrollable.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index 668c5372..626cd07f 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -659,6 +659,10 @@ where
let content_layout = layout.children().next().unwrap();
let content_bounds = content_layout.bounds();
+ let Some(visible_bounds) = bounds.intersection(viewport) else {
+ return;
+ };
+
let scrollbars =
Scrollbars::new(state, self.direction, bounds, content_bounds);
@@ -704,7 +708,7 @@ where
// Draw inner content
if scrollbars.active() {
- renderer.with_layer(bounds, |renderer| {
+ renderer.with_layer(visible_bounds, |renderer| {
renderer.with_translation(
Vector::new(-translation.x, -translation.y),
|renderer| {
@@ -767,9 +771,9 @@ where
renderer.with_layer(
Rectangle {
- width: (bounds.width + 2.0).min(viewport.width),
- height: (bounds.height + 2.0).min(viewport.height),
- ..bounds
+ width: (visible_bounds.width + 2.0).min(viewport.width),
+ height: (visible_bounds.height + 2.0).min(viewport.height),
+ ..visible_bounds
},
|renderer| {
if let Some(scrollbar) = scrollbars.y {