diff options
author | 2024-01-12 14:41:40 +0100 | |
---|---|---|
committer | 2024-01-12 14:41:40 +0100 | |
commit | 50c310fd9f692eafb2350827636ffbd6d7b6c9b9 (patch) | |
tree | 0f1ab4182a0cce7469e01881c095e0c3988b3f9a /core/src/length.rs | |
parent | 63e9adac56e9a4f21ec82137329d7c455fbf630b (diff) | |
parent | 11474bdc3e1a43e6c167d7b98f22d87933dbd2b6 (diff) | |
download | iced-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.rs | 18 |
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 { |