Skip to content

Commit

Permalink
feat(RectangleTracker): allow ignoring the bounds of a parent widget
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Oct 30, 2023
1 parent a946e7e commit 46dc02d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/widget/rectangle_tracker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -88,6 +89,7 @@ where
id,
tx,
container: Container::new(content),
ignore_bounds: false,
}
}

Expand Down Expand Up @@ -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<Message, Renderer>
Expand All @@ -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(
Expand Down

0 comments on commit 46dc02d

Please sign in to comment.