Windows: respect min/max sizes when creating the window (#2393)
This commit is contained in:
parent
c53a574bff
commit
6b7ceedc91
3 changed files with 34 additions and 2 deletions
23
src/dpi.rs
23
src/dpi.rs
|
|
@ -511,6 +511,29 @@ impl Size {
|
|||
Size::Logical(size) => size.to_physical(scale_factor),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clamp<S: Into<Size>>(input: S, min: S, max: S, scale_factor: f64) -> Size {
|
||||
let (input, min, max) = (
|
||||
input.into().to_physical::<f64>(scale_factor),
|
||||
min.into().to_physical::<f64>(scale_factor),
|
||||
max.into().to_physical::<f64>(scale_factor),
|
||||
);
|
||||
|
||||
let clamp = |input: f64, min: f64, max: f64| {
|
||||
if input < min {
|
||||
min
|
||||
} else if input > max {
|
||||
max
|
||||
} else {
|
||||
input
|
||||
}
|
||||
};
|
||||
|
||||
let width = clamp(input.width, min.width, max.width);
|
||||
let height = clamp(input.height, min.height, max.height);
|
||||
|
||||
PhysicalSize::new(width, height).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: Pixel> From<PhysicalSize<P>> for Size {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue