From b3c192a2e478e9f2a101aecb417e316ed6900a80 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 19 Jun 2020 00:08:28 +0200 Subject: Make default text size configurable in `Settings` --- src/settings.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/settings.rs') 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 { /// The window settings. /// @@ -22,6 +22,11 @@ pub struct Settings { // 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 Settings { /// /// [`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 Default for Settings +where + Flags: Default, +{ + fn default() -> Self { + Self { + flags: Default::default(), antialiasing: Default::default(), default_font: Default::default(), + default_text_size: 20, window: Default::default(), } } -- cgit From 65a4dca0d965ca963428231173ca5fb9c672ab52 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 25 Jun 2020 00:32:41 +0200 Subject: Add `min_size` and `max_size` to `window::Settings` --- src/settings.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/settings.rs') diff --git a/src/settings.rs b/src/settings.rs index 933829bd..d7ff4cab 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -75,12 +75,7 @@ where impl From> for iced_winit::Settings { fn from(settings: Settings) -> iced_winit::Settings { iced_winit::Settings { - window: iced_winit::settings::Window { - size: settings.window.size, - resizable: settings.window.resizable, - decorations: settings.window.decorations, - platform_specific: Default::default(), - }, + window: settings.window.into(), flags: settings.flags, } } -- cgit From 9a037a23e9b32d9dbe7086a54d777b5f0550a660 Mon Sep 17 00:00:00 2001 From: Francesco Pasa Date: Sat, 11 Apr 2020 15:16:10 +0200 Subject: Add support for setting window icon This adds a new property from Settings::window::iconand a Icon struct which can be converted to winit::window::Icon. It also adds code to display this icon in Application::run. Due to the fact that the Icon struct is non copyable, I also had to remove the Copy trait from all Settings, both in `iced` and `iced_winit`. --- src/settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/settings.rs') diff --git a/src/settings.rs b/src/settings.rs index d7ff4cab..ec0e56b6 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)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Settings { /// The window settings. /// -- cgit From a0cc7e4e43f16de4c19607f913b7f587c61aa5ef Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 Jul 2020 06:09:39 +0200 Subject: Move `Icon` to `iced` crate and introduce `Error` --- src/settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/settings.rs') diff --git a/src/settings.rs b/src/settings.rs index ec0e56b6..40b1b1ea 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -2,7 +2,7 @@ use crate::window; /// The settings of an application. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone)] pub struct Settings { /// The window settings. /// -- cgit