macOS: Implement with_resize_increments (#519)

Fixes #135
This commit is contained in:
Francesca Frangipane 2018-05-16 10:16:36 -04:00 committed by GitHub
parent 2464a135b3
commit 8440091a4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 13 deletions

View file

@ -42,8 +42,8 @@ const BACKEND_PREFERENCE_ENV_VAR: &str = "WINIT_UNIX_BACKEND";
pub struct PlatformSpecificWindowBuilderAttributes {
pub visual_infos: Option<XVisualInfo>,
pub screen_id: Option<i32>,
pub resize_increments: Option<(i32, i32)>,
pub base_size: Option<(i32, i32)>,
pub resize_increments: Option<(u32, u32)>,
pub base_size: Option<(u32, u32)>,
}
lazy_static!(

View file

@ -488,6 +488,7 @@ pub struct PlatformSpecificWindowBuilderAttributes {
pub titlebar_hidden: bool,
pub titlebar_buttons_hidden: bool,
pub fullsize_content_view: bool,
pub resize_increments: Option<(u32, u32)>,
}
pub struct Window2 {
@ -771,6 +772,13 @@ impl Window2 {
if pl_attrs.movable_by_window_background {
window.setMovableByWindowBackground_(YES);
}
if let Some((x, y)) = pl_attrs.resize_increments {
if x >= 1 && y >= 1 {
let size = NSSize::new(x as _, y as _);
window.setResizeIncrements_(size);
}
}
window.center();
window