iced/
settings.rs

1//! Configure your application.
2use crate::{Font, Pixels};
3
4use std::borrow::Cow;
5
6/// The settings of an iced program.
7#[derive(Debug, Clone)]
8pub struct Settings {
9    /// The identifier of the application.
10    ///
11    /// If provided, this identifier may be used to identify the application or
12    /// communicate with it through the windowing system.
13    pub id: Option<String>,
14
15    /// The fonts to load on boot.
16    pub fonts: Vec<Cow<'static, [u8]>>,
17
18    /// The default [`Font`] to be used.
19    ///
20    /// By default, it uses [`Family::SansSerif`](crate::font::Family::SansSerif).
21    pub default_font: Font,
22
23    /// The text size that will be used by default.
24    ///
25    /// The default value is `16.0`.
26    pub default_text_size: Pixels,
27
28    /// If set to true, the renderer will try to perform antialiasing for some
29    /// primitives.
30    ///
31    /// Enabling it can produce a smoother result in some widgets
32    ///
33    /// By default, it is disabled.
34    pub antialiasing: bool,
35
36    /// If set to true the application will exit when the main window is closed.
37    pub exit_on_close_request: bool,
38
39    /// Whether the application is a daemon
40    pub is_daemon: bool,
41}
42
43impl Default for Settings {
44    fn default() -> Self {
45        Self {
46            id: None,
47            fonts: Vec::new(),
48            default_font: Font::default(),
49            default_text_size: Pixels(14.0),
50            antialiasing: false,
51            exit_on_close_request: false,
52            is_daemon: false,
53        }
54    }
55}
56
57#[cfg(feature = "winit")]
58impl From<Settings> for iced_winit::Settings {
59    fn from(settings: Settings) -> iced_winit::Settings {
60        iced_winit::Settings {
61            id: settings.id,
62            fonts: settings.fonts,
63            is_daemon: settings.is_daemon,
64        }
65    }
66}