2019-11-25 14:17:13 +01:00
|
|
|
//! Configure your application.
|
2023-08-30 04:31:21 +02:00
|
|
|
use crate::{Font, Pixels};
|
2019-11-25 14:17:13 +01:00
|
|
|
|
2023-09-18 19:07:41 +02:00
|
|
|
use std::borrow::Cow;
|
2019-11-25 14:17:13 +01:00
|
|
|
|
2024-06-19 01:53:40 +02:00
|
|
|
/// The settings of an iced program.
|
2020-07-01 06:09:39 +02:00
|
|
|
#[derive(Debug, Clone)]
|
2024-06-19 01:53:40 +02:00
|
|
|
pub struct Settings {
|
2021-08-11 19:23:05 +07:00
|
|
|
/// The identifier of the application.
|
|
|
|
|
///
|
|
|
|
|
/// If provided, this identifier may be used to identify the application or
|
|
|
|
|
/// communicate with it through the windowing system.
|
|
|
|
|
pub id: Option<String>,
|
|
|
|
|
|
2023-09-18 19:07:41 +02:00
|
|
|
/// The fonts to load on boot.
|
|
|
|
|
pub fonts: Vec<Cow<'static, [u8]>>,
|
|
|
|
|
|
2023-02-04 07:33:33 +01:00
|
|
|
/// The default [`Font`] to be used.
|
2020-01-09 18:31:07 +01:00
|
|
|
///
|
2023-09-09 12:24:47 +02:00
|
|
|
/// By default, it uses [`Family::SansSerif`](crate::font::Family::SansSerif).
|
2023-02-04 07:33:33 +01:00
|
|
|
pub default_font: Font,
|
2020-02-15 10:08:27 +01:00
|
|
|
|
2020-06-19 00:08:28 +02:00
|
|
|
/// The text size that will be used by default.
|
|
|
|
|
///
|
2023-01-31 06:29:21 +01:00
|
|
|
/// The default value is `16.0`.
|
2023-08-30 04:31:21 +02:00
|
|
|
pub default_text_size: Pixels,
|
2020-06-19 00:08:28 +02:00
|
|
|
|
2020-02-18 09:54:24 +01:00
|
|
|
/// If set to true, the renderer will try to perform antialiasing for some
|
2020-02-15 10:08:27 +01:00
|
|
|
/// primitives.
|
|
|
|
|
///
|
|
|
|
|
/// Enabling it can produce a smoother result in some widgets, like the
|
2024-12-17 02:20:23 +01:00
|
|
|
/// `canvas` widget, at a performance cost.
|
2020-02-15 10:08:27 +01:00
|
|
|
///
|
2025-03-12 02:14:58 +01:00
|
|
|
/// By default, it is enabled.
|
2020-02-18 09:54:24 +01:00
|
|
|
pub antialiasing: bool,
|
2019-12-29 12:29:47 +01:00
|
|
|
}
|
|
|
|
|
|
2024-06-19 01:53:40 +02:00
|
|
|
impl Default for Settings {
|
2020-06-19 00:08:28 +02:00
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
2021-08-11 19:23:05 +07:00
|
|
|
id: None,
|
2023-10-27 03:58:45 +02:00
|
|
|
fonts: Vec::new(),
|
2023-09-20 04:51:08 +02:00
|
|
|
default_font: Font::default(),
|
2023-08-30 04:31:21 +02:00
|
|
|
default_text_size: Pixels(16.0),
|
2025-03-12 02:14:58 +01:00
|
|
|
antialiasing: true,
|
2020-04-06 01:14:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|