From 6258b0ac169a3ecac563446a4d18ec1f86710b2a Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Wed, 18 May 2022 11:51:56 -0400 Subject: [PATCH] adjust storing and processing of area info --- src/math_app.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/math_app.rs b/src/math_app.rs index c9841f9..70d252e 100644 --- a/src/math_app.rs +++ b/src/math_app.rs @@ -91,7 +91,7 @@ pub struct MathApp { functions: FunctionManager, /// 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), + last_info: (Option, Option), /// Whether or not dark mode is enabled dark_mode: bool, @@ -253,7 +253,7 @@ impl MathApp { #[cfg(not(target_arch = "wasm32"))] functions: FunctionManager::default(), - last_info: (vec![None], None), + last_info: (None, None), dark_mode: true, // dark mode is default and is previously set text: data.text, opened: Opened::default(), @@ -460,8 +460,8 @@ impl App for MathApp { } // Display Area and time of last frame - if self.last_info.0.iter().any(|e| e.is_some()) { - ui.label(format!("Area: {}", option_vec_printer(&self.last_info.0))); + if let Some(ref area) = self.last_info.0 { + ui.label(area); } }); }); @@ -578,7 +578,7 @@ impl App for MathApp { function.calculate(width_changed, min_max_changed, &self.settings) }); - self.last_info.0 = self + let area: Vec> = self .functions .get_entries() .iter() @@ -587,6 +587,12 @@ impl App for MathApp { function.display(plot_ui, &self.settings, COLORS[i]) }) .collect(); + + self.last_info.0 = if area.iter().any(|e| e.is_some()) { + Some(format!("Area: {}", option_vec_printer(area.as_slice()))) + } else { + None + }; }); });