Make Shrink have priority over Fill in layout
This commit is contained in:
parent
68c0484b5c
commit
0655a20ad1
46 changed files with 264 additions and 273 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Padding, Vector};
|
||||
use crate::Vector;
|
||||
|
||||
/// An amount of space in 2 dimensions.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
@ -26,15 +26,7 @@ impl Size {
|
|||
/// A [`Size`] with infinite width and height.
|
||||
pub const INFINITY: Size = Size::new(f32::INFINITY, f32::INFINITY);
|
||||
|
||||
/// Increments the [`Size`] to account for the given padding.
|
||||
pub fn pad(&self, padding: Padding) -> Self {
|
||||
Size {
|
||||
width: self.width + padding.horizontal(),
|
||||
height: self.height + padding.vertical(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the minimum of each component of this size and another
|
||||
/// Returns the minimum of each component of this size and another.
|
||||
pub fn min(self, other: Self) -> Self {
|
||||
Size {
|
||||
width: self.width.min(other.width),
|
||||
|
|
@ -42,13 +34,23 @@ impl Size {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the maximum of each component of this size and another
|
||||
/// Returns the maximum of each component of this size and another.
|
||||
pub fn max(self, other: Self) -> Self {
|
||||
Size {
|
||||
width: self.width.max(other.width),
|
||||
height: self.height.max(other.height),
|
||||
}
|
||||
}
|
||||
|
||||
/// Expands this [`Size`] by the given amount.
|
||||
pub fn expand(self, other: impl Into<Size>) -> Self {
|
||||
let other = other.into();
|
||||
|
||||
Size {
|
||||
width: self.width + other.width,
|
||||
height: self.height + other.height,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<[f32; 2]> for Size {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue