2020-05-28 01:46:17 +02:00
|
|
|
//! Configure a renderer.
|
2020-05-19 20:34:17 +02:00
|
|
|
pub use iced_graphics::Antialiasing;
|
2020-05-19 14:23:28 +02:00
|
|
|
|
2020-11-25 07:11:27 +01:00
|
|
|
/// The settings of a [`Backend`].
|
2020-05-19 14:23:28 +02:00
|
|
|
///
|
2020-11-25 07:11:27 +01:00
|
|
|
/// [`Backend`]: crate::Backend
|
2020-06-01 22:07:29 +02:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
2020-05-19 14:23:28 +02:00
|
|
|
pub struct Settings {
|
|
|
|
|
/// The bytes of the font that will be used by default.
|
|
|
|
|
///
|
|
|
|
|
/// If `None` is provided, a default system font will be chosen.
|
|
|
|
|
pub default_font: Option<&'static [u8]>,
|
|
|
|
|
|
2020-06-19 00:08:28 +02:00
|
|
|
/// The default size of text.
|
|
|
|
|
///
|
|
|
|
|
/// By default, it will be set to 20.
|
|
|
|
|
pub default_text_size: u16,
|
|
|
|
|
|
2021-07-22 18:21:50 +07:00
|
|
|
/// If enabled, spread text workload in multiple threads when multiple cores
|
|
|
|
|
/// are available.
|
2021-07-22 18:27:33 +07:00
|
|
|
///
|
|
|
|
|
/// By default, it is disabled.
|
2021-07-22 18:21:50 +07:00
|
|
|
pub text_multithreading: bool,
|
|
|
|
|
|
2020-05-19 14:23:28 +02:00
|
|
|
/// The antialiasing strategy that will be used for triangle primitives.
|
2021-07-22 18:27:33 +07:00
|
|
|
///
|
|
|
|
|
/// By default, it is `None`.
|
2020-05-19 14:23:28 +02:00
|
|
|
pub antialiasing: Option<Antialiasing>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for Settings {
|
|
|
|
|
fn default() -> Settings {
|
|
|
|
|
Settings {
|
|
|
|
|
default_font: None,
|
2020-06-19 00:08:28 +02:00
|
|
|
default_text_size: 20,
|
2021-07-22 18:21:50 +07:00
|
|
|
text_multithreading: false,
|
2020-05-19 14:23:28 +02:00
|
|
|
antialiasing: None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-25 11:27:31 +01:00
|
|
|
|
|
|
|
|
impl Settings {
|
|
|
|
|
/// Creates new [`Settings`] using environment configuration.
|
|
|
|
|
///
|
|
|
|
|
/// Currently, this is equivalent to calling [`Settings::default`].
|
|
|
|
|
pub fn from_env() -> Self {
|
|
|
|
|
Self::default()
|
|
|
|
|
}
|
|
|
|
|
}
|