1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30: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

@@ -26,11 +26,6 @@ default = ["accesskit", "default_fonts", "glow"]
## Enable platform accessibility API implementations through [AccessKit](https://accesskit.dev/).
accesskit = ["egui/accesskit", "egui-winit/accesskit"]
## Detect dark mode system preference using [`dark-light`](https://docs.rs/dark-light).
##
## See also [`NativeOptions::follow_system_theme`] and [`NativeOptions::default_theme`].
dark-light = ["dep:dark-light"]
## If set, egui will use `include_bytes!` to bundle some fonts.
## If you plan on specifying your own fonts you may disable this feature.
default_fonts = ["egui/default_fonts"]
@@ -107,7 +102,6 @@ raw-window-handle = { version = "0.5.0" }
winit = "0.28.1"
# optional native:
dark-light = { version = "1.0", optional = true }
directories-next = { version = "2", optional = true }
egui-wgpu = { version = "0.21.0", path = "../egui-wgpu", optional = true, features = [
"winit",

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
}