Make Button sizing strategy adaptive

This commit is contained in:
Héctor Ramón Jiménez 2024-01-11 06:12:19 +01:00
parent fa53d9adbb
commit 03c901d49b
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 20 additions and 13 deletions

View file

@ -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 {