End of day commit.

This commit is contained in:
Florent DENEF 2022-12-01 16:54:33 +01:00
parent 877d300a5c
commit 09c02c8783
5 changed files with 24 additions and 4 deletions

View File

@ -8,6 +8,7 @@ edition = "2021"
[dependencies] [dependencies]
eframe = { version = "*", features = ["dark-light"] } eframe = { version = "*", features = ["dark-light"] }
egui = { version = "*", features = ["deadlock_detection"]} egui = { version = "*", features = ["deadlock_detection"]}
egui_file = "*"
json = "*" json = "*"
serde = { version = "*", features = ["derive"] } serde = { version = "*", features = ["derive"] }
serde_json = "*" serde_json = "*"

10
src/dialog/file_dialog.rs Normal file
View File

@ -0,0 +1,10 @@
pub struct FileDialog {
dialog: egui_file::FileDialog,
}
impl super::Dialog for FileDialog {
fn open(&mut self) {
self.dialog = egui_file::FileDialog::open_file(None);
self.dialog.open();
}
}

9
src/dialog/mod.rs Normal file
View File

@ -0,0 +1,9 @@
pub mod file_dialog;
pub trait View {
fn ui(&mut self, ui: &mut egui::Ui);
}
pub trait Dialog {
fn open(&mut self);
fn show(&mut self, ctx: &egui::Context);
}

View File

@ -1,2 +1,3 @@
pub mod gui; pub mod gui;
pub mod sheet; pub mod sheet;
pub mod dialog;

View File

@ -7,16 +7,14 @@ fn main() {
eframe::run_native( eframe::run_native(
"Billy Sheet editor", "Billy Sheet editor",
options, options,
Box::new(|_ctx| { Box::new(|_ctx| Box::<Gui>::default()),
// ctx.egui_ctx.options().screen_reader = true;
Box::<Gui>::default()
}),
); );
} }
#[derive(Debug)] #[derive(Debug)]
struct Gui { struct Gui {
sheet: billy_sheet::sheet::CharacterSheet, sheet: billy_sheet::sheet::CharacterSheet,
dialogs: Vec<impl billy_sheet::dialog::Dialog>,
edit_mode: bool, edit_mode: bool,
} }
@ -24,6 +22,7 @@ impl Default for Gui {
fn default() -> Self { fn default() -> Self {
Self { Self {
sheet: billy_sheet::sheet::CharacterSheet::default(), sheet: billy_sheet::sheet::CharacterSheet::default(),
dialogs: Vec::new(),
edit_mode: true, edit_mode: true,
} }
} }