Created egui template application

This commit is contained in:
Luke Else 2023-03-21 21:40:39 +00:00
parent 8b2ae9facd
commit 07c1cb9ad5
3 changed files with 95 additions and 0 deletions

45
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'egui-template'",
"cargo": {
"args": [
"build",
"--bin=egui-template",
"--package=egui-template"
],
"filter": {
"name": "egui-template",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'egui-template'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=egui-template",
"--package=egui-template"
],
"filter": {
"name": "egui-template",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}

11
Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "egui-template"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
egui = "0.21.0"
eframe = "0.21.3"
tracing-subscriber = "0.3.16"

39
src/main.rs Normal file
View File

@ -0,0 +1,39 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
use eframe::egui;
fn main() -> Result<(), eframe::Error> {
// Log to stdout (if you run with `RUST_LOG=debug`).
tracing_subscriber::fmt::init();
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(150.0, 50.0)),
resizable: false,
..Default::default()
};
eframe::run_native(
"egui-template",
options,
Box::new(|_cc| Box::new(MyApp::default())),
)
}
struct MyApp {
name: String
}
impl Default for MyApp {
fn default() -> Self {
Self {
name: "Hello, World!".to_owned()
}
}
}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading(&self.name);
});
}
}