add option to remove functions

This commit is contained in:
Simon Gardling 2022-03-01 21:53:27 -05:00
parent 3f16a05d4f
commit 2fe0eebb6d

View File

@ -246,12 +246,20 @@ impl epi::App for MathApp {
egui::Slider::new(&mut self.integral_num, INTEGRAL_NUM_RANGE).text("Interval"),
);
let mut remove_i: Option<usize> = None;
for (i, function) in self.functions.iter_mut().enumerate() {
let mut integral_toggle: bool = false;
let integral_enabled = function.integral;
// Entry for a function
ui.horizontal(|ui| {
ui.label("Function: ");
if ui
.add(Button::new("X"))
.on_hover_text("Delete Function")
.clicked()
{
remove_i = Some(i);
}
if ui
.add(Button::new(""))
.on_hover_text(if integral_enabled {
@ -292,6 +300,13 @@ impl epi::App for MathApp {
}
}
if self.functions.len() > 1 {
if let Some(remove_i_unwrap) = remove_i {
self.functions.remove(remove_i_unwrap);
self.func_strs.remove(remove_i_unwrap);
}
}
// Open Source and Licensing information
ui.hyperlink_to(
"I'm Opensource!",