diff options
author | 2024-01-05 17:24:43 +0100 | |
---|---|---|
committer | 2024-01-10 10:01:49 +0100 | |
commit | 22226394f7b1a0e0205b9bb5b3ef9b85a3b406f5 (patch) | |
tree | 22214a4ac6bca5033f6d5a227934288019f6ca60 /core/src/widget.rs | |
parent | 0322e820eb40d36a7425246278b7bcb22b7010aa (diff) | |
download | iced-22226394f7b1a0e0205b9bb5b3ef9b85a3b406f5.tar.gz iced-22226394f7b1a0e0205b9bb5b3ef9b85a3b406f5.tar.bz2 iced-22226394f7b1a0e0205b9bb5b3ef9b85a3b406f5.zip |
Introduce `Widget::size_hint` and fix further layout inconsistencies
Diffstat (limited to 'core/src/widget.rs')
-rw-r--r-- | core/src/widget.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/src/widget.rs b/core/src/widget.rs index 294d5984..890b3773 100644 --- a/core/src/widget.rs +++ b/core/src/widget.rs @@ -15,7 +15,7 @@ use crate::layout::{self, Layout}; use crate::mouse; use crate::overlay; use crate::renderer; -use crate::{Clipboard, Length, Rectangle, Shell}; +use crate::{Clipboard, Length, Rectangle, Shell, Size}; /// A component that displays information and allows interaction. /// @@ -49,6 +49,14 @@ where /// Returns the height of the [`Widget`]. fn height(&self) -> Length; + /// Returns a [`Size`] hint for laying out the [`Widget`]. + /// + /// This hint may be used by some widget containers to adjust their sizing strategy + /// during construction. + fn size_hint(&self) -> Size<Length> { + Size::new(self.width(), self.height()) + } + /// Returns the [`layout::Node`] of the [`Widget`]. /// /// This [`layout::Node`] is used by the runtime to compute the [`Layout`] of the |