generated from luke-else/egui-template
Initial commit
This commit is contained in:
15
src/app/mod.rs
Normal file
15
src/app/mod.rs
Normal file
@ -0,0 +1,15 @@
|
||||
mod ui;
|
||||
|
||||
/// Stuct to store the state of the running application
|
||||
pub struct App {
|
||||
name: String
|
||||
}
|
||||
|
||||
impl Default for App {
|
||||
/// Creates the default startup state for the app;
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: String::from("Hello, World!")
|
||||
}
|
||||
}
|
||||
}
|
26
src/app/ui/mod.rs
Normal file
26
src/app/ui/mod.rs
Normal file
@ -0,0 +1,26 @@
|
||||
use crate::app::App;
|
||||
use crate::theme::onedark::ONE_DARK;
|
||||
|
||||
impl eframe::App for App {
|
||||
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);
|
||||
});
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
23
src/main.rs
Normal file
23
src/main.rs
Normal file
@ -0,0 +1,23 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
mod app;
|
||||
mod theme;
|
||||
use app::App;
|
||||
use egui::ViewportBuilder;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
// Log to stdout (if you run with `RUST_LOG=debug`).
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
// Setup the options for the default window
|
||||
let options = eframe::NativeOptions {
|
||||
viewport: ViewportBuilder::default().with_inner_size(egui::vec2(300.0, 200.0)),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
//Start rendering and run the application
|
||||
eframe::run_native(
|
||||
"egui-template",
|
||||
options,
|
||||
Box::new(|_cc| Ok(Box::new(App::default()))),
|
||||
)
|
||||
}
|
16
src/theme/mod.rs
Normal file
16
src/theme/mod.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use egui::Color32;
|
||||
|
||||
pub mod onedark;
|
||||
|
||||
//struct to store the colours used in a theme;
|
||||
#[allow(dead_code)]
|
||||
pub struct Theme {
|
||||
pub bg: Color32,
|
||||
pub fg: Color32,
|
||||
pub opt1: Color32,
|
||||
pub opt2: Color32,
|
||||
pub opt3: Color32,
|
||||
pub opt4: Color32,
|
||||
pub opt5: Color32,
|
||||
pub opt6: Color32,
|
||||
}
|
11
src/theme/onedark.rs
Normal file
11
src/theme/onedark.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use crate::theme::*;
|
||||
pub const ONE_DARK: Theme = Theme {
|
||||
bg: Color32::from_rgb(40, 44, 52), //Dark Grey
|
||||
fg: Color32::from_rgb(171, 178, 191), //Light Grey
|
||||
opt1: Color32::from_rgb(224, 108, 117), //Red
|
||||
opt2: Color32::from_rgb(152, 195, 121), //Green
|
||||
opt3: Color32::from_rgb(229, 192, 123), //Yellow
|
||||
opt4: Color32::from_rgb(97, 175, 239), //Blue
|
||||
opt5: Color32::from_rgb(198, 120, 221), //Purple
|
||||
opt6: Color32::from_rgb(86, 182, 194) //Turqoise
|
||||
};
|
Reference in New Issue
Block a user