From e5afaa08924cb0f34789b5a7de1720dc91978923 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 6 Sep 2023 21:50:59 -0400 Subject: [PATCH] Add access to bounds/content bounds from a scrollable viewport. (#2072) * Add access to bounds/content bounds from a scrollable viewport in order to perform certain scrollable optimizations as a consumer. * Move bounds/content_bounds after relative_offset as per feedback. --- widget/src/scrollable.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index a83ed985ce..d0c77e6b55 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -1146,6 +1146,16 @@ impl Viewport { RelativeOffset { x, y } } + + /// Returns the bounds of the current [`Viewport`]. + pub fn bounds(&self) -> Rectangle { + self.bounds + } + + /// Returns the content bounds of the current [`Viewport`]. + pub fn content_bounds(&self) -> Rectangle { + self.content_bounds + } } impl State {