From 4c0286e8acdf0792a9680f6f8212a534a51e3da0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 12 Jun 2020 22:12:15 +0200 Subject: Add `background_color` to `Application` and `Sandbox` --- src/application.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index 19cab7da..2de67eb0 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,4 +1,6 @@ -use crate::{window, Command, Element, Executor, Settings, Subscription}; +use crate::{ + window, Color, Command, Element, Executor, Settings, Subscription, +}; /// An interactive cross-platform application. /// @@ -174,6 +176,16 @@ pub trait Application: Sized { window::Mode::Windowed } + /// Returns the background color of the [`Application`]. + /// + /// By default, it returns [`Color::WHITE`]. + /// + /// [`Application`]: trait.Application.html + /// [`Color::WHITE`]: struct.Color.html#const.WHITE + fn background_color(&self) -> Color { + Color::WHITE + } + /// Runs the [`Application`]. /// /// On native platforms, this method will take control of the current thread @@ -256,6 +268,10 @@ where fn subscription(&self) -> Subscription { self.0.subscription() } + + fn background_color(&self) -> Color { + self.0.background_color() + } } #[cfg(target_arch = "wasm32")] -- cgit 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/application.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/application.rs') 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 { -- cgit From c9696ca687446d78de374a828183de0a5e4bace3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 19 Jun 2020 19:17:05 +0200 Subject: Add `scale_factor` to `Application` and `Sandbox` --- src/application.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index 2de67eb0..92d9cbed 100644 --- a/src/application.rs +++ b/src/application.rs @@ -186,6 +186,21 @@ pub trait Application: Sized { Color::WHITE } + /// Returns the scale factor of the [`Application`]. + /// + /// It can be used to dynamically control the size of the UI at runtime + /// (i.e. zooming). + /// + /// For instance, a scale factor of `2.0` will make widgets twice as big, + /// while a scale factor of `0.5` will shrink them to half their size. + /// + /// By default, it returns `1.0`. + /// + /// [`Application`]: trait.Application.html + fn scale_factor(&self) -> f64 { + 1.0 + } + /// Runs the [`Application`]. /// /// On native platforms, this method will take control of the current thread @@ -272,6 +287,10 @@ where fn background_color(&self) -> Color { self.0.background_color() } + + fn scale_factor(&self) -> f64 { + self.0.scale_factor() + } } #[cfg(target_arch = "wasm32")] -- cgit