Rework theme API

This commit adds support for theming on macOS and
also unifies the system theme handling across platforms.
This commit is contained in:
keiya sasaki 2022-10-19 03:34:36 +09:00 committed by GitHub
parent 4f06cfcf5b
commit 92fdf5ba85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 256 additions and 60 deletions

View file

@ -694,8 +694,8 @@ impl Window {
}
#[inline]
pub fn theme(&self) -> Theme {
self.window_state_lock().current_theme
pub fn theme(&self) -> Option<Theme> {
Some(self.window_state_lock().current_theme)
}
#[inline]
@ -781,7 +781,7 @@ impl<'a, T: 'static> InitData<'a, T> {
// If the system theme is dark, we need to set the window theme now
// before we update the window flags (and possibly show the
// window for the first time).
let current_theme = try_theme(window, self.pl_attribs.preferred_theme);
let current_theme = try_theme(window, self.attributes.preferred_theme);
let window_state = {
let window_state = WindowState::new(
@ -789,7 +789,7 @@ impl<'a, T: 'static> InitData<'a, T> {
self.pl_attribs.taskbar_icon.clone(),
scale_factor,
current_theme,
self.pl_attribs.preferred_theme,
self.attributes.preferred_theme,
);
let window_state = Arc::new(Mutex::new(window_state));
WindowState::set_window_flags(window_state.lock().unwrap(), window, |f| {