iced_core/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, like the
32 /// `canvas` widget, at a performance cost.
33 ///
34 /// By default, it is enabled.
35 pub antialiasing: bool,
36
37 /// Whether or not to attempt to synchronize rendering when possible.
38 ///
39 /// Disabling it can improve rendering performance on some platforms.
40 ///
41 /// By default, it is enabled.
42 pub vsync: bool,
43}
44
45impl Default for Settings {
46 fn default() -> Self {
47 Self {
48 id: None,
49 fonts: Vec::new(),
50 default_font: Font::default(),
51 default_text_size: Pixels(16.0),
52 antialiasing: true,
53 vsync: true,
54 }
55 }
56}