Use winit to obtain current theme::Mode
This commit is contained in:
parent
5c7ae8a3d6
commit
0111f514a1
25 changed files with 208 additions and 602 deletions
|
|
@ -595,14 +595,7 @@ async fn run_instance<P>(
|
|||
}
|
||||
}
|
||||
|
||||
debug::theme_changed(|| {
|
||||
if window_manager.is_empty() {
|
||||
theme::Base::palette(&program.theme(id))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
let is_first = window_manager.is_empty();
|
||||
let window = window_manager.insert(
|
||||
id,
|
||||
window,
|
||||
|
|
@ -613,6 +606,14 @@ async fn run_instance<P>(
|
|||
exit_on_close_request,
|
||||
);
|
||||
|
||||
debug::theme_changed(|| {
|
||||
if is_first {
|
||||
theme::Base::palette(window.state.theme())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
let logical_size = window.state.logical_size();
|
||||
|
||||
let _ = user_interfaces.insert(
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ where
|
|||
cursor_position: Option<winit::dpi::PhysicalPosition<f64>>,
|
||||
modifiers: winit::keyboard::ModifiersState,
|
||||
theme: P::Theme,
|
||||
theme_mode: theme::Mode,
|
||||
style: theme::Style,
|
||||
}
|
||||
|
||||
|
|
@ -52,7 +53,14 @@ where
|
|||
) -> Self {
|
||||
let title = program.title(window_id);
|
||||
let scale_factor = program.scale_factor(window_id);
|
||||
let theme = program.theme(window_id);
|
||||
let theme_mode = match window.theme() {
|
||||
None => theme::Mode::None,
|
||||
Some(winit::window::Theme::Light) => theme::Mode::Light,
|
||||
Some(winit::window::Theme::Dark) => theme::Mode::Dark,
|
||||
};
|
||||
let theme = program
|
||||
.theme(window_id)
|
||||
.unwrap_or_else(|| <P::Theme as theme::Base>::default(theme_mode));
|
||||
let style = program.style(&theme);
|
||||
|
||||
let viewport = {
|
||||
|
|
@ -72,6 +80,7 @@ where
|
|||
cursor_position: None,
|
||||
modifiers: winit::keyboard::ModifiersState::default(),
|
||||
theme,
|
||||
theme_mode,
|
||||
style,
|
||||
}
|
||||
}
|
||||
|
|
@ -216,7 +225,9 @@ where
|
|||
}
|
||||
|
||||
// Update theme and appearance
|
||||
self.theme = program.theme(window_id);
|
||||
self.theme = program.theme(window_id).unwrap_or_else(|| {
|
||||
<P::Theme as theme::Base>::default(self.theme_mode)
|
||||
});
|
||||
self.style = program.style(&self.theme);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue