linebender / druid

A data-first Rust-native UI design toolkit.
https://linebender.org/druid/
Apache License 2.0
9.58k stars 566 forks source link

[Bug] Light Theme Detection Broken #2408

Closed caoccao closed 1 month ago

caoccao commented 2 months ago

I'm building an application on Windows 10 x86_64 with light theme set. However, the application always shows the dark theme and I failed to find a way of correcting it.

image

The registry is as follows.

image

The settings is as follows.

image

caoccao commented 2 months ago

Update

I pointed the dependency to the latest source code. It's now resolved.

[dependencies]
# druid = "0.8.3"
druid = { path = "../druid/druid" }

image

Furthermore, I implemented a simple light theme based on the built-in dark theme as follows.

fn main() {
  // ...
  druid::AppLauncher::with_window(window)
    .configure_env(set_light_theme)
    .launch(())
    .expect("Failed to launch application");
}

fn set_light_theme(env: &mut druid::Env, _: &()) {
  env.set(
    druid::theme::WINDOW_BACKGROUND_COLOR,
    druid::Color::rgb8(0xFF - 0x29, 0xFF - 0x29, 0xFF - 0x29),
  );
  env.set(
    druid::theme::TEXT_COLOR,
    druid::Color::rgb8(0xFF - 0xf0, 0xFF - 0xf0, 0xFF - 0xea),
  );
  env.set(
    druid::theme::DISABLED_TEXT_COLOR,
    druid::Color::rgb8(0xFF - 0xa0, 0xFF - 0xa0, 0xFF - 0x9a),
  );
  env.set(
    druid::theme::PLACEHOLDER_COLOR,
    druid::Color::rgb8(0xFF - 0x80, 0xFF - 0x80, 0xFF - 0x80),
  );
  env.set(
    druid::theme::PRIMARY_LIGHT,
    druid::Color::rgb8(0xFF - 0x5c, 0xFF - 0xc4, 0xFF - 0xff),
  );
  env.set(
    druid::theme::PRIMARY_DARK,
    druid::Color::rgb8(0xFF - 0x00, 0xFF - 0x8d, 0xFF - 0xdd),
  );
  env.set(
    druid::theme::BACKGROUND_LIGHT,
    druid::Color::rgb8(0xFF - 0x3a, 0xFF - 0x3a, 0xFF - 0x3a),
  );
  env.set(
    druid::theme::BACKGROUND_DARK,
    druid::Color::rgb8(0xFF - 0x31, 0xFF - 0x31, 0xFF - 0x31),
  );
  env.set(
    druid::theme::FOREGROUND_LIGHT,
    druid::Color::rgb8(0xFF - 0xf9, 0xFF - 0xf9, 0xFF - 0xf9),
  );
  env.set(
    druid::theme::FOREGROUND_DARK,
    druid::Color::rgb8(0xFF - 0xbf, 0xFF - 0xbf, 0xFF - 0xbf),
  );
  env.set(
    druid::theme::DISABLED_FOREGROUND_LIGHT,
    druid::Color::rgb8(0xFF - 0x89, 0xFF - 0x89, 0xFF - 0x89),
  );
  env.set(
    druid::theme::DISABLED_FOREGROUND_DARK,
    druid::Color::rgb8(0xFF - 0x6f, 0xFF - 0x6f, 0xFF - 0x6f),
  );
  env.set(
    druid::theme::BUTTON_LIGHT,
    druid::Color::rgb8(0xFF - 0x21, 0xFF - 0x21, 0xFF - 0x21),
  );
  env.set(druid::theme::BUTTON_DARK, druid::Color::rgb8(0x99, 0x99, 0x99));
  env.set(
    druid::theme::BORDER_DARK,
    druid::Color::rgb8(0xFF - 0x3a, 0xFF - 0x3a, 0xFF - 0x3a),
  );
  env.set(
    druid::theme::BORDER_LIGHT,
    druid::Color::rgb8(0xFF - 0xa1, 0xFF - 0xa1, 0xFF - 0xa1),
  );
  env.set(
    druid::theme::SELECTION_TEXT_COLOR,
    druid::Color::rgb8(0xFF - 0x00, 0xFF - 0x00, 0xFF - 0x00),
  );
  env.set(
    druid::theme::SCROLLBAR_COLOR,
    druid::Color::rgb8(0xFF - 0xff, 0xFF - 0xff, 0xFF - 0xff),
  );
  env.set(
    druid::theme::SCROLLBAR_BORDER_COLOR,
    druid::Color::rgb8(0xFF - 0x77, 0xFF - 0x77, 0xFF - 0x77),
  );
}

image

xStrom commented 1 month ago

This was indeed fixed in #2378 and will be part of the next release.