diff options
author | 2020-06-19 00:08:28 +0200 | |
---|---|---|
committer | 2020-06-19 00:16:22 +0200 | |
commit | b3c192a2e478e9f2a101aecb417e316ed6900a80 (patch) | |
tree | aebde6403c3a6cef9566cca64e185272fcbbfcbd /src | |
parent | d19c02035ff5e4a895868023bd67f3df1f5d7007 (diff) | |
download | iced-b3c192a2e478e9f2a101aecb417e316ed6900a80.tar.gz iced-b3c192a2e478e9f2a101aecb417e316ed6900a80.tar.bz2 iced-b3c192a2e478e9f2a101aecb417e316ed6900a80.zip |
Make default text size configurable in `Settings`
Diffstat (limited to 'src')
-rw-r--r-- | src/application.rs | 1 | ||||
-rw-r--r-- | src/settings.rs | 27 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/application.rs b/src/application.rs index 2de67eb0..b9b71645 100644 --- a/src/application.rs +++ b/src/application.rs @@ -202,6 +202,7 @@ pub trait Application: Sized { { let renderer_settings = crate::renderer::Settings { default_font: settings.default_font, + default_text_size: settings.default_text_size, antialiasing: if settings.antialiasing { Some(crate::renderer::settings::Antialiasing::MSAAx4) } else { diff --git a/src/settings.rs b/src/settings.rs index 01ad0ee0..933829bd 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -2,7 +2,7 @@ use crate::window; /// The settings of an application. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Settings<Flags> { /// The window settings. /// @@ -22,6 +22,11 @@ pub struct Settings<Flags> { // TODO: Add `name` for web compatibility pub default_font: Option<&'static [u8]>, + /// The text size that will be used by default. + /// + /// The default value is 20. + pub default_text_size: u16, + /// If set to true, the renderer will try to perform antialiasing for some /// primitives. /// @@ -39,12 +44,28 @@ impl<Flags> Settings<Flags> { /// /// [`Application`]: ../trait.Application.html pub fn with_flags(flags: Flags) -> Self { + let default_settings = Settings::<()>::default(); + Self { flags, - // not using ..Default::default() struct update syntax since it is more permissive to - // allow initializing with flags without trait bound on Default + antialiasing: default_settings.antialiasing, + default_font: default_settings.default_font, + default_text_size: default_settings.default_text_size, + window: default_settings.window, + } + } +} + +impl<Flags> Default for Settings<Flags> +where + Flags: Default, +{ + fn default() -> Self { + Self { + flags: Default::default(), antialiasing: Default::default(), default_font: Default::default(), + default_text_size: 20, window: Default::default(), } } |