Skip to content

Commit

Permalink
Providing generation result message.
Browse files Browse the repository at this point in the history
  • Loading branch information
notdanilo committed Nov 6, 2023
1 parent 8a1c865 commit 2897671
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
17 changes: 12 additions & 5 deletions tools/editor/src/gui/ui/layout/editor/generators/generator.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
use ligen_traits::generator::file_generator::FileGenerator;
use ligen_cargo::parser::library;
use ligen_traits::generator;

use crate::prelude::*;
use crate::gui::ui::editor::{widget::Widget, settings::Settings};

pub struct Generator {
generator: Box<dyn FileGenerator>
generator: Box<dyn generator::Generator>,
result: String
}

impl Generator {
pub fn new<T: FileGenerator + 'static>(generator: T) -> Self {
pub fn new<T: generator::Generator + 'static>(generator: T) -> Self {
let generator = Box::new(generator);
Self { generator }
let result = Default::default();
Self { generator, result }
}
}

Expand All @@ -19,7 +22,11 @@ impl Widget for Generator {
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, input: &mut Self::Input) {
ui.label("Generator");
if ui.button("Generate").clicked() {

match self.generator.generate(input) {
Ok(_) => self.result = "Success".to_string(),
Err(error) => self.result = format!("Error: {:?}", error)
};
}
ui.label(&self.result);
}
}
8 changes: 5 additions & 3 deletions tools/editor/src/gui/ui/layout/editor/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ pub struct Editor {
library: ligen_ir::Library,
filter: String,
settings: Settings,
symbols: Symbols
symbols: Symbols,
generators: Generators
}

impl Editor {
pub fn new(library: ligen_ir::Library) -> Self {
let filter = Default::default();
let symbols = Symbols::new(&library);
let display_settings = Default::default();
Self { library, symbols, filter, settings: display_settings }
let generators = Default::default();
Self { library, symbols, filter, settings: display_settings, generators }
}
}

Expand Down Expand Up @@ -80,7 +82,7 @@ impl Pane for Editor {
ui.separator();
Library::new().show(&self.settings, ui, &mut self.library);
ui.separator();
Generators::new().show(&self.settings, ui, &mut self.library);
self.generators.show(&self.settings, ui, &mut self.library);
ui.separator();
ui.horizontal(|ui| {
ui.label("Filter");
Expand Down

0 comments on commit 2897671

Please sign in to comment.