116 lines
3.5 KiB
Rust
116 lines
3.5 KiB
Rust
pub struct UserInterface {
|
|
developer_mode: bool,
|
|
show_profiler: bool,
|
|
quit: bool,
|
|
show_about: bool,
|
|
log_contents: String,
|
|
}
|
|
|
|
impl UserInterface {
|
|
pub fn new() -> Self {
|
|
Self {
|
|
developer_mode: true,
|
|
show_profiler: false,
|
|
quit: false,
|
|
show_about: false,
|
|
log_contents: "Hello logging!\n".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn should_quit(&self) -> bool {
|
|
self.quit
|
|
}
|
|
|
|
pub fn run(&mut self, ctx: &egui::Context) {
|
|
egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| {
|
|
egui::menu::bar(ui, |ui| {
|
|
ui.menu_button("File", |ui| {
|
|
if self.developer_mode {
|
|
if ui.button("fuck").clicked() {
|
|
println!("fuck");
|
|
}
|
|
}
|
|
|
|
if ui.button("Save").clicked() {
|
|
println!("Saving!");
|
|
ui.close_menu();
|
|
}
|
|
|
|
if ui.button("Save as...").clicked() {
|
|
println!("Saving as!");
|
|
ui.close_menu();
|
|
}
|
|
|
|
if ui.button("Open...").clicked() {
|
|
println!("Opening!");
|
|
ui.close_menu();
|
|
}
|
|
|
|
if ui.button("Quit").clicked() {
|
|
println!("Quitting!");
|
|
ui.close_menu();
|
|
self.quit = true;
|
|
}
|
|
});
|
|
|
|
ui.menu_button("Edit", |ui| {
|
|
if ui.button("Undo").clicked() {
|
|
println!("Undoing!");
|
|
}
|
|
|
|
if ui.button("Redo").clicked() {
|
|
println!("Redoing!");
|
|
}
|
|
});
|
|
|
|
ui.menu_button("View", |ui| {
|
|
ui.checkbox(&mut self.developer_mode, "Developer mode");
|
|
ui.checkbox(&mut self.show_profiler, "Show profiler");
|
|
});
|
|
|
|
ui.menu_button("Help", |ui| {
|
|
if ui.button("About").clicked() {
|
|
self.show_about = true;
|
|
ui.close_menu();
|
|
}
|
|
});
|
|
})
|
|
});
|
|
|
|
egui::Window::new("example_window").show(ctx, |ui| {
|
|
ui.heading("Hello world!");
|
|
});
|
|
|
|
if self.show_about {
|
|
egui::Window::new("About")
|
|
.open(&mut self.show_about)
|
|
.resizable(false)
|
|
.collapsible(false)
|
|
.show(ctx, |ui| {
|
|
ui.vertical_centered(|ui| {
|
|
ui.heading("Cyborg Editor");
|
|
});
|
|
});
|
|
}
|
|
|
|
egui::TopBottomPanel::bottom("info_panel")
|
|
.resizable(true)
|
|
.show(ctx, |ui| {
|
|
ui.heading("Log Output");
|
|
|
|
egui::containers::ScrollArea::vertical()
|
|
.auto_shrink([false, false])
|
|
.max_width(f32::INFINITY)
|
|
.max_height(f32::INFINITY)
|
|
.show(ui, |ui| {
|
|
let text_edit = egui::TextEdit::multiline(&mut self.log_contents)
|
|
.desired_width(f32::INFINITY)
|
|
.frame(false);
|
|
ui.add(text_edit);
|
|
});
|
|
});
|
|
|
|
egui::CentralPanel::default().show(ctx, |ui| {});
|
|
}
|
|
}
|