summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-02-27 01:37:13 +0100
committerLibravatar GitHub <noreply@github.com>2024-02-27 01:37:13 +0100
commit8bb1587a748f2c579ce8ea7f5c584cf4a6361e83 (patch)
treecd22dde1af966ab886169e234f6feedf373b80f6 /core
parentf6f0c01546543ee7fee7048de5d59de9059e9b60 (diff)
parent01fbd5049d09b44369b7cd1f283c473afda5d2be (diff)
downloadiced-8bb1587a748f2c579ce8ea7f5c584cf4a6361e83.tar.gz
iced-8bb1587a748f2c579ce8ea7f5c584cf4a6361e83.tar.bz2
iced-8bb1587a748f2c579ce8ea7f5c584cf4a6361e83.zip
Merge pull request #2298 from iced-rs/fix/row-column-fluidity
Fix `Column` and `Row` fluidity being overridden by `push`
Diffstat (limited to '')
-rw-r--r--core/src/length.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/src/length.rs b/core/src/length.rs
index 4c139895..5f24169f 100644
--- a/core/src/length.rs
+++ b/core/src/length.rs
@@ -48,12 +48,21 @@ impl Length {
/// Specifically:
/// - [`Length::Shrink`] if [`Length::Shrink`] or [`Length::Fixed`].
/// - [`Length::Fill`] otherwise.
- pub fn fluid(&self) -> Length {
+ pub fn fluid(&self) -> Self {
match self {
Length::Fill | Length::FillPortion(_) => Length::Fill,
Length::Shrink | Length::Fixed(_) => Length::Shrink,
}
}
+
+ /// Adapts the [`Length`] so it can contain the other [`Length`] and
+ /// match its fluidity.
+ pub fn enclose(self, other: Length) -> Self {
+ match (self, other) {
+ (Length::Shrink, Length::Fill | Length::FillPortion(_)) => other,
+ _ => self,
+ }
+ }
}
impl From<Pixels> for Length {