From 7abb089c04261da36adfcb29dbf0c78976b006cc Mon Sep 17 00:00:00 2001 From: Lucas Schumacher Date: Mon, 3 Jun 2024 23:01:03 -0400 Subject: [PATCH] Add side panel --- src/app.rs | 16 +++++++++++++++- src/backend/audio.rs | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index 861dfe2..459f739 100644 --- a/src/app.rs +++ b/src/app.rs @@ -23,6 +23,7 @@ pub struct TemplateApp { selected_backend: usize, open_device: Option>, device_window_open: bool, + side_panel_open: bool, } impl TemplateApp { @@ -52,6 +53,7 @@ impl TemplateApp { selected_backend: 0, open_device: None, device_window_open: true, + side_panel_open: false, } } } @@ -73,7 +75,7 @@ impl eframe::App for TemplateApp { ctx.request_repaint(); self.plots.update_plots(); - // Menu bar + // Menu bar panel egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { egui::menu::bar(ui, |ui| { // 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); 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::TopBottomPanel::top("Plot") .resizable(true) diff --git a/src/backend/audio.rs b/src/backend/audio.rs index 58f3560..a5192e6 100644 --- a/src/backend/audio.rs +++ b/src/backend/audio.rs @@ -31,8 +31,8 @@ impl Audio { } } impl crate::backend::Device for Audio { - fn show_settings(&mut self, _ui: &mut egui::Ui) { - todo!() + fn show_settings(&mut self, ui: &mut egui::Ui) { + ui.label("TODO"); } fn can_tune(&self) -> bool {