diff options
author | 2022-05-25 05:01:18 +0200 | |
---|---|---|
committer | 2022-05-25 05:01:18 +0200 | |
commit | 03eda9b162012c503ead649e5ccb95b7ef1d10ed (patch) | |
tree | a134dbab97011c0a465f4527d2ae0bb771f51554 /winit/src/application.rs | |
parent | 2cfb307f8c3927a0876c6b754a5d7d673b9edfee (diff) | |
download | iced-03eda9b162012c503ead649e5ccb95b7ef1d10ed.tar.gz iced-03eda9b162012c503ead649e5ccb95b7ef1d10ed.tar.bz2 iced-03eda9b162012c503ead649e5ccb95b7ef1d10ed.zip |
Let a `Theme` control the background color of an application
... and remove `Application::background_color`
Diffstat (limited to 'winit/src/application.rs')
-rw-r--r-- | winit/src/application.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index abe6b8a9..55fd9e73 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -6,9 +6,10 @@ pub use state::State; use crate::clipboard::{self, Clipboard}; use crate::conversion; use crate::mouse; +use crate::theme::{self, Definition as _}; use crate::{ - Color, Command, Debug, Error, Executor, Mode, Proxy, Runtime, Settings, - Size, Subscription, + Command, Debug, Error, Executor, Mode, Proxy, Runtime, Settings, Size, + Subscription, }; use iced_futures::futures; @@ -77,13 +78,6 @@ pub trait Application: Program { Mode::Windowed } - /// Returns the background [`Color`] of the [`Application`]. - /// - /// By default, it returns [`Color::WHITE`]. - fn background_color(&self) -> Color { - Color::WHITE - } - /// Returns the scale factor of the [`Application`]. /// /// It can be used to dynamically control the size of the UI at runtime @@ -115,6 +109,7 @@ where A: Application + 'static, E: Executor + 'static, C: window::Compositor<Renderer = A::Renderer> + 'static, + <A::Renderer as iced_native::Renderer>::Theme: theme::Definition, { use futures::task; use futures::Future; @@ -250,6 +245,7 @@ async fn run_instance<A, E, C>( A: Application + 'static, E: Executor + 'static, C: window::Compositor<Renderer = A::Renderer> + 'static, + <A::Renderer as iced_native::Renderer>::Theme: theme::Definition, { use iced_futures::futures::stream::StreamExt; use winit::event; @@ -425,7 +421,7 @@ async fn run_instance<A, E, C>( &mut renderer, &mut surface, state.viewport(), - state.background_color(), + theme.background_color(), &debug.overlay(), ) { Ok(()) => { |