feat: add overflow option to Pin widget to allow content beyond boundaries

This commit is contained in:
Inuxiuz 2026-07-11 16:49:55 +08:00 • committed by Michael Murphy
parent ba4f09b7bf
commit dc0e80edd8

View file

@ -60,6 +60,7 @@ where
width: Length,
height: Length,
position: Point,
overflow: bool,
}
impl<'a, Message, Theme, Renderer> Pin<'a, Message, Theme, Renderer>
@ -75,6 +76,7 @@ where
width: Length::Fill,
height: Length::Fill,
position: Point::ORIGIN,
overflow: false,
}
}
@ -107,6 +109,12 @@ where
self.position.y = y.into().0;
self
}
/// Sets whether the [`Pin`] can overflow its boundaries.
pub fn overflow(mut self, overflow: bool) -> Self {
self.overflow = overflow;
self
}
}
impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer>
@ -146,7 +154,11 @@ where
let limits = limits.width(self.width).height(self.height);
let available =
limits.max() - Size::new(self.position.x, self.position.y);
if self.overflow {
limits.max()
} else {
limits.max() - Size::new(self.position.x, self.position.y)
};
let node = self
.content