mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-28 07:33:14 -04:00
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:
@@ -19,7 +19,6 @@ pub(self) use crate::platform_impl::Fullscreen;
|
||||
|
||||
use crate::event::DeviceId as RootDeviceId;
|
||||
use crate::icon::Icon;
|
||||
use crate::window::Theme;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Parent {
|
||||
@@ -35,7 +34,6 @@ pub struct PlatformSpecificWindowBuilderAttributes {
|
||||
pub taskbar_icon: Option<Icon>,
|
||||
pub no_redirection_bitmap: bool,
|
||||
pub drag_and_drop: bool,
|
||||
pub preferred_theme: Option<Theme>,
|
||||
pub skip_taskbar: bool,
|
||||
pub decoration_shadow: bool,
|
||||
}
|
||||
@@ -48,7 +46,6 @@ impl Default for PlatformSpecificWindowBuilderAttributes {
|
||||
taskbar_icon: None,
|
||||
no_redirection_bitmap: false,
|
||||
drag_and_drop: true,
|
||||
preferred_theme: None,
|
||||
skip_taskbar: false,
|
||||
decoration_shadow: false,
|
||||
}
|
||||
|
||||
@@ -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| {
|
||||
|
||||
Reference in New Issue
Block a user