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

Custom light & dark themes on system theme change #4490

Open
kernelkind opened this issue May 12, 2024 · 1 comment
Open

Custom light & dark themes on system theme change #4490

kernelkind opened this issue May 12, 2024 · 1 comment
Labels
egui rerun Desired for Rerun.io style visuals and theming

Comments

@kernelkind
Copy link

Is your feature request related to a problem? Please describe.
Currently, when the system theme changes, the Visuals theme is switched to the hard-coded egui::Visuals::dark() or egui::Visuals::light(). I would like for there to be an option to use custom Visuals for dark and light themes.

This seems to be where the system theme change is detected and the egui visuals are set:

self.egui_ctx.set_visuals(theme.egui_visuals());

And this seems to be where the hard-coded Visuals are set:

pub fn egui_visuals(self) -> egui::Visuals {
match self {
Self::Dark => egui::Visuals::dark(),
Self::Light => egui::Visuals::light(),
}
}

Describe the solution you'd like
There should be some way to pass a Visuals that corresponds to the dark theme, and another Visuals which corresponds to the light theme. Then, when a theme change is needed, those custom themes would be used instead of the hard-coded egui::Visuals::dark() or egui::Visuals::light().

Describe alternatives you've considered
None

Additional context
I am working on https://github.com/damus-io/notedeck and we would like to support custom theming at some point. It's not a high priority at the moment, and I would be open to submitting a PR for this feature in the future.

@emilk
Copy link
Owner

emilk commented May 13, 2024

100% agree with this.

The global style is stored in Options::style, and I suggest we split that into three fields:

struct Options {
    pub dark_mode_style: Arc<Style>,
    pub light_mode_style: Arc<Style>,
    pub theme: Theme, // Dark or Light}

with enum Theme { Dark, Light } (move the one in eframe into egui).

PRs welcome!

@emilk emilk added egui rerun Desired for Rerun.io style visuals and theming labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui rerun Desired for Rerun.io style visuals and theming
Projects
None yet
Development

No branches or pull requests

2 participants