iced_core/window/
settings.rs

1//! Configure your windows.
2#[cfg(target_os = "windows")]
3#[path = "settings/windows.rs"]
4mod platform;
5
6#[cfg(target_os = "macos")]
7#[path = "settings/macos.rs"]
8mod platform;
9
10#[cfg(target_os = "linux")]
11#[path = "settings/linux.rs"]
12mod platform;
13
14#[cfg(target_arch = "wasm32")]
15#[path = "settings/wasm.rs"]
16mod platform;
17
18#[cfg(not(any(
19    target_os = "windows",
20    target_os = "macos",
21    target_os = "linux",
22    target_arch = "wasm32"
23)))]
24#[path = "settings/other.rs"]
25mod platform;
26
27use crate::window::{Icon, Level, Position};
28use crate::Size;
29
30pub use platform::PlatformSpecific;
31/// The window settings of an application.
32#[derive(Debug, Clone)]
33pub struct Settings {
34    /// The initial logical dimensions of the window.
35    pub size: Size,
36
37    /// The initial position of the window.
38    pub position: Position,
39
40    /// The minimum size of the window.
41    pub min_size: Option<Size>,
42
43    /// The maximum size of the window.
44    pub max_size: Option<Size>,
45
46    /// Whether the window should be visible or not.
47    pub visible: bool,
48
49    /// Whether the window should be resizable or not.
50    pub resizable: bool,
51
52    /// Whether the window should have a border, a title bar, etc. or not.
53    pub decorations: bool,
54
55    /// Whether the window should be transparent.
56    pub transparent: bool,
57
58    /// The window [`Level`].
59    pub level: Level,
60
61    /// The icon of the window.
62    pub icon: Option<Icon>,
63
64    /// Platform specific settings.
65    pub platform_specific: PlatformSpecific,
66
67    /// Whether the window will close when the user requests it, e.g. when a user presses the
68    /// close button.
69    ///
70    /// This can be useful if you want to have some behavior that executes before the window is
71    /// actually destroyed. If you disable this, you must manually close the window with the
72    /// `window::close` command.
73    ///
74    /// By default this is enabled.
75    pub exit_on_close_request: bool,
76}
77
78impl Default for Settings {
79    fn default() -> Self {
80        Self {
81            size: Size::new(1024.0, 768.0),
82            position: Position::default(),
83            min_size: None,
84            max_size: None,
85            visible: true,
86            resizable: true,
87            decorations: true,
88            transparent: false,
89            level: Level::default(),
90            icon: None,
91            exit_on_close_request: true,
92            platform_specific: PlatformSpecific::default(),
93        }
94    }
95}