1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

Remove dark-light dependency (#2929)

* Remove dark-light dependency

Since https://github.com/emilk/egui/pull/2750 we now get what we need
straight from `winit`.

* fix warning

* Docstring formatting

* fix typo in check.sh
This commit is contained in:
Emil Ernerfeldt
2023-04-18 21:52:48 +02:00
committed by GitHub
parent 9c9a54ce36
commit d486c76a9f
6 changed files with 5 additions and 106 deletions

View File

@@ -328,18 +328,15 @@ pub struct NativeOptions {
/// 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>.
/// The theme will automatically change when the dark vs light mode preference is changed.
///
/// 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.
/// Does not work on Linux (see <https://github.com/rust-windowing/winit/issues/1549>).
///
/// See also [`Self::default_theme`].
pub follow_system_theme: bool,
/// Which theme to use in case [`Self::follow_system_theme`] is `false`
/// or the `dark-light` feature is disabled.
/// or eframe fails to detect the system theme.
///
/// Default: [`Theme::Dark`].
pub default_theme: Theme,
@@ -454,30 +451,6 @@ impl Default for NativeOptions {
}
}
#[cfg(not(target_arch = "wasm32"))]
impl NativeOptions {
/// The theme used by the system.
#[cfg(feature = "dark-light")]
pub fn system_theme(&self) -> Option<Theme> {
if self.follow_system_theme {
crate::profile_scope!("dark_light::detect");
match dark_light::detect() {
dark_light::Mode::Dark => Some(Theme::Dark),
dark_light::Mode::Light => Some(Theme::Light),
dark_light::Mode::Default => None,
}
} else {
None
}
}
/// The theme used by the system.
#[cfg(not(feature = "dark-light"))]
pub fn system_theme(&self) -> Option<Theme> {
None
}
}
// ----------------------------------------------------------------------------
/// Options when using `eframe` in a web page.

View File

@@ -1450,9 +1450,8 @@ fn system_theme(window: &winit::window::Window, options: &NativeOptions) -> Opti
}
// Winit only reads the system theme on macOS and Windows.
// On Linux we have to fall back on dark-light (if enabled).
// See: https://github.com/rust-windowing/winit/issues/1549
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
fn system_theme(_window: &winit::window::Window, options: &NativeOptions) -> Option<crate::Theme> {
options.system_theme()
fn system_theme(_window: &winit::window::Window, _options: &NativeOptions) -> Option<crate::Theme> {
None
}