simplify dark mode code
This commit is contained in:
parent
654f2a67c5
commit
74be8357cf
@ -3,12 +3,11 @@ use crate::misc::digits_precision;
|
|||||||
use crate::parsing::{add_asterisks, test_func};
|
use crate::parsing::{add_asterisks, test_func};
|
||||||
|
|
||||||
use const_format::formatc;
|
use const_format::formatc;
|
||||||
use eframe::egui::FontTweak;
|
|
||||||
use eframe::{egui, epi};
|
use eframe::{egui, epi};
|
||||||
use egui::plot::Plot;
|
use egui::plot::Plot;
|
||||||
use egui::{
|
use egui::{
|
||||||
Button, CentralPanel, Color32, ComboBox, Context, FontData, FontDefinitions, FontFamily,
|
Button, CentralPanel, Color32, ComboBox, Context, FontData, FontDefinitions, FontFamily,
|
||||||
RichText, SidePanel, Slider, TopBottomPanel, Vec2, Window,
|
RichText, SidePanel, Slider, TopBottomPanel, Vec2, Visuals, Window,
|
||||||
};
|
};
|
||||||
use epi::{Frame, Storage};
|
use epi::{Frame, Storage};
|
||||||
use include_flate::flate;
|
use include_flate::flate;
|
||||||
@ -343,11 +342,10 @@ impl epi::App for MathApp {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn update(&mut self, ctx: &Context, _frame: &Frame) {
|
fn update(&mut self, ctx: &Context, _frame: &Frame) {
|
||||||
let start = instant::Instant::now();
|
let start = instant::Instant::now();
|
||||||
if self.settings.dark_mode {
|
ctx.set_visuals(match self.settings.dark_mode {
|
||||||
ctx.set_visuals(egui::Visuals::dark());
|
true => Visuals::dark(),
|
||||||
} else {
|
false => Visuals::light(),
|
||||||
ctx.set_visuals(egui::Visuals::light());
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Reduce size of final binary by just including one font
|
// Reduce size of final binary by just including one font
|
||||||
let mut fonts = FontDefinitions::default();
|
let mut fonts = FontDefinitions::default();
|
||||||
@ -416,22 +414,18 @@ impl epi::App for MathApp {
|
|||||||
self.settings.info_open = !self.settings.info_open;
|
self.settings.info_open = !self.settings.info_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.settings.dark_mode {
|
if ui
|
||||||
if ui
|
.add(Button::new(match self.settings.dark_mode {
|
||||||
.add(Button::new("🌞"))
|
true => "🌞",
|
||||||
.on_hover_text("Turn the Lights on!")
|
false => "🌙",
|
||||||
.clicked()
|
}))
|
||||||
{
|
.on_hover_text(match self.settings.dark_mode {
|
||||||
self.settings.dark_mode = false;
|
true => "Turn the Lights on!",
|
||||||
}
|
false => "Turn the Lights off.",
|
||||||
} else {
|
})
|
||||||
if ui
|
.clicked()
|
||||||
.add(Button::new("🌙"))
|
{
|
||||||
.on_hover_text("Turn the Lights off.")
|
self.settings.dark_mode = !self.settings.dark_mode;
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
self.settings.dark_mode = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.label(format!(
|
ui.label(format!(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user