Skip to content

Commit

Permalink
Added macOS platform specific options
Browse files Browse the repository at this point in the history
  • Loading branch information
casperstorm authored and hecrj committed Mar 14, 2023
1 parent de4ae51 commit ed7b613
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ pub mod icon;

pub use icon::Icon;
pub use position::Position;
pub use settings::Settings;
pub use settings::{PlatformSpecific, Settings};

pub use crate::runtime::window::*;
18 changes: 17 additions & 1 deletion src/window/settings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
use crate::window::{Icon, Position};

#[cfg(target_os = "macos")]
#[path = "settings/macos.rs"]
mod platform;

#[cfg(not(target_os = "macos"))]
#[path = "settings/other.rs"]
mod platform;

pub use platform::PlatformSpecific;

/// The window settings of an application.
#[derive(Debug, Clone)]
pub struct Settings {
Expand Down Expand Up @@ -32,6 +42,9 @@ pub struct Settings {

/// The icon of the window.
pub icon: Option<Icon>,

/// Platform specific settings.
pub platform_specific: platform::PlatformSpecific,
}

impl Default for Settings {
Expand All @@ -47,6 +60,7 @@ impl Default for Settings {
transparent: false,
always_on_top: false,
icon: None,
platform_specific: Default::default(),
}
}
}
Expand All @@ -64,7 +78,9 @@ impl From<Settings> for iced_winit::settings::Window {
transparent: settings.transparent,
always_on_top: settings.always_on_top,
icon: settings.icon.map(Icon::into),
platform_specific: Default::default(),
platform_specific: iced_winit::settings::PlatformSpecific::from(
settings.platform_specific,
),
}
}
}
20 changes: 20 additions & 0 deletions src/window/settings/macos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// The platform specific window settings of an application.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct PlatformSpecific {
/// Hides the window title.
pub title_hidden: bool,
/// Makes the titlebar transparent and allows the content to appear behind it.
pub titlebar_transparent: bool,
/// Makes the window content appear behind the titlebar.
pub fullsize_content_view: bool,
}

impl From<PlatformSpecific> for iced_winit::settings::PlatformSpecific {
fn from(platform_specific: PlatformSpecific) -> Self {
Self {
title_hidden: platform_specific.title_hidden,
titlebar_transparent: platform_specific.titlebar_transparent,
fullsize_content_view: platform_specific.fullsize_content_view,
}
}
}
9 changes: 9 additions & 0 deletions src/window/settings/other.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// The platform specific window settings of an application.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct PlatformSpecific;

impl From<PlatformSpecific> for iced_winit::settings::PlatformSpecific {
fn from(_: PlatformSpecific) -> Self {
Default::default()
}
}

0 comments on commit ed7b613

Please sign in to comment.