-
-
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.
Adding more Metadata and displaying them on the editor
- Loading branch information
Showing
17 changed files
with
284 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# IntelliJ idea auto-generated files | ||
.idea | ||
.gradle | ||
.vscode | ||
|
||
# Space for testing things | ||
workbench | ||
|
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,15 @@ | ||
use crate::prelude::*; | ||
|
||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] | ||
pub struct Author { | ||
pub name: String, | ||
pub email: String, | ||
} | ||
|
||
impl Author { | ||
pub fn new(name: impl Into<String>, email: impl Into<String>) -> Self { | ||
let name = name.into(); | ||
let email = email.into(); | ||
Self { name, email } | ||
} | ||
} |
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,18 @@ | ||
use crate::{prelude::*, VersionRequirement}; | ||
|
||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] | ||
pub struct Dependency { | ||
pub identifier: String, | ||
pub requirement: VersionRequirement, | ||
} | ||
|
||
impl TryFrom<&str> for Dependency { | ||
type Error = Error; | ||
fn try_from(value: &str) -> Result<Self> { | ||
let mut parts = value.split(' '); | ||
let identifier = parts.next().ok_or("Failed to get identifier.")?.to_string(); | ||
let requirement = parts.next().ok_or("Failed to get requirement.")?; | ||
let requirement = VersionRequirement::try_from(requirement)?; | ||
Ok(Self { identifier, requirement }) | ||
} | ||
} |
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,7 @@ | ||
use crate::{prelude::*, VersionRequirement}; | ||
|
||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] | ||
pub struct Language { | ||
pub name: String, | ||
pub requirement: VersionRequirement, | ||
} |
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 |
---|---|---|
@@ -1,9 +1,24 @@ | ||
use crate::prelude::*; | ||
|
||
pub mod language; | ||
pub mod dependency; | ||
pub mod author; | ||
pub mod version; | ||
|
||
pub use language::*; | ||
pub use dependency::*; | ||
pub use author::*; | ||
pub use version::*; | ||
|
||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] | ||
pub struct Metadata { | ||
pub version: Version, | ||
pub language: Language, | ||
pub summary: String, | ||
pub description: String, | ||
pub homepage: String, | ||
pub authors: Vec<Author>, | ||
pub dependencies: Vec<Dependency>, | ||
pub keywords: Vec<String>, | ||
pub license: String, | ||
} |
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,23 @@ | ||
use crate::prelude::*; | ||
|
||
#[derive(Shrinkwrap, Debug, Clone, Serialize, Deserialize, PartialEq)] | ||
#[shrinkwrap(mutable)] | ||
pub struct VersionRequirement(pub semver::VersionReq); | ||
|
||
impl TryFrom<&str> for VersionRequirement { | ||
type Error = Error; | ||
fn try_from(value: &str) -> Result<Self> { | ||
let value = value.replace("==", "="); | ||
let version = | ||
semver::VersionReq::parse(&value) | ||
.map_err(|e| Error::Message(format!("Failed to parse version requirement: {}, Reason: {}", value, e)))?; | ||
let version = Self(version); | ||
Ok(version) | ||
} | ||
} | ||
|
||
impl Default for VersionRequirement { | ||
fn default() -> Self { | ||
Self(semver::VersionReq::parse("*").unwrap()) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
tools/editor/src/gui/ui/layout/editor/ir/library/metadata/author.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,17 @@ | ||
use crate::{prelude::*, gui::ui::{editor::{widget::{Widget, WidgetFor}, settings::Settings}, Labeled, StringField}}; | ||
|
||
#[derive(Default)] | ||
pub struct Author {} | ||
|
||
impl Widget for Author { | ||
type Input = ligen_ir::Author; | ||
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, input: &mut Self::Input) { | ||
Labeled::new(&input.name).show(settings, ui, |ui| { | ||
StringField::default().show(settings, ui, &mut input.email); | ||
}); | ||
} | ||
} | ||
|
||
impl WidgetFor for ligen_ir::Author { | ||
type Widget = Author; | ||
} |
17 changes: 17 additions & 0 deletions
17
tools/editor/src/gui/ui/layout/editor/ir/library/metadata/dependency.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,17 @@ | ||
use crate::{prelude::*, gui::ui::{editor::{widget::{Widget, WidgetFor}, settings::Settings}, Labeled, StringField}}; | ||
|
||
#[derive(Default)] | ||
pub struct Dependency {} | ||
|
||
impl Widget for Dependency { | ||
type Input = ligen_ir::Dependency; | ||
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, input: &mut Self::Input) { | ||
Labeled::new(&input.identifier).show(settings, ui, |ui| { | ||
StringField::default().show(settings, ui, &mut input.requirement); | ||
}); | ||
} | ||
} | ||
|
||
impl WidgetFor for ligen_ir::Dependency { | ||
type Widget = Dependency; | ||
} |
28 changes: 28 additions & 0 deletions
28
tools/editor/src/gui/ui/layout/editor/ir/library/metadata/language.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,28 @@ | ||
use ligen_gui_runtime::egui::CollapsingHeader; | ||
|
||
use crate::{prelude::*, gui::ui::{editor::widget::Widget, StringField, Labeled}}; | ||
|
||
#[derive(Default)] | ||
pub struct Language {} | ||
|
||
impl Language { | ||
pub fn new() -> Self { | ||
Default::default() | ||
} | ||
} | ||
|
||
impl Widget for Language { | ||
type Input = ligen_ir::Language; | ||
fn show(&mut self, settings: &crate::gui::ui::editor::settings::Settings, ui: &mut egui::Ui, input: &mut Self::Input) { | ||
CollapsingHeader::new("Language") | ||
.default_open(false) | ||
.show(ui, |ui| { | ||
Labeled::new("Name").show(settings, ui, |ui| { | ||
StringField::default().show(settings, ui, &mut input.name); | ||
}); | ||
Labeled::new("Requirement").show(settings, ui, |ui| { | ||
StringField::default().show(settings, ui, &mut input.requirement); | ||
}); | ||
}); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
tools/editor/src/gui/ui/layout/editor/ir/library/metadata/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,46 @@ | ||
pub mod language; | ||
pub use language::*; | ||
|
||
pub mod author; | ||
pub use author::*; | ||
|
||
pub mod dependency; | ||
pub use dependency::*; | ||
|
||
use ligen_gui_runtime::egui::CollapsingHeader; | ||
|
||
use crate::{prelude::*, gui::ui::{editor::{widget::Widget, settings::Settings}, StringField, SubWidgets}}; | ||
use crate::gui::ui::Labeled; | ||
|
||
#[derive(Default)] | ||
pub struct Metadata {} | ||
|
||
impl Metadata { | ||
pub fn new() -> Self { | ||
Default::default() | ||
} | ||
} | ||
|
||
impl Widget for Metadata { | ||
type Input = ligen_ir::Metadata; | ||
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, input: &mut Self::Input) { | ||
CollapsingHeader::new("Metadata") | ||
.show(ui, |ui| { | ||
Labeled::new("Version").show(settings, ui, |ui| { | ||
StringField::default().show(settings, ui, &mut input.version); | ||
}); | ||
Labeled::new("Homepage").show(settings, ui, |ui| { | ||
StringField::default().show(settings, ui, &mut input.homepage); | ||
}); | ||
Labeled::new("Summary").show(settings, ui, |ui| { | ||
StringField::default().show(settings, ui, &mut input.summary); | ||
}); | ||
Language::new().show(settings, ui, &mut input.language); | ||
SubWidgets::new("Author").show(settings, ui, &mut input.authors); | ||
SubWidgets::new_irregular("Dependency", "Dependencies").show(settings, ui, &mut input.dependencies); | ||
CollapsingHeader::new("Description").show(ui, |ui| { | ||
StringField::default().show(settings, ui, &mut input.description); | ||
}); | ||
}); | ||
} | ||
} |
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,22 @@ | ||
use crate::prelude::*; | ||
use crate::gui::ui::editor::{widget::Widget, settings::Settings}; | ||
|
||
|
||
pub struct Labeled { | ||
label: String | ||
} | ||
|
||
impl Labeled { | ||
pub fn new(label: impl Into<String>) -> Self { | ||
let label = label.into(); | ||
Self { label } | ||
} | ||
|
||
pub fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, mut show: impl FnMut(&mut egui::Ui)) { | ||
ui.horizontal(|ui| { | ||
ui.label(&self.label); | ||
show(ui); | ||
}); | ||
|
||
} | ||
} |
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