summaryrefslogtreecommitdiffstats
path: root/core/src/length.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-11 06:12:19 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-11 06:12:19 +0100
commit03c901d49b7cce901cfd76100f08dcff31420af8 (patch)
treef19e1708f3687edf20429dd493ab27d44a008305 /core/src/length.rs
parentfa53d9adbb0efbbe806a749476f83c04f756be75 (diff)
downloadiced-03c901d49b7cce901cfd76100f08dcff31420af8.tar.gz
iced-03c901d49b7cce901cfd76100f08dcff31420af8.tar.bz2
iced-03c901d49b7cce901cfd76100f08dcff31420af8.zip
Make `Button` sizing strategy adaptive
Diffstat (limited to 'core/src/length.rs')
-rw-r--r--core/src/length.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/src/length.rs b/core/src/length.rs
index 6dc15049..4c139895 100644
--- a/core/src/length.rs
+++ b/core/src/length.rs
@@ -42,6 +42,18 @@ impl Length {
pub fn is_fill(&self) -> bool {
self.fill_factor() != 0
}
+
+ /// Returns the "fluid" variant of the [`Length`].
+ ///
+ /// Specifically:
+ /// - [`Length::Shrink`] if [`Length::Shrink`] or [`Length::Fixed`].
+ /// - [`Length::Fill`] otherwise.
+ pub fn fluid(&self) -> Length {
+ match self {
+ Length::Fill | Length::FillPortion(_) => Length::Fill,
+ Length::Shrink | Length::Fixed(_) => Length::Shrink,
+ }
+ }
}
impl From<Pixels> for Length {