From 046f3596ca88c1ad4c2941f2f74007684920e5d5 Mon Sep 17 00:00:00 2001 From: FinnPerry Date: Wed, 8 Mar 2023 11:33:13 +1100 Subject: fix: add `width` to scrollables --- native/src/widget/scrollable.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index c1df8c39..45cd2a0e 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -33,6 +33,7 @@ where Renderer::Theme: StyleSheet, { id: Option, + width: Length, height: Length, vertical: Properties, horizontal: Option, @@ -50,6 +51,7 @@ where pub fn new(content: impl Into>) -> Self { Scrollable { id: None, + width: Length::Shrink, height: Length::Shrink, vertical: Properties::default(), horizontal: None, @@ -65,6 +67,12 @@ where self } + /// Sets the width of the [`Scrollable`]. + pub fn width(mut self, width: impl Into) -> Self { + self.width = width.into(); + self + } + /// Sets the height of the [`Scrollable`]. pub fn height(mut self, height: impl Into) -> Self { self.height = height.into(); @@ -173,7 +181,7 @@ where } fn width(&self) -> Length { - self.content.as_widget().width() + self.width } fn height(&self) -> Length { @@ -188,7 +196,7 @@ where layout( renderer, limits, - Widget::::width(self), + self.width, self.height, self.horizontal.is_some(), |renderer, limits| { -- cgit