Skip to content

Commit

Permalink
Remove dark-light dependency
Browse files Browse the repository at this point in the history
Since #2750 we now get what we need
straight from `winit`.
  • Loading branch information
emilk committed Apr 18, 2023
1 parent 0f9e1a3 commit 9b5ab4f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 107 deletions.
65 changes: 0 additions & 65 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions crates/eframe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -75,9 +70,9 @@ wgpu = ["dep:wgpu", "dep:egui-wgpu", "dep:pollster"]
# - It's also important that we don't impose an android-activity backend by taking this choice away from applications.

## Enable the `native-activity` backend via `egui-winit` on Android
android-native-activity = [ "egui-winit/android-native-activity" ]
android-native-activity = ["egui-winit/android-native-activity"]
## Enable the `game-activity` backend via `egui-winit` on Android
android-game-activity = [ "egui-winit/android-game-activity" ]
android-game-activity = ["egui-winit/android-game-activity"]

[dependencies]
egui = { version = "0.21.0", path = "../egui", default-features = false, features = [
Expand Down Expand Up @@ -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",
Expand Down
33 changes: 3 additions & 30 deletions crates/eframe/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,9 +1454,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()
None
}
2 changes: 0 additions & 2 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ deny = [
]

skip = [
{ name = "ahash" }, # old version via dark-light
{ name = "arrayvec" }, # old version via tiny-skiaz
{ name = "hashbrown" }, # old version via dark-light
{ name = "nix" }, # old version via winit
{ name = "redox_syscall" }, # old version via winit
{ name = "time" }, # old version pulled in by unmaintianed crate 'chrono'
Expand Down

0 comments on commit 9b5ab4f

Please sign in to comment.