cleanup code

This commit is contained in:
Simon Gardling 2022-03-28 21:51:45 -04:00
parent f4aeb80cf8
commit 45c2055da3

View File

@ -457,19 +457,14 @@ impl MathApp {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Function:"); ui.label("Function:");
if functions_len > 1 {
// There's more than 1 function! Functions can now be deleted // There's more than 1 function! Functions can now be deleted
if ui if ui
.add(Button::new("X")) .add_enabled(functions_len > 1, Button::new("X"))
.on_hover_text("Delete Function") .on_hover_text("Delete Function")
.clicked() .clicked()
{ {
remove_i = Some(i); remove_i = Some(i);
} }
} else {
// Display greyed out "X" button if there's only one function added
ui.add_enabled(false, Button::new("X"));
}
// Toggle integral being enabled or not // Toggle integral being enabled or not
integral_toggle = ui integral_toggle = ui
@ -546,8 +541,10 @@ impl MathApp {
} }
impl epi::App for MathApp { impl epi::App for MathApp {
// Called each time the UI needs repainting, which may be many times per second. /// Called each time the UI needs repainting, which may be many times per
/// second.
fn update(&mut self, ctx: &Context, _frame: &mut Frame) { fn update(&mut self, ctx: &Context, _frame: &mut Frame) {
// start timer
let start = instant::Instant::now(); let start = instant::Instant::now();
// Set dark/light mode depending on the variable `self.settings.dark_mode` // Set dark/light mode depending on the variable `self.settings.dark_mode`
@ -556,6 +553,7 @@ impl epi::App for MathApp {
false => Visuals::light(), false => Visuals::light(),
}); });
// Toggle show_side_panel on `H` key press
self.settings self.settings
.show_side_panel .show_side_panel
.bitxor_assign(ctx.input().key_down(Key::H)); .bitxor_assign(ctx.input().key_down(Key::H));
@ -710,7 +708,6 @@ impl epi::App for MathApp {
let maxx_bounds: f64 = bounds.max()[0]; let maxx_bounds: f64 = bounds.max()[0];
dyn_mut_iter(&mut self.functions) dyn_mut_iter(&mut self.functions)
// .iter_mut()
.enumerate() .enumerate()
.filter(|(i, _)| !self.func_strs[*i].is_empty()) .filter(|(i, _)| !self.func_strs[*i].is_empty())
.for_each(|(_, function)| { .for_each(|(_, function)| {