/ src / gui / views.rs
views.rs
 1  pub fn save_button(ui: &mut egui::Ui) {
 2      if ui.button("Save").clicked() {
 3          //TODO: Open file dialog
 4          //Get destination path
 5          //save screenshot of plot to path
 6      }
 7  }
 8  
 9  pub type Display<'a> = Box<dyn FnMut(&mut egui::Ui) + 'a>;
10  
11  pub fn display_plot<'a>(mut circles: Vec<crate::Circle>, circle_length: &'a usize, line_colors: Vec<egui::Color32>) -> Display<'a> {
12      Box::new(move |ui| {
13          ui.with_layout(egui::Layout::bottom_up(egui::Align::Center), |ui| {
14              save_button(ui);
15              crate::plot(ui, &mut circles, &circle_length, &line_colors);
16          });
17      })
18  }
19  
20  
21  pub fn display_gui() -> Display<'static> {
22      Box::new(move |_ui| {
23          //TODO: UI (on unfocus update values)
24          // Message Content input
25          // start shift input
26          // circle length input
27          // generate button (if pressed, generate plot with details)
28      })
29  }
30  
31  pub fn random_color() -> egui::Color32 {
32      use rand::Rng;
33  
34      let mut rng = rand::thread_rng();
35      let range = 0..=255;
36  
37      egui::Color32::from_rgb(
38          rng.gen_range(range.clone()),
39          rng.gen_range(range.clone()),
40          rng.gen_range(range)
41      )
42  }
43