From 983a2eb7a48de634a2aefd10b5f8ec8c7adf0b42 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Mon, 29 Jul 2024 19:21:42 +0100 Subject: [PATCH] Started work on adding tabs to main window --- src/app/mod.rs | 4 ++-- src/app/ui/mod.rs | 25 ++++++++++++++++++------- src/app/ui/tabs/metar_tab.rs | 0 src/app/ui/tabs/mod.rs | 11 +++++++++++ 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 src/app/ui/tabs/metar_tab.rs create mode 100644 src/app/ui/tabs/mod.rs diff --git a/src/app/mod.rs b/src/app/mod.rs index a565930..c988d10 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -3,7 +3,7 @@ mod ui; /// Stuct to store the state of the running application pub struct App<'a> { name: &'a str, - icao: Vec<&'a str>, + icaos: Vec<&'a str>, metars: Vec<&'a str>, tafs: Vec<&'a str> } @@ -13,7 +13,7 @@ impl <'a> Default for App<'a> { fn default() -> Self { Self { name: "AvBag - Welcome", - icao: vec![], + icaos: vec![], metars: vec![], tafs: vec![] } diff --git a/src/app/ui/mod.rs b/src/app/ui/mod.rs index 6f10096..21dd67d 100644 --- a/src/app/ui/mod.rs +++ b/src/app/ui/mod.rs @@ -1,14 +1,25 @@ use crate::app::App; use crate::theme::onedark::ONE_DARK; -impl <'a>eframe::App for App<'a> { +pub mod tabs; + +impl<'a> eframe::App for App<'a> { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { let background_frame = egui::Frame::default().fill(ONE_DARK.bg); - + egui::CentralPanel::default() - .frame(background_frame) - .show(ctx, |ui| { - ui.heading(self.name); - }); + .frame(background_frame) + .show(ctx, |ui| { + ui.heading(self.name); + + egui::TopBottomPanel::top("wrap_app_top_bar").show(ctx, |ui| { + ui.horizontal_wrapped(|ui| { + ui.visuals_mut().button_frame = false; + + // Insert Tabs + ui.selectable_label(false, format!("{:#?}", tabs::CURRENT_TAB)) + }); + }); + }); } -} \ No newline at end of file +} diff --git a/src/app/ui/tabs/metar_tab.rs b/src/app/ui/tabs/metar_tab.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/app/ui/tabs/mod.rs b/src/app/ui/tabs/mod.rs new file mode 100644 index 0000000..f2008a2 --- /dev/null +++ b/src/app/ui/tabs/mod.rs @@ -0,0 +1,11 @@ +pub mod metar_tab; + +#[derive(Debug)] +pub enum Tabs { + METAR, + TAF, + NOTAMS, + Routing, +} + +pub static CURRENT_TAB: Tabs = Tabs::METAR; \ No newline at end of file