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::Size;
28use crate::window::{Icon, Level, Position};
29
30pub use platform::PlatformSpecific;
31
32/// The window settings of an application.
33#[derive(Debug, Clone)]
34pub struct Settings {
35    /// The initial logical dimensions of the window.
36    pub size: Size,
37
38    /// Whether the window should start maximized.
39    pub maximized: bool,
40
41    /// Whether the window should start fullscreen.
42    pub fullscreen: bool,
43
44    /// The initial position of the window.
45    pub position: Position,
46
47    /// The minimum size of the window.
48    pub min_size: Option<Size>,
49
50    /// The maximum size of the window.
51    pub max_size: Option<Size>,
52
53    /// Whether the window should be visible or not.
54    pub visible: bool,
55
56    /// Whether the window should be resizable or not.
57    pub resizable: bool,
58
59    /// Whether the window should have a border, a title bar, etc. or not.
60    pub decorations: bool,
61
62    /// Whether the window should be transparent.
63    pub transparent: bool,
64
65    /// The window [`Level`].
66    pub level: Level,
67
68    /// The icon of the window.
69    pub icon: Option<Icon>,
70
71    /// Platform specific settings.
72    pub platform_specific: PlatformSpecific,
73
74    /// Whether the window will close when the user requests it, e.g. when a user presses the
75    /// close button.
76    ///
77    /// This can be useful if you want to have some behavior that executes before the window is
78    /// actually destroyed. If you disable this, you must manually close the window with the
79    /// `window::close` command.
80    ///
81    /// By default this is enabled.
82    pub exit_on_close_request: bool,
83}
84
85impl Default for Settings {
86    fn default() -> Self {
87        Self {
88            size: Size::new(1024.0, 768.0),
89            maximized: false,
90            fullscreen: false,
91            position: Position::default(),
92            min_size: None,
93            max_size: None,
94            visible: true,
95            resizable: true,
96            decorations: true,
97            transparent: false,
98            level: Level::default(),
99            icon: None,
100            exit_on_close_request: true,
101            platform_specific: PlatformSpecific::default(),
102        }
103    }
104}