Reformat CRLF -> LF. Adding a WIP GUI too.

This commit is contained in:
Pcornat 2022-10-30 13:17:00 +01:00
parent 4ed370d51f
commit 4436c79c65
Signed by: Pcornat
GPG Key ID: 2F3932FF46D9ECA0

View File

@ -1,61 +1,76 @@
use eframe::egui;
fn main() {
let options = eframe::NativeOptions::default();
eframe::run_native(
"Billy Sheet editor",
options,
Box::new(|ctx| {
ctx.egui_ctx.options().screen_reader = true;
Box::new(Gui::default())
}),
);
let options = eframe::NativeOptions::default();
eframe::run_native(
"Billy Sheet editor",
options,
Box::new(|ctx| {
// ctx.egui_ctx.options().screen_reader = true;
Box::new(Gui::default())
}),
);
}
#[derive(Debug)]
struct Gui {
test: billy_sheet::sheet::CharacterSheet,
edit_mode: bool,
test: billy_sheet::sheet::CharacterSheet,
edit_mode: bool,
}
impl Default for Gui {
fn default() -> Self {
Self {
test: billy_sheet::sheet::CharacterSheet::default(),
edit_mode: true,
}
}
fn default() -> Self {
Self {
test: billy_sheet::sheet::CharacterSheet::default(),
edit_mode: true,
}
}
}
impl eframe::App for Gui {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::TopBottomPanel::top("menu").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
egui::widgets::global_dark_light_mode_buttons(ui);
ui.menu_button("File", |ui| {
if ui.button("Open (Ctrl + O)").clicked() {}
if ui.button("Quit (Ctrl + Q)").clicked() {
_frame.close();
}
});
if ui.button(format!("Edit mode {}", self.edit_mode)).clicked() {
self.edit_mode = !self.edit_mode;
}
});
});
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application");
ui.separator();
ui.vertical_centered_justified(|ui| {
ui.label("Hello");
// ui.text_edit_multiline(self.test.name());
});
});
if ctx
.input_mut()
.consume_key(egui::Modifiers::CTRL, egui::Key::Q)
{
_frame.close();
}
}
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::TopBottomPanel::top("menu").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
egui::widgets::global_dark_light_mode_buttons(ui);
ui.menu_button("File", |ui| {
if ui.button("Open (Ctrl + O)").clicked() {}
if ui.button("Quit (Ctrl + Q)").clicked() {
_frame.close();
}
});
if ui.button(format!("Edit mode {}", self.edit_mode)).clicked() {
self.edit_mode = !self.edit_mode.clone();
}
});
});
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application");
ui.separator();
ui.vertical_centered_justified(|ui| {
let mut tmp_str = self.test.character().to_string();
ui.text_edit_multiline(&mut tmp_str);
self.test.character = tmp_str;
});
ui.columns(2, |columns| {
// let mut col_1_ui = &mut columns[0];
// let mut col_2_ui = &mut columns[1];
columns[0].columns(2, |two_columns| {
// let mut in_col1 = &mut two_columns[0];
// let mut in_col2 = &mut two_columns[1];
two_columns[0].vertical_centered_justified(|ui| {
ui.heading("Habileté");
});
two_columns[1].vertical_centered_justified(|ui| {
ui.heading("Adresse");
});
});
});
});
if ctx
.input_mut()
.consume_key(egui::Modifiers::CTRL, egui::Key::Q)
{
_frame.close();
}
}
}