Skip to content

Commit

Permalink
Add rounding to the size given to BoxConstraints::constrain. (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom authored Mar 22, 2020
1 parent 71596e8 commit 3eafd81
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions druid/src/box_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ impl BoxConstraints {
}
}

/// Clamp a given size so that fits within the constraints.
/// Clamp a given size so that it fits within the constraints.
///
/// The given size is also [rounded away from zero],
/// so that the layout is aligned to pixels.
///
/// [rounded away from zero]: struct.Size.html#method.expand
pub fn constrain(&self, size: impl Into<Size>) -> Size {
size.into().clamp(self.min, self.max)
size.into().expand().clamp(self.min, self.max)
}

/// Returns the max size of these constraints.
Expand Down

0 comments on commit 3eafd81

Please # to comment.