Adapt scrollable sizing strategy to contents
This commit is contained in:
parent
904704d7c1
commit
aa62fa2ce9
2 changed files with 17 additions and 12 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue