-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
157 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::{prelude::*, gui::ui::panes::Pane}; | ||
use ligen_parsing::parser::ParserConfigSet; | ||
use ligen_python_parser::parser::{PythonParserConfig, PythonParser}; | ||
|
||
pub mod parser; | ||
pub use parser::*; | ||
|
||
use crate::gui::ui::panes::PaneManager; | ||
|
||
use super::{ir::Editor, widget::Widget, settings::Settings}; | ||
|
||
pub struct Parsing { | ||
parsers: Vec<Parser> | ||
} | ||
|
||
impl Default for Parsing { | ||
fn default() -> Self { | ||
let parsers = vec![ | ||
Parser::new(Box::new(PythonParser::default())) | ||
]; | ||
Self { parsers } | ||
} | ||
} | ||
|
||
impl Parsing { | ||
pub fn new() -> Self { | ||
Default::default() | ||
} | ||
} | ||
|
||
impl Pane for Parsing { | ||
fn title(&self) -> String { | ||
"Parsing".to_string() | ||
} | ||
fn show(&mut self, ui: &mut ligen_gui_runtime::egui::Ui, pane_manager: &mut PaneManager) -> egui_tiles::UiResponse { | ||
let mut settings = Settings::default(); | ||
settings.editor.editable_fields = true; | ||
for (index, parser) in self.parsers.iter_mut().enumerate() { | ||
ui.push_id(index, |ui| { | ||
parser.show(&settings, ui, pane_manager); | ||
}); | ||
} | ||
Default::default() | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tools/editor/src/gui/ui/layout/editor/parsing/parser/config.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::{prelude::*, gui::ui::editor::ir::{Path, Literal}}; | ||
use ligen_parsing::parser::{self, ParserConfigSet}; | ||
|
||
use crate::gui::ui::editor::{widget::Widget, settings::Settings}; | ||
|
||
#[derive(Default)] | ||
pub struct ParserConfig {} | ||
|
||
impl ParserConfig { | ||
pub fn new() -> Self { | ||
Default::default() | ||
} | ||
} | ||
|
||
impl Widget for ParserConfig { | ||
type Input = parser::ParserConfig; | ||
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, input: &mut Self::Input) { | ||
ui.label("Configuration"); | ||
for (index, (mut path, mut literal)) in input.iter().enumerate() { | ||
ui.push_id(index, |ui| { | ||
ui.horizontal(|ui| { | ||
Path::default().show(settings, ui, &mut path); | ||
Literal::default().show(settings, ui, &mut literal); | ||
input.set(path, literal); | ||
}); | ||
}); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
tools/editor/src/gui/ui/layout/editor/parsing/parser/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
pub mod config; | ||
pub use config::*; | ||
|
||
use crate::{prelude::*, gui::ui::{editor::{widget::Widget, settings::Settings, ir::Editor}, panes::PaneManager}}; | ||
use std::path::Path; | ||
use ligen_parsing::parser::{self, Parser as ParserTrait, ParserConfigSet, ParserConfig, ParserConfigGet}; | ||
use ligen_python_parser::parser::{PythonParser, PythonParserConfig}; | ||
|
||
pub struct Parser { | ||
parser: Box<dyn for<'a> parser::Parser<&'a Path, Output = ligen_ir::Library>>, | ||
config: ParserConfig | ||
} | ||
|
||
impl Parser { | ||
pub fn new(parser: Box<dyn for<'a> parser::Parser<&'a Path, Output = ligen_ir::Library>>) -> Self { | ||
let config = parser.config(); | ||
Self { parser, config } | ||
} | ||
} | ||
|
||
impl Widget for Parser { | ||
type Input = PaneManager; | ||
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, pane_manager: &mut PaneManager) { | ||
ui.indent("indent", |ui| { | ||
ui.add_space(16.0); | ||
ui.label(self.parser.name()); | ||
config::ParserConfig::new().show(settings, ui, &mut self.config); | ||
if ui.button("Parse").clicked() { | ||
let entry = rfd::FileDialog::new() | ||
.pick_folder(); | ||
if let Some(entry) = entry { | ||
stacker::grow(1024 * 1024 * 10, || { | ||
let library = self.parser.parse(entry.as_path(), &self.config).unwrap(); | ||
pane_manager.new_pane(Box::new(Editor::new(library))); | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters