mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
eframe: Automatically change theme when system dark/light mode changes (#2750)
* React to ThemeChanged event from winit * React to theme change using media query change event in WASM * Share conversion from bool -> Theme * Suppress too_many_arguments warning * Document limitations of automatically following the dark vs light mode preference * Simplify expression * Conditionally compile code to prevent unused item warnings * Remove needless borrow * Remove another needless borrow * Make associated functions to standalone * Request repaint after theme has changed * Only install event listener when `follow_system_theme` is enabled * Remove dark-light feature gate * Detect system theme using winit * Update documentation * Fix typos * fix warning about unused argument --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
@@ -323,13 +323,15 @@ pub struct NativeOptions {
|
||||
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||
pub renderer: Renderer,
|
||||
|
||||
/// Only used if the `dark-light` feature is enabled:
|
||||
///
|
||||
/// Try to detect and follow the system preferred setting for dark vs light mode.
|
||||
///
|
||||
/// By default, this is `true` on Mac and Windows, but `false` on Linux
|
||||
/// due to <https://github.com/frewsxcv/rust-dark-light/issues/17>.
|
||||
///
|
||||
/// On Mac and Windows the theme will automatically change when the dark vs light mode preference is changed.
|
||||
///
|
||||
/// This only works on Linux if the `dark-light` feature is enabled.
|
||||
///
|
||||
/// See also [`Self::default_theme`].
|
||||
pub follow_system_theme: bool,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user