diff --git a/Cargo.lock b/Cargo.lock index c176cc3..57c19d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -663,7 +663,7 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "eframe" version = "0.18.0" -source = "git+https://github.com/Titaniumtown/egui.git#9c285d1260d8b3b403fb59391b531bd684e06bd4" +source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04" dependencies = [ "bytemuck", "egui", @@ -683,7 +683,7 @@ dependencies = [ [[package]] name = "egui" version = "0.18.1" -source = "git+https://github.com/Titaniumtown/egui.git#9c285d1260d8b3b403fb59391b531bd684e06bd4" +source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04" dependencies = [ "ahash", "epaint", @@ -694,7 +694,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.18.0" -source = "git+https://github.com/Titaniumtown/egui.git#9c285d1260d8b3b403fb59391b531bd684e06bd4" +source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04" dependencies = [ "arboard", "egui", @@ -707,7 +707,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.18.0" -source = "git+https://github.com/Titaniumtown/egui.git#9c285d1260d8b3b403fb59391b531bd684e06bd4" +source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04" dependencies = [ "bytemuck", "egui", @@ -727,7 +727,7 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "emath" version = "0.18.0" -source = "git+https://github.com/Titaniumtown/egui.git#9c285d1260d8b3b403fb59391b531bd684e06bd4" +source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04" dependencies = [ "bytemuck", ] @@ -735,7 +735,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.18.1" -source = "git+https://github.com/Titaniumtown/egui.git#9c285d1260d8b3b403fb59391b531bd684e06bd4" +source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04" dependencies = [ "ab_glyph", "ahash", diff --git a/src/function_manager.rs b/src/function_manager.rs index 073bedd..35a6fa1 100644 --- a/src/function_manager.rs +++ b/src/function_manager.rs @@ -132,7 +132,7 @@ impl FunctionManager { Button::new_const(WidgetText::RichText(RichText::new_const(text))).frame(false) } - /// the y offset multiplier of the `buttons_area` area + /// The y offset multiplier of the `buttons_area` area const BUTTONS_Y_OFFSET: f32 = 1.32; widgets_ontop( @@ -198,10 +198,7 @@ impl FunctionManager { } pub fn any_using_integral(&self) -> bool { - self.functions - .iter() - .filter(|(_, func)| func.integral) - .count() > 0 + self.functions.iter().any(|(_, func)| func.integral) } #[inline] diff --git a/src/math_app.rs b/src/math_app.rs index 594a976..1a95920 100644 --- a/src/math_app.rs +++ b/src/math_app.rs @@ -107,7 +107,6 @@ pub struct MathApp { /// Contains the list of Areas calculated (the vector of f64) and time it took for the last frame (the Duration). Stored in a Tuple. last_info: (Vec>, Option), - toggle_visuals: bool, dark_mode: bool, /// Stores opened windows/elements for later reference @@ -256,7 +255,6 @@ impl MathApp { Self { functions: Default::default(), last_info: (vec![None], None), - toggle_visuals: false, dark_mode: true, // dark mode is default and is previously set text: text_data.expect("Didn't find text.json"), opened: Opened::default(), @@ -391,16 +389,6 @@ impl App for MathApp { None }; - // Toggle visuals if requested - if self.toggle_visuals { - ctx.set_visuals(match self.dark_mode { - true => Visuals::light(), - false => Visuals::dark(), - }); - self.dark_mode.bitxor_assign(true); - self.toggle_visuals = false; - } - // If keyboard input isn't being grabbed, check for key combos if !ctx.wants_keyboard_input() { // If `H` key is pressed, toggle Side Panel @@ -455,7 +443,7 @@ impl App for MathApp { ); // Toggles dark/light mode - self.toggle_visuals = ui + if ui .add(Button::new(match self.dark_mode { true => "🌞", false => "🌙", @@ -464,10 +452,17 @@ impl App for MathApp { true => "Turn the Lights on!", false => "Turn the Lights off.", }) - .clicked(); + .clicked() + { + ctx.set_visuals(match self.dark_mode { + true => Visuals::light(), + false => Visuals::dark(), + }); + self.dark_mode.bitxor_assign(true); + } // Display Area and time of last frame - if self.last_info.0.iter().filter(|e| e.is_some()).count() > 0 { + if self.last_info.0.iter().any(|e| e.is_some()) { ui.label(format!("Area: {}", option_vec_printer(&self.last_info.0))); } });