From 69f85bad0da12373e0c33bcbe8dc1137565cd964 Mon Sep 17 00:00:00 2001 From: Hubald Verzijl Date: Thu, 21 Aug 2025 16:39:17 +0200 Subject: [PATCH] Add new tab. --- src/app.rs | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/app.rs b/src/app.rs index d63ea2c..44dca08 100644 --- a/src/app.rs +++ b/src/app.rs @@ -37,14 +37,8 @@ struct TabViewer { show_settings_toggle: Option, } -impl egui_dock::TabViewer for TabViewer { - type Tab = String; - - fn title(&mut self, tab: &mut Self::Tab) -> egui::WidgetText { - (&*tab).into() - } - - fn ui(&mut self, ui: &mut egui::Ui, tab: &mut Self::Tab) { +impl TabViewer { + fn single_tab(&mut self, ui: &mut egui::Ui) { egui::Frame::default().inner_margin(5).show(ui, |ui| { let settings = CollapsingHeader::new("Settings") .open(self.show_settings_toggle) @@ -110,6 +104,28 @@ impl egui_dock::TabViewer for TabViewer { ); }); } + + fn multi_tab(&mut self, ui: &mut egui::Ui) { + ui.heading("Bode plots!"); + } +} + +impl egui_dock::TabViewer for TabViewer { + type Tab = String; + + fn title(&mut self, tab: &mut Self::Tab) -> egui::WidgetText { + (&*tab).into() + } + + fn ui(&mut self, ui: &mut egui::Ui, tab: &mut Self::Tab) { + match tab.as_str() { + "Single" => self.single_tab(ui), + "Multi" => self.multi_tab(ui), + _ => { + let _ = ui.label("Unknown tab"); + } + } + } } impl App { @@ -136,7 +152,7 @@ impl App { // Step 3: Construct App let app = App { - tree: DockState::new(vec!["Single".to_string()]), + tree: DockState::new(vec!["Single".to_string(), "Multi".to_string()]), tab_viewer, run_impedancemeter_tx, magnitude,