summaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorLibravatar FinnPerry <finnperry3@gmail.com>2023-03-08 11:33:13 +1100
committerLibravatar FinnPerry <finnperry3@gmail.com>2023-03-08 11:44:08 +1100
commit046f3596ca88c1ad4c2941f2f74007684920e5d5 (patch)
treed7c5d74de0ab27f6c04704eec02ea5f9bd79ab3d /native/src
parentdf68cca0c9dda051ae979ccc2f5ca8d37c3e3cb5 (diff)
downloadiced-046f3596ca88c1ad4c2941f2f74007684920e5d5.tar.gz
iced-046f3596ca88c1ad4c2941f2f74007684920e5d5.tar.bz2
iced-046f3596ca88c1ad4c2941f2f74007684920e5d5.zip
fix: add `width` to scrollables
Diffstat (limited to 'native/src')
-rw-r--r--native/src/widget/scrollable.rs12
1 files changed, 10 insertions, 2 deletions
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<Id>,
+ width: Length,
height: Length,
vertical: Properties,
horizontal: Option<Properties>,
@@ -50,6 +51,7 @@ where
pub fn new(content: impl Into<Element<'a, Message, Renderer>>) -> 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<Length>) -> Self {
+ self.width = width.into();
+ self
+ }
+
/// Sets the height of the [`Scrollable`].
pub fn height(mut self, height: impl Into<Length>) -> 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::<Message, Renderer>::width(self),
+ self.width,
self.height,
self.horizontal.is_some(),
|renderer, limits| {