add option to remove functions
This commit is contained in:
parent
3f16a05d4f
commit
2fe0eebb6d
@ -246,12 +246,20 @@ impl epi::App for MathApp {
|
|||||||
egui::Slider::new(&mut self.integral_num, INTEGRAL_NUM_RANGE).text("Interval"),
|
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() {
|
for (i, function) in self.functions.iter_mut().enumerate() {
|
||||||
let mut integral_toggle: bool = false;
|
let mut integral_toggle: bool = false;
|
||||||
let integral_enabled = function.integral;
|
let integral_enabled = function.integral;
|
||||||
// Entry for a function
|
// Entry for a function
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.label("Function: ");
|
ui.label("Function: ");
|
||||||
|
if ui
|
||||||
|
.add(Button::new("X"))
|
||||||
|
.on_hover_text("Delete Function")
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
remove_i = Some(i);
|
||||||
|
}
|
||||||
if ui
|
if ui
|
||||||
.add(Button::new("∫"))
|
.add(Button::new("∫"))
|
||||||
.on_hover_text(if integral_enabled {
|
.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
|
// Open Source and Licensing information
|
||||||
ui.hyperlink_to(
|
ui.hyperlink_to(
|
||||||
"I'm Opensource!",
|
"I'm Opensource!",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user