2021-07-21 18:59:24 +07:00
|
|
|
use crate::window::{Icon, Position};
|
2020-07-01 06:09:39 +02:00
|
|
|
|
2023-03-14 11:22:06 +01:00
|
|
|
pub use iced_winit::settings::PlatformSpecific;
|
2023-02-23 14:33:53 +01:00
|
|
|
|
2020-01-16 05:54:22 +01:00
|
|
|
/// The window settings of an application.
|
2020-07-01 06:09:39 +02:00
|
|
|
#[derive(Debug, Clone)]
|
2020-01-16 05:54:22 +01:00
|
|
|
pub struct Settings {
|
2020-06-25 00:32:41 +02:00
|
|
|
/// The initial size of the window.
|
2020-01-16 05:54:22 +01:00
|
|
|
pub size: (u32, u32),
|
|
|
|
|
|
2021-06-25 17:16:44 +02:00
|
|
|
/// The initial position of the window.
|
2021-07-21 18:59:24 +07:00
|
|
|
pub position: Position,
|
2021-06-25 17:16:44 +02:00
|
|
|
|
2020-06-25 00:32:41 +02:00
|
|
|
/// The minimum size of the window.
|
|
|
|
|
pub min_size: Option<(u32, u32)>,
|
|
|
|
|
|
|
|
|
|
/// The maximum size of the window.
|
|
|
|
|
pub max_size: Option<(u32, u32)>,
|
|
|
|
|
|
2022-07-18 18:37:41 +02:00
|
|
|
/// Whether the window should be visible or not.
|
|
|
|
|
pub visible: bool,
|
|
|
|
|
|
2020-01-16 05:54:22 +01:00
|
|
|
/// Whether the window should be resizable or not.
|
|
|
|
|
pub resizable: bool,
|
|
|
|
|
|
|
|
|
|
/// Whether the window should have a border, a title bar, etc. or not.
|
|
|
|
|
pub decorations: bool,
|
2020-04-11 15:16:10 +02:00
|
|
|
|
2020-09-28 21:05:15 -07:00
|
|
|
/// Whether the window should be transparent.
|
2020-08-17 15:38:02 +07:00
|
|
|
pub transparent: bool,
|
|
|
|
|
|
2020-09-28 21:05:15 -07:00
|
|
|
/// Whether the window will always be on top of other windows.
|
|
|
|
|
pub always_on_top: bool,
|
|
|
|
|
|
2020-07-01 06:09:39 +02:00
|
|
|
/// The icon of the window.
|
|
|
|
|
pub icon: Option<Icon>,
|
2023-02-23 14:33:53 +01:00
|
|
|
|
|
|
|
|
/// Platform specific settings.
|
2023-03-14 11:22:06 +01:00
|
|
|
pub platform_specific: PlatformSpecific,
|
2020-01-16 05:54:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for Settings {
|
|
|
|
|
fn default() -> Settings {
|
|
|
|
|
Settings {
|
|
|
|
|
size: (1024, 768),
|
2021-07-21 18:59:24 +07:00
|
|
|
position: Position::default(),
|
2020-06-25 00:32:41 +02:00
|
|
|
min_size: None,
|
|
|
|
|
max_size: None,
|
2022-07-18 18:37:41 +02:00
|
|
|
visible: true,
|
2020-01-16 05:54:22 +01:00
|
|
|
resizable: true,
|
|
|
|
|
decorations: true,
|
2020-08-17 15:38:02 +07:00
|
|
|
transparent: false,
|
2020-09-28 21:05:15 -07:00
|
|
|
always_on_top: false,
|
2020-04-11 15:16:10 +02:00
|
|
|
icon: None,
|
2023-02-23 14:33:53 +01:00
|
|
|
platform_specific: Default::default(),
|
2020-01-16 05:54:22 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-25 00:32:41 +02:00
|
|
|
|
|
|
|
|
impl From<Settings> for iced_winit::settings::Window {
|
|
|
|
|
fn from(settings: Settings) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
size: settings.size,
|
2021-07-21 18:59:24 +07:00
|
|
|
position: iced_winit::Position::from(settings.position),
|
2020-06-25 00:32:41 +02:00
|
|
|
min_size: settings.min_size,
|
|
|
|
|
max_size: settings.max_size,
|
2022-07-18 18:37:41 +02:00
|
|
|
visible: settings.visible,
|
2020-06-25 00:32:41 +02:00
|
|
|
resizable: settings.resizable,
|
|
|
|
|
decorations: settings.decorations,
|
2020-08-17 15:38:02 +07:00
|
|
|
transparent: settings.transparent,
|
2020-09-28 21:05:15 -07:00
|
|
|
always_on_top: settings.always_on_top,
|
2020-07-01 06:09:39 +02:00
|
|
|
icon: settings.icon.map(Icon::into),
|
2023-03-14 11:22:06 +01:00
|
|
|
platform_specific: settings.platform_specific,
|
2020-06-25 00:32:41 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|