summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-02-25 21:43:32 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-25 21:43:32 +0100
commitbe8102ea3b65431cd58b239d61ac3474508a638d (patch)
tree703954bfcc28e4d568061ab88b7f933d177f5441 /core/src
parentf07fdba0b1620dfc04f2690c2f04dd4aaf543023 (diff)
parent871b7e0311c73358213aae6326973300f0b56faa (diff)
downloadiced-be8102ea3b65431cd58b239d61ac3474508a638d.tar.gz
iced-be8102ea3b65431cd58b239d61ac3474508a638d.tar.bz2
iced-be8102ea3b65431cd58b239d61ac3474508a638d.zip
Merge pull request #1734 from iced-rs/fix/padding-fit
Fix `Padding::fit` on irregular values for an axis
Diffstat (limited to 'core/src')
-rw-r--r--core/src/padding.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/src/padding.rs b/core/src/padding.rs
index 752b2b86..0b1bba13 100644
--- a/core/src/padding.rs
+++ b/core/src/padding.rs
@@ -77,12 +77,14 @@ impl Padding {
/// Fits the [`Padding`] between the provided `inner` and `outer` [`Size`].
pub fn fit(self, inner: Size, outer: Size) -> Self {
let available = (outer - inner).max(Size::ZERO);
+ let new_top = self.top.min(available.height);
+ let new_left = self.left.min(available.width);
Padding {
- top: self.top.min(available.height / 2.0),
- right: self.right.min(available.width / 2.0),
- bottom: self.bottom.min(available.height / 2.0),
- left: self.left.min(available.width / 2.0),
+ top: new_top,
+ bottom: self.bottom.min(available.height - new_top),
+ left: new_left,
+ right: self.right.min(available.width - new_left),
}
}
}