summaryrefslogtreecommitdiffstats
path: root/core/src/widget.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-16 12:02:42 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-16 12:02:42 +0100
commit534c7dd7b0bc515c31b6de87b4aa6a35b44c46a0 (patch)
tree0ddc8f1b681cbade7e47293bd46a362896aa538a /core/src/widget.rs
parent17135cbd56316f31167eb62e026839450506573f (diff)
parentc4ba657de86d7606587dad5124f435141258f570 (diff)
downloadiced-534c7dd7b0bc515c31b6de87b4aa6a35b44c46a0.tar.gz
iced-534c7dd7b0bc515c31b6de87b4aa6a35b44c46a0.tar.bz2
iced-534c7dd7b0bc515c31b6de87b4aa6a35b44c46a0.zip
Merge branch 'master' into update-winit
Diffstat (limited to 'core/src/widget.rs')
-rw-r--r--core/src/widget.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/src/widget.rs b/core/src/widget.rs
index 294d5984..7f5632ae 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.
///
@@ -43,11 +43,16 @@ pub trait Widget<Message, Renderer>
where
Renderer: crate::Renderer,
{
- /// Returns the width of the [`Widget`].
- fn width(&self) -> Length;
+ /// Returns the [`Size`] of the [`Widget`] in lengths.
+ fn size(&self) -> Size<Length>;
- /// 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> {
+ self.size()
+ }
/// Returns the [`layout::Node`] of the [`Widget`].
///