Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dark-light dependency #2929

Merged
merged 4 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 2 additions & 3 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()
fn system_theme(_window: &winit::window::Window, _options: &NativeOptions) -> Option<crate::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
File renamed without changes.