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