Added macOS platform specific options
This commit is contained in:
parent
de4ae51e3c
commit
ed7b613804
4 changed files with 47 additions and 2 deletions
|
|
@ -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::*;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -47,6 +60,7 @@ impl Default for Settings {
|
|||
transparent: false,
|
||||
always_on_top: false,
|
||||
icon: None,
|
||||
platform_specific: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
src/window/settings/macos.rs
Normal file
20
src/window/settings/macos.rs
Normal file
|
|
@ -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
src/window/settings/other.rs
Normal file
9
src/window/settings/other.rs
Normal file
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue