mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Add light mode
This commit is contained in:
@@ -69,6 +69,8 @@ impl epi::App for WrapApp {
|
||||
// A menu-bar is a horizontal layout with some special styles applied.
|
||||
// egui::menu::bar(ui, |ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
dark_light_mode_switch(ui);
|
||||
|
||||
ui.checkbox(&mut self.backend_panel.open, "💻 Backend");
|
||||
ui.separator();
|
||||
|
||||
@@ -130,6 +132,15 @@ fn clock_button(ui: &mut egui::Ui, seconds_since_midnight: f64) -> egui::Respons
|
||||
ui.add(egui::Button::new(time).text_style(egui::TextStyle::Monospace))
|
||||
}
|
||||
|
||||
/// Show a button to switch to/from dark/light mode (globally).
|
||||
fn dark_light_mode_switch(ui: &mut egui::Ui) {
|
||||
let style: egui::Style = (*ui.ctx().style()).clone();
|
||||
let new_visuals = style.visuals.light_dark_small_toggle_button(ui);
|
||||
if let Some(visuals) = new_visuals {
|
||||
ui.ctx().set_style(egui::Style { visuals, ..style });
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// How often we repaint the demo app by default
|
||||
|
||||
Reference in New Issue
Block a user