mirror of
https://github.com/tauri-apps/tao.git
synced 2026-01-31 00:35:16 +01:00
feat(macos): add setters to set title bar style on macOS (#926)
* feat(macos): add setters to set title bar style on macOS * fix: bool to BOOL
This commit is contained in:
5
.changes/feat-set-title-bar-style.md
Normal file
5
.changes/feat-set-title-bar-style.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'tao': patch
|
||||
---
|
||||
|
||||
On macOS, add `set_fullsize_content_view` and `set_titlebar_transparent` to `Window` to set the title bar style.
|
||||
@@ -74,6 +74,16 @@ pub trait WindowExtMacOS {
|
||||
|
||||
/// Returns the window's tabbing identifier.
|
||||
fn tabbing_identifier(&self) -> String;
|
||||
|
||||
/// The content view consumes the full size of the window.
|
||||
///
|
||||
/// <https://developer.apple.com/documentation/appkit/nsfullsizecontentviewwindowmask>
|
||||
fn set_fullsize_content_view(&self, fullsize: bool);
|
||||
|
||||
/// A Boolean value that indicates whether the title bar draws its background.
|
||||
///
|
||||
/// <https://developer.apple.com/documentation/appkit/nswindow/1419167-titlebarappearstransparent>
|
||||
fn set_titlebar_transparent(&self, transparent: bool);
|
||||
}
|
||||
|
||||
impl WindowExtMacOS for Window {
|
||||
@@ -141,6 +151,16 @@ impl WindowExtMacOS for Window {
|
||||
fn tabbing_identifier(&self) -> String {
|
||||
self.window.tabbing_identifier()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_fullsize_content_view(&self, fullsize: bool) {
|
||||
self.window.set_fullsize_content_view(fullsize);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_titlebar_transparent(&self, transparent: bool) {
|
||||
self.window.set_titlebar_transparent(transparent);
|
||||
}
|
||||
}
|
||||
|
||||
/// Corresponds to `NSApplicationActivationPolicy`.
|
||||
|
||||
@@ -1613,6 +1613,26 @@ impl WindowExtMacOS for UnownedWindow {
|
||||
ns_string_to_rust(tabbing_identifier)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_fullsize_content_view(&self, fullsize: bool) {
|
||||
let mut mask = unsafe { self.ns_window.styleMask() };
|
||||
if fullsize {
|
||||
mask |= NSWindowStyleMask::NSFullSizeContentViewWindowMask;
|
||||
} else {
|
||||
mask &= !NSWindowStyleMask::NSFullSizeContentViewWindowMask;
|
||||
}
|
||||
self.set_style_mask_sync(mask);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_titlebar_transparent(&self, transparent: bool) {
|
||||
unsafe {
|
||||
self
|
||||
.ns_window
|
||||
.setTitlebarAppearsTransparent_(transparent as BOOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for UnownedWindow {
|
||||
|
||||
Reference in New Issue
Block a user