summaryrefslogtreecommitdiffstats
path: root/core/src/length.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-01-12 14:41:40 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-12 14:41:40 +0100
commit50c310fd9f692eafb2350827636ffbd6d7b6c9b9 (patch)
tree0f1ab4182a0cce7469e01881c095e0c3988b3f9a /core/src/length.rs
parent63e9adac56e9a4f21ec82137329d7c455fbf630b (diff)
parent11474bdc3e1a43e6c167d7b98f22d87933dbd2b6 (diff)
downloadiced-50c310fd9f692eafb2350827636ffbd6d7b6c9b9.tar.gz
iced-50c310fd9f692eafb2350827636ffbd6d7b6c9b9.tar.bz2
iced-50c310fd9f692eafb2350827636ffbd6d7b6c9b9.zip
Merge pull request #2192 from iced-rs/fix/layout-inconsistencies
Layout consistency
Diffstat (limited to 'core/src/length.rs')
-rw-r--r--core/src/length.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/src/length.rs b/core/src/length.rs
index 3adb996e..4c139895 100644
--- a/core/src/length.rs
+++ b/core/src/length.rs
@@ -36,6 +36,24 @@ impl Length {
Length::Fixed(_) => 0,
}
}
+
+ /// Returns `true` iff the [`Length`] is either [`Length::Fill`] or
+ // [`Length::FillPortion`].
+ 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 {