Skip to content

Commit

Permalink
more mac window config
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhou121 committed Jan 12, 2025
1 parent 5ab32a2 commit e621c63
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/app_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 {
Expand Down
21 changes: 21 additions & 0 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,18 @@ pub struct MacOSWindowConfig {
pub(crate) movable_by_window_background: Option<bool>,
pub(crate) titlebar_transparent: Option<bool>,
pub(crate) titlebar_hidden: Option<bool>,
pub(crate) title_hidden: Option<bool>,
pub(crate) titlebar_buttons_hidden: Option<bool>,
pub(crate) full_size_content_view: Option<bool>,
pub(crate) unified_titlebar: Option<bool>,
pub(crate) movable: Option<bool>,
pub(crate) traffic_lights_offset: Option<(f64, f64)>,
pub(crate) accepts_first_mouse: Option<bool>,
pub(crate) tabbing_identifier: Option<String>,
pub(crate) option_as_alt: Option<MacOsOptionAsAlt>,
pub(crate) has_shadow: Option<bool>,
pub(crate) disallow_high_dpi: Option<bool>,
pub(crate) panel: Option<bool>,
}

impl MacOSWindowConfig {
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e621c63

Please sign in to comment.