From e621c631f59859cc4cd80c64e1510399fa4aa55a Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Sun, 12 Jan 2025 22:11:47 +0000 Subject: [PATCH] more mac window config --- src/app_handle.rs | 9 +++++++++ src/window.rs | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/app_handle.rs b/src/app_handle.rs index c62ddcf4..0ce18f09 100644 --- a/src/app_handle.rs +++ b/src/app_handle.rs @@ -395,9 +395,15 @@ impl ApplicationHandle { if let Some(val) = mac.titlebar_hidden { window_attributes = window_attributes.with_titlebar_hidden(val); } + if let Some(val) = mac.title_hidden { + window_attributes = window_attributes.with_title_hidden(val); + } if let Some(val) = mac.full_size_content_view { window_attributes = window_attributes.with_fullsize_content_view(val); } + if let Some(val) = mac.unified_titlebar { + window_attributes = window_attributes.with_unified_titlebar(val); + } if let Some(val) = mac.movable { window_attributes = window_attributes.with_movable_by_window_background(val); } @@ -423,6 +429,9 @@ impl ApplicationHandle { if let Some(hide) = mac.titlebar_buttons_hidden { window_attributes = window_attributes.with_titlebar_buttons_hidden(hide) } + if let Some(panel) = mac.panel { + window_attributes = window_attributes.with_panel(panel) + } } let Ok(window) = event_loop.create_window(window_attributes) else { diff --git a/src/window.rs b/src/window.rs index c3a95e26..aa7c524a 100644 --- a/src/window.rs +++ b/src/window.rs @@ -251,8 +251,10 @@ pub struct MacOSWindowConfig { pub(crate) movable_by_window_background: Option, pub(crate) titlebar_transparent: Option, pub(crate) titlebar_hidden: Option, + pub(crate) title_hidden: Option, pub(crate) titlebar_buttons_hidden: Option, pub(crate) full_size_content_view: Option, + pub(crate) unified_titlebar: Option, pub(crate) movable: Option, pub(crate) traffic_lights_offset: Option<(f64, f64)>, pub(crate) accepts_first_mouse: Option, @@ -260,6 +262,7 @@ pub struct MacOSWindowConfig { pub(crate) option_as_alt: Option, pub(crate) has_shadow: Option, pub(crate) disallow_high_dpi: Option, + pub(crate) panel: Option, } impl MacOSWindowConfig { @@ -282,6 +285,12 @@ impl MacOSWindowConfig { self } + /// Hides the title. + pub fn hide_title(mut self, val: bool) -> Self { + self.title_hidden = Some(val); + self + } + /// Hides the title bar buttons. pub fn hide_titlebar_buttons(mut self, val: bool) -> Self { self.titlebar_buttons_hidden = Some(val); @@ -294,6 +303,12 @@ impl MacOSWindowConfig { self } + /// unify the titlebar + pub fn unified_titlebar(mut self, val: bool) -> Self { + self.unified_titlebar = Some(val); + self + } + /// Allow the window to be moved or not. pub fn movable(mut self, val: bool) -> Self { self.movable = Some(val); @@ -341,6 +356,12 @@ impl MacOSWindowConfig { self.disallow_high_dpi = Some(val); self } + + /// Set whether the window is a panel + pub fn panel(mut self, val: bool) -> Self { + self.panel = Some(val); + self + } } /// macOS specific configuration for how the Option key is treated