From 470b966e8db539d17128e889b7f9b83eae9ddfc0 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 30 Oct 2023 14:33:45 -0400 Subject: [PATCH] feat(RectangleTracker): allow ignoring the bounds of a parent widget --- src/widget/rectangle_tracker/mod.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/widget/rectangle_tracker/mod.rs b/src/widget/rectangle_tracker/mod.rs index f307ff8eb90..507e1d817d1 100644 --- a/src/widget/rectangle_tracker/mod.rs +++ b/src/widget/rectangle_tracker/mod.rs @@ -71,6 +71,7 @@ where tx: UnboundedSender<(I, Rectangle)>, id: I, container: Container<'a, Message, Renderer>, + ignore_bounds: bool, } impl<'a, Message, Renderer, I> RectangleTrackingContainer<'a, Message, Renderer, I> @@ -88,6 +89,7 @@ where id, tx, container: Container::new(content), + ignore_bounds: false, } } @@ -160,6 +162,14 @@ where self.container = self.container.style(style); self } + + /// Set to true to ignore parent container bounds when performing layout. + /// This can be useful for widgets that are in auto-sized surfaces. + #[must_use] + pub fn ignore_bounds(mut self, ignore_bounds: bool) -> Self { + self.ignore_bounds = ignore_bounds; + self + } } impl<'a, Message, Renderer, I> Widget @@ -186,7 +196,14 @@ where } fn layout(&self, renderer: &Renderer, limits: &layout::Limits) -> layout::Node { - self.container.layout(renderer, limits) + self.container.layout( + renderer, + if self.ignore_bounds { + &layout::Limits::NONE + } else { + limits + }, + ) } fn operate(