Add side panel

This commit is contained in:
Lucas Schumacher 2024-06-03 23:01:03 -04:00
parent d878f66bd8
commit 7abb089c04
2 changed files with 17 additions and 3 deletions

View File

@ -23,6 +23,7 @@ pub struct TemplateApp {
selected_backend: usize, selected_backend: usize,
open_device: Option<Box<dyn backend::Device>>, open_device: Option<Box<dyn backend::Device>>,
device_window_open: bool, device_window_open: bool,
side_panel_open: bool,
} }
impl TemplateApp { impl TemplateApp {
@ -52,6 +53,7 @@ impl TemplateApp {
selected_backend: 0, selected_backend: 0,
open_device: None, open_device: None,
device_window_open: true, device_window_open: true,
side_panel_open: false,
} }
} }
} }
@ -73,7 +75,7 @@ impl eframe::App for TemplateApp {
ctx.request_repaint(); ctx.request_repaint();
self.plots.update_plots(); self.plots.update_plots();
// Menu bar // Menu bar panel
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
egui::menu::bar(ui, |ui| { egui::menu::bar(ui, |ui| {
// NOTE: no File->Quit on web pages! // NOTE: no File->Quit on web pages!
@ -88,6 +90,10 @@ impl eframe::App for TemplateApp {
} }
} }
}); });
ui.menu_button("View", |ui| {
ui.checkbox(&mut self.side_panel_open, "Side Panel");
});
self.plots.render_menu_buttons(ui); self.plots.render_menu_buttons(ui);
ui.add_space(16.0); ui.add_space(16.0);
@ -95,6 +101,14 @@ impl eframe::App for TemplateApp {
}); });
}); });
// Side panel
egui::SidePanel::right("Sid panel").show_animated(ctx, self.side_panel_open, |ui| {
if let Some(d) = &mut self.open_device {
d.show_settings(ui)
}
});
// Central panel
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
egui::TopBottomPanel::top("Plot") egui::TopBottomPanel::top("Plot")
.resizable(true) .resizable(true)

View File

@ -31,8 +31,8 @@ impl Audio {
} }
} }
impl crate::backend::Device for Audio { impl crate::backend::Device for Audio {
fn show_settings(&mut self, _ui: &mut egui::Ui) { fn show_settings(&mut self, ui: &mut egui::Ui) {
todo!() ui.label("TODO");
} }
fn can_tune(&self) -> bool { fn can_tune(&self) -> bool {