summaryrefslogtreecommitdiffstats
path: root/src/settings.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-19 00:08:28 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-19 00:16:22 +0200
commitb3c192a2e478e9f2a101aecb417e316ed6900a80 (patch)
treeaebde6403c3a6cef9566cca64e185272fcbbfcbd /src/settings.rs
parentd19c02035ff5e4a895868023bd67f3df1f5d7007 (diff)
downloadiced-b3c192a2e478e9f2a101aecb417e316ed6900a80.tar.gz
iced-b3c192a2e478e9f2a101aecb417e316ed6900a80.tar.bz2
iced-b3c192a2e478e9f2a101aecb417e316ed6900a80.zip
Make default text size configurable in `Settings`
Diffstat (limited to 'src/settings.rs')
-rw-r--r--src/settings.rs27
1 files changed, 24 insertions, 3 deletions
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(),
}
}