Skip to content

Commit

Permalink
init blank egui project
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenLoc committed Mar 27, 2023
1 parent ef56549 commit fc54f9b
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .idea/TypeFast.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
egui = "0.21.0"
eframe = { version = "0.21.0", default-features = false, features = [
"accesskit", # Make egui comptaible with screen readers. NOTE: adds a lot of dependencies.
"default_fonts", # Embed the default egui fonts.
"glow", # Use the glow rendering backend. Alternative: "wgpu".
"persistence", # Enable restoring app state when restarting the app.
] }
tracing-subscriber = "0.3"
serde = { version = "1", features = ["derive"] }
6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@_list:
just --list --unsorted


run:
cargo run
80 changes: 80 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/// We derive Deserialize/Serialize so we can persist app state on shutdown.
#[derive(serde::Deserialize, serde::Serialize)]
#[serde(default)] // if we add new fields, give them default values when deserializing old state
pub struct TypeFastApp {
label: String,
}

impl Default for TypeFastApp {
fn default() -> Self {
Self {
// Example stuff:
label: "Hello World!".to_owned(),
}
}
}

impl TypeFastApp {
/// Called once before the first frame.
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
if let Some(storage) = cc.storage {
return eframe::get_value(storage, eframe::APP_KEY).unwrap_or_default();
}

Default::default()
}
}

impl eframe::App for TypeFastApp {
/// Called each time the UI needs repainting, which may be many times per second.
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let Self { label: _} = self;

// Examples of how to create different panels and windows.
// Pick whichever suits you.
// Tip: a good default choice is to just keep the `CentralPanel`.
// For inspiration and more examples, go to https://emilk.github.io/egui

egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar:
egui::menu::bar(ui, |ui| {
ui.menu_button("File", |ui| {
if ui.button("Quit").clicked() {
_frame.close();
}
});
});
});

egui::SidePanel::left("side_panel_1").show(ctx, |ui| {
ui.heading("Left");
} );



egui::SidePanel::right("side_panel_0").show(ctx, |ui| {
ui.heading("Right");



ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
ui.label("TypeFast");
});
});
});

egui::CentralPanel::default().show(ctx, |ui| {

ui.heading("central");

});
}

/// Called by the frame work to save state before shutdown.
fn save(&mut self, storage: &mut dyn eframe::Storage) {
eframe::set_value(storage, eframe::APP_KEY, self);
}
}
20 changes: 18 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
fn main() {
println!("Hello, world!");
#![warn(clippy::all, rust_2018_idioms)]
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release

use crate::app::TypeFastApp;

mod app;


fn main() -> eframe::Result<()> {
// Log to stdout (if you run with `RUST_LOG=debug`).
tracing_subscriber::fmt::init();

let native_options = eframe::NativeOptions::default();
eframe::run_native(
"TypeFast",
native_options,
Box::new(|cc| Box::new(TypeFastApp::new(cc))),
)
}

0 comments on commit fc54f9b

Please sign in to comment.