summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-07-18 13:22:53 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-07-18 13:22:53 +0200
commitaa62fa2ce992949d20ddbe8683ed2be0d922a568 (patch)
treed46b2946b9bc2add8c1396de036ee51074d95b0d /widget
parent904704d7c1b006c850654dcf3bf9e856e23cb317 (diff)
downloadiced-aa62fa2ce992949d20ddbe8683ed2be0d922a568.tar.gz
iced-aa62fa2ce992949d20ddbe8683ed2be0d922a568.tar.bz2
iced-aa62fa2ce992949d20ddbe8683ed2be0d922a568.zip
Adapt `scrollable` sizing strategy to contents
Diffstat (limited to '')
-rw-r--r--widget/src/scrollable.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index b1082203..6dd593cb 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -62,19 +62,27 @@ where
.validate()
}
- fn validate(self) -> Self {
+ fn validate(mut self) -> Self {
+ let size_hint = self.content.as_widget().size_hint();
+
debug_assert!(
- self.direction.vertical().is_none()
- || !self.content.as_widget().size_hint().height.is_fill(),
+ self.direction.vertical().is_none() || !size_hint.height.is_fill(),
"scrollable content must not fill its vertical scrolling axis"
);
debug_assert!(
- self.direction.horizontal().is_none()
- || !self.content.as_widget().size_hint().width.is_fill(),
+ self.direction.horizontal().is_none() || !size_hint.width.is_fill(),
"scrollable content must not fill its horizontal scrolling axis"
);
+ if self.direction.horizontal().is_none() {
+ self.width = self.width.enclose(size_hint.width);
+ }
+
+ if self.direction.vertical().is_none() {
+ self.height = self.height.enclose(size_hint.height);
+ }
+
self
}