2023-11-29 22:28:31 +01:00
|
|
|
//! Configure your windows.
|
2023-07-12 19:21:05 -07:00
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
|
#[path = "settings/windows.rs"]
|
|
|
|
|
mod platform;
|
|
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
#[path = "settings/macos.rs"]
|
|
|
|
|
mod platform;
|
|
|
|
|
|
2023-11-29 22:28:31 +01:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
#[path = "settings/linux.rs"]
|
|
|
|
|
mod platform;
|
|
|
|
|
|
2023-07-12 19:21:05 -07:00
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
|
#[path = "settings/wasm.rs"]
|
|
|
|
|
mod platform;
|
|
|
|
|
|
|
|
|
|
#[cfg(not(any(
|
|
|
|
|
target_os = "windows",
|
|
|
|
|
target_os = "macos",
|
2023-11-29 22:28:31 +01:00
|
|
|
target_os = "linux",
|
2023-07-12 19:21:05 -07:00
|
|
|
target_arch = "wasm32"
|
|
|
|
|
)))]
|
|
|
|
|
#[path = "settings/other.rs"]
|
|
|
|
|
mod platform;
|
|
|
|
|
|
2023-11-29 22:28:31 +01:00
|
|
|
use crate::window::{Icon, Level, Position};
|
2023-11-30 23:40:33 +01:00
|
|
|
use crate::Size;
|
2023-02-23 14:33:53 +01:00
|
|
|
|
2023-11-29 22:28:31 +01:00
|
|
|
pub use platform::PlatformSpecific;
|
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 {
|
2023-11-30 23:40:33 +01:00
|
|
|
/// The initial logical dimensions of the window.
|
|
|
|
|
pub size: Size,
|
2020-01-16 05:54:22 +01:00
|
|
|
|
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.
|
2023-11-30 23:40:33 +01:00
|
|
|
pub min_size: Option<Size>,
|
2020-06-25 00:32:41 +02:00
|
|
|
|
|
|
|
|
/// The maximum size of the window.
|
2023-11-30 23:40:33 +01:00
|
|
|
pub max_size: Option<Size>,
|
2020-06-25 00:32:41 +02:00
|
|
|
|
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,
|
|
|
|
|
|
2023-05-25 23:14:07 +02:00
|
|
|
/// The window [`Level`].
|
|
|
|
|
pub level: Level,
|
2020-09-28 21:05:15 -07:00
|
|
|
|
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,
|
2023-07-24 14:32:59 -07:00
|
|
|
|
|
|
|
|
/// Whether the window will close when the user requests it, e.g. when a user presses the
|
|
|
|
|
/// close button.
|
|
|
|
|
///
|
|
|
|
|
/// This can be useful if you want to have some behavior that executes before the window is
|
|
|
|
|
/// actually destroyed. If you disable this, you must manually close the window with the
|
|
|
|
|
/// `window::close` command.
|
|
|
|
|
///
|
|
|
|
|
/// By default this is enabled.
|
|
|
|
|
pub exit_on_close_request: bool,
|
2020-01-16 05:54:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for Settings {
|
2023-11-29 22:28:31 +01:00
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
2023-11-30 23:40:33 +01:00
|
|
|
size: Size::new(1024.0, 768.0),
|
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,
|
2023-05-25 23:14:07 +02:00
|
|
|
level: Level::default(),
|
2020-04-11 15:16:10 +02:00
|
|
|
icon: None,
|
2023-07-24 14:32:59 -07:00
|
|
|
exit_on_close_request: true,
|
2023-09-20 04:51:08 +02:00
|
|
|
platform_specific: PlatformSpecific::default(),
|
2020-01-16 05:54:22 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|