macOS: Add `movable_by_window_background` option to viewport (#5412)
Add an option called `movable_by_window_background` alongside a new builder method. When set to true, the window is movable by dragging its background ([Apple Docs](https://developer.apple.com/documentation/appkit/nswindow/ismovablebywindowbackground)) This is exclusive to macOS systems, similar to `fullsize_content_view`. * [x] I have followed the instructions in the PR template
This commit is contained in:
parent
52732b23a6
commit
d54e29d375
|
|
@ -1615,6 +1615,7 @@ pub fn create_winit_window_attributes(
|
|||
|
||||
// macOS:
|
||||
fullsize_content_view: _fullsize_content_view,
|
||||
movable_by_window_background: _movable_by_window_background,
|
||||
title_shown: _title_shown,
|
||||
titlebar_buttons_shown: _titlebar_buttons_shown,
|
||||
titlebar_shown: _titlebar_shown,
|
||||
|
|
@ -1761,7 +1762,8 @@ pub fn create_winit_window_attributes(
|
|||
.with_title_hidden(!_title_shown.unwrap_or(true))
|
||||
.with_titlebar_buttons_hidden(!_titlebar_buttons_shown.unwrap_or(true))
|
||||
.with_titlebar_transparent(!_titlebar_shown.unwrap_or(true))
|
||||
.with_fullsize_content_view(_fullsize_content_view.unwrap_or(false));
|
||||
.with_fullsize_content_view(_fullsize_content_view.unwrap_or(false))
|
||||
.with_movable_by_window_background(_movable_by_window_background.unwrap_or(false));
|
||||
}
|
||||
|
||||
window_attributes
|
||||
|
|
|
|||
|
|
@ -291,6 +291,7 @@ pub struct ViewportBuilder {
|
|||
|
||||
// macOS:
|
||||
pub fullsize_content_view: Option<bool>,
|
||||
pub movable_by_window_background: Option<bool>,
|
||||
pub title_shown: Option<bool>,
|
||||
pub titlebar_buttons_shown: Option<bool>,
|
||||
pub titlebar_shown: Option<bool>,
|
||||
|
|
@ -432,6 +433,15 @@ impl ViewportBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// macOS: Set to `true` to allow the window to be moved by dragging the background.
|
||||
///
|
||||
/// Enabling this feature can result in unexpected behaviour with draggable UI widgets such as sliders.
|
||||
#[inline]
|
||||
pub fn with_movable_by_background(mut self, value: bool) -> Self {
|
||||
self.movable_by_window_background = Some(value);
|
||||
self
|
||||
}
|
||||
|
||||
/// macOS: Set to `false` to hide the window title.
|
||||
#[inline]
|
||||
pub fn with_title_shown(mut self, title_shown: bool) -> Self {
|
||||
|
|
@ -640,6 +650,7 @@ impl ViewportBuilder {
|
|||
visible: new_visible,
|
||||
drag_and_drop: new_drag_and_drop,
|
||||
fullsize_content_view: new_fullsize_content_view,
|
||||
movable_by_window_background: new_movable_by_window_background,
|
||||
title_shown: new_title_shown,
|
||||
titlebar_buttons_shown: new_titlebar_buttons_shown,
|
||||
titlebar_shown: new_titlebar_shown,
|
||||
|
|
@ -825,6 +836,13 @@ impl ViewportBuilder {
|
|||
recreate_window = true;
|
||||
}
|
||||
|
||||
if new_movable_by_window_background.is_some()
|
||||
&& self.movable_by_window_background != new_movable_by_window_background
|
||||
{
|
||||
self.movable_by_window_background = new_movable_by_window_background;
|
||||
recreate_window = true;
|
||||
}
|
||||
|
||||
if new_drag_and_drop.is_some() && self.drag_and_drop != new_drag_and_drop {
|
||||
self.drag_and_drop = new_drag_and_drop;
|
||||
recreate_window = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue