Created Base Setup

This commit is contained in:
Luke Else 2024-07-28 10:39:55 +01:00
parent 92e13e1c1d
commit 1e1d3bf0b1
5 changed files with 16 additions and 22 deletions

View File

@ -1,5 +1,5 @@
[package] [package]
name = "egui-template" name = "AvBag"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

View File

@ -1,3 +1,3 @@
# egui-template # AvBag
Template repo for an egui application in rust Rust application to serve as a Aviation Flight Bag

View File

@ -1,15 +1,21 @@
mod ui; mod ui;
/// Stuct to store the state of the running application /// Stuct to store the state of the running application
pub struct App { pub struct App<'a> {
name: String name: &'a str,
icao: Vec<&'a str>,
metars: Vec<&'a str>,
tafs: Vec<&'a str>
} }
impl Default for App { impl <'a> Default for App<'a> {
/// Creates the default startup state for the app; /// Creates the default startup state for the app;
fn default() -> Self { fn default() -> Self {
Self { Self {
name: String::from("Hello, World!") name: "AvBag - Welcome",
icao: vec![],
metars: vec![],
tafs: vec![]
} }
} }
} }

View File

@ -1,26 +1,14 @@
use crate::app::App; use crate::app::App;
use crate::theme::onedark::ONE_DARK; use crate::theme::onedark::ONE_DARK;
impl eframe::App for App { impl <'a>eframe::App for App<'a> {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let background_frame = egui::Frame::default().fill(ONE_DARK.bg); let background_frame = egui::Frame::default().fill(ONE_DARK.bg);
egui::CentralPanel::default() egui::CentralPanel::default()
.frame(background_frame) .frame(background_frame)
.show(ctx, |ui| { .show(ctx, |ui| {
ui.heading(&self.name); ui.heading(self.name);
}); });
egui::Window::new("test window")
.collapsible(false)
.auto_sized()
.show(ctx, |ui| {
ui.heading(&self.name);
for _ in 0..10 {
ui.add(egui::Button::new(&self.name));
}
}
);
} }
} }

View File

@ -16,7 +16,7 @@ fn main() -> Result<(), eframe::Error> {
//Start rendering and run the application //Start rendering and run the application
eframe::run_native( eframe::run_native(
"egui-template", "AvBag",
options, options,
Box::new(|_cc| Ok(Box::new(App::default()))), Box::new(|_cc| Ok(Box::new(App::default()))),
) )