diff options
author | 2024-07-18 22:39:49 +0200 | |
---|---|---|
committer | 2024-07-18 22:39:49 +0200 | |
commit | 23ad15391c88f562c90f4344d3949f76b6f9caf9 (patch) | |
tree | 883f5752e3cfe516ee22048015e9255b502bb04e /widget/src/scrollable.rs | |
parent | 616689ca54942a13aac3615e571ae995ad4571b6 (diff) | |
parent | 06acb740fba1889c6a9fb48dfa3ae3aaac1df3ab (diff) | |
download | iced-23ad15391c88f562c90f4344d3949f76b6f9caf9.tar.gz iced-23ad15391c88f562c90f4344d3949f76b6f9caf9.tar.bz2 iced-23ad15391c88f562c90f4344d3949f76b6f9caf9.zip |
Merge pull request #2508 from iced-rs/feature/rich-text
`rich_text` and `markdown` widgets
Diffstat (limited to 'widget/src/scrollable.rs')
-rw-r--r-- | widget/src/scrollable.rs | 18 |
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 } |