diff --git a/core/src/theme.rs b/core/src/theme.rs index cc5b77df..a0ec538b 100644 --- a/core/src/theme.rs +++ b/core/src/theme.rs @@ -252,7 +252,7 @@ impl fmt::Display for Custom { } } -/// The base style of a [`Theme`]. +/// The base style of a theme. #[derive(Debug, Clone, Copy, PartialEq)] pub struct Style { /// The background [`Color`] of the application. @@ -262,16 +262,27 @@ pub struct Style { pub text_color: Color, } -/// The default blank style of a [`Theme`]. +/// The default blank style of a theme. pub trait Base { - /// Returns the default base [`Style`] of a [`Theme`]. + /// Returns the default base [`Style`] of a theme. fn base(&self) -> Style; + + /// Returns the color [`Palette`] of the theme. + /// + /// This [`Palette`] may be used by the runtime for + /// debugging purposes; like displaying performance + /// metrics or devtools. + fn palette(&self) -> Option; } impl Base for Theme { fn base(&self) -> Style { default(self) } + + fn palette(&self) -> Option { + Some(self.palette()) + } } /// The default [`Style`] of a built-in [`Theme`]. diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 5cd5ddcb..2c79e7f3 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -597,6 +597,14 @@ async fn run_instance

( continue; } + debug::theme_changed(|| { + if window_manager.is_empty() { + theme::Base::palette(&program.theme(id)) + } else { + None + } + }); + let window = window_manager.insert( id, window, @@ -1026,6 +1034,12 @@ async fn run_instance

( window.raw.request_redraw(); } + debug::theme_changed(|| { + window_manager.first().and_then(|window| { + theme::Base::palette(window.state.theme()) + }) + }); + user_interfaces = ManuallyDrop::new(build_user_interfaces( &program,