diff options
author | 2020-06-20 19:20:37 +0200 | |
---|---|---|
committer | 2020-06-20 19:20:37 +0200 | |
commit | eec65a055fd4dbec5684611edc77338db0e6330e (patch) | |
tree | 840b2427350682b7e9448c64fdc6121364004e39 /src/application.rs | |
parent | 1432c82bdf43c6febd6a9153a71302e37347e524 (diff) | |
parent | c9696ca687446d78de374a828183de0a5e4bace3 (diff) | |
download | iced-eec65a055fd4dbec5684611edc77338db0e6330e.tar.gz iced-eec65a055fd4dbec5684611edc77338db0e6330e.tar.bz2 iced-eec65a055fd4dbec5684611edc77338db0e6330e.zip |
Merge pull request #415 from hecrj/feature/configurable-scale-factor
Add `scale_factor` to `Application` and `Sandbox`
Diffstat (limited to 'src/application.rs')
-rw-r--r-- | src/application.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/application.rs b/src/application.rs index b9b71645..47b89dbd 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 @@ -273,6 +288,10 @@ where fn background_color(&self) -> Color { self.0.background_color() } + + fn scale_factor(&self) -> f64 { + self.0.scale_factor() + } } #[cfg(target_arch = "wasm32")] |