iced_core/window/
settings.rs

1//! Configure your windows.
2#[cfg(target_os = "windows")]
3#[path = "settings/windows.rs"]
4pub mod 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 title bar has Close button or not
60    pub closeable: bool,
61
62    /// Whether the title bar has Minimize button or not
63    pub minimizable: bool,
64
65    /// Whether the window should have a border, a title bar, etc. or not.
66    pub decorations: bool,
67
68    /// Whether the window should be transparent.
69    pub transparent: bool,
70
71    /// Whether the window should have blurry background.
72    ///
73    /// Note that the blurry effect is applied to the transparent window. You need to enable
74    /// [`Settings::transparent`] and set a proper opacity value to the background color with
75    /// `Application::style`.
76    ///
77    /// This option is only supported on macOS and Linux. Please read the [winit document][winit]
78    /// for more details.
79    ///
80    /// [winit]: https://docs.rs/winit/0.30/winit/window/struct.Window.html#method.set_blur
81    pub blur: bool,
82
83    /// The window [`Level`].
84    pub level: Level,
85
86    /// The icon of the window.
87    pub icon: Option<Icon>,
88
89    /// Platform specific settings.
90    pub platform_specific: PlatformSpecific,
91
92    /// Whether the window will close when the user requests it, e.g. when a user presses the
93    /// close button.
94    ///
95    /// This can be useful if you want to have some behavior that executes before the window is
96    /// actually destroyed. If you disable this, you must manually close the window with the
97    /// `window::close` command.
98    ///
99    /// By default this is enabled.
100    pub exit_on_close_request: bool,
101}
102
103impl Default for Settings {
104    fn default() -> Self {
105        Self {
106            size: Size::new(1024.0, 768.0),
107            maximized: false,
108            fullscreen: false,
109            position: Position::default(),
110            min_size: None,
111            max_size: None,
112            visible: true,
113            resizable: true,
114            minimizable: true,
115            closeable: true,
116            decorations: true,
117            transparent: false,
118            blur: false,
119            level: Level::default(),
120            icon: None,
121            exit_on_close_request: true,
122            platform_specific: PlatformSpecific::default(),
123        }
124    }
125}