Skip to content

Commit

Permalink
EditorSettings and DisplaySettings
Browse files Browse the repository at this point in the history
  • Loading branch information
notdanilo committed Oct 26, 2023
1 parent 582a304 commit d831d55
Show file tree
Hide file tree
Showing 35 changed files with 431 additions and 291 deletions.
21 changes: 11 additions & 10 deletions tools/editor/src/gui/ui/layout/editor/ir/attributes/attribute.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
pub use crate::prelude::*;

use crate::gui::ui::editor::ir::{Attributes, Identifier, Literal};
use crate::gui::ui::editor::{ir::{Attributes, Identifier, Literal}, widget::Widget, settings::Settings};

#[derive(Default)]
pub struct Attribute {
editable: bool
}
pub struct Attribute;

impl Attribute {
pub fn new() -> Self {
Default::default()
}
}

pub fn show(&mut self, ui: &mut egui::Ui, mut attribute: &mut ligen_ir::Attribute) {
impl Widget for Attribute {
type Input = ligen_ir::Attribute;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, mut attribute: &mut ligen_ir::Attribute) {
let variant_name = match attribute {
ligen_ir::Attribute::Literal(_) => "Literal",
ligen_ir::Attribute::Group(_, _) => "Group",
Expand All @@ -30,14 +31,14 @@ impl Attribute {

ui.horizontal_top(|ui| {
match &mut attribute {
ligen_ir::Attribute::Literal(literal) => Literal::new().show(ui, literal),
ligen_ir::Attribute::Literal(literal) => Literal::new().show(settings, ui, literal),
ligen_ir::Attribute::Group(identifier, attributes) => {
Identifier::new().show(ui, identifier);
Attributes::new().show(ui, attributes);
Identifier::new().show(settings, ui, identifier);
Attributes::new().show(settings, ui, attributes);
},
ligen_ir::Attribute::Named(identifier, literal) => {
Identifier::new().show(ui, identifier);
Literal::new().show(ui, literal);
Identifier::new().show(settings, ui, identifier);
Literal::new().show(settings, ui, literal);
}
}
});
Expand Down
18 changes: 10 additions & 8 deletions tools/editor/src/gui/ui/layout/editor/ir/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ pub use crate::prelude::*;
mod attribute;

pub use attribute::*;
use crate::gui::ui::EditableList;
use crate::gui::ui::{EditableList, editor::{widget::Widget, settings::Settings}};

pub struct Attributes {
}
#[derive(Default)]
pub struct Attributes;

impl Attributes {
pub fn new() -> Self {
Self {}
Default::default()
}
}

pub fn show(&mut self, ui: &mut egui::Ui, attributes: &mut ligen_ir::Attributes) {
impl Widget for Attributes {
type Input = ligen_ir::Attributes;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, attributes: &mut ligen_ir::Attributes) {
EditableList::new("Attributes", "Add attribute")
.show(ui, &mut attributes.attributes,|ui, attribute| {
Attribute::new().show(ui, attribute);
.show(settings, ui, &mut attributes.attributes,|ui, attribute| {
Attribute::new().show(settings, ui, attribute);
});

}
}
15 changes: 9 additions & 6 deletions tools/editor/src/gui/ui/layout/editor/ir/directory.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
pub use crate::prelude::*;

use std::path::PathBuf;
use crate::gui::ui::StringField;
use crate::gui::ui::{StringField, editor::{widget::Widget, settings::Settings}};

pub struct Directory {
}
#[derive(Default)]
pub struct Directory;

impl Directory {
pub fn new() -> Self {
Self {}
Default::default()
}
}

pub fn show(&mut self, ui: &mut egui::Ui, directory: &mut PathBuf) {
StringField::new().show(ui, directory)
impl Widget for Directory {
type Input = PathBuf;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, directory: &mut PathBuf) {
StringField::new().show(settings, ui, directory)
}
}
30 changes: 17 additions & 13 deletions tools/editor/src/gui/ui/layout/editor/ir/function/method.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
use crate::gui::ui::editor::settings::Settings;
use crate::gui::ui::editor::widget::Widget;
use crate::gui::ui::{EditableList, OptionalField};
use crate::gui::ui::editor::ir::{Attributes, Identifier, Parameter, Synchrony, Type, Visibility};
pub use crate::prelude::*;

pub struct Method {

}
#[derive(Default)]
pub struct Method;

impl Method {
pub fn new() -> Self {
Self {}
Default::default()
}
}

pub fn show(&mut self, ui: &mut egui::Ui, method: &mut ligen_ir::Method) {
impl Widget for Method {
type Input = ligen_ir::Method;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, method: &mut ligen_ir::Method) {
ui.horizontal_top(|ui| {
Visibility::new().show(ui, &mut method.visibility);
Synchrony::new().show(ui, &mut method.synchrony);
Identifier::new().show(ui, &mut method.identifier);
EditableList::new("Inputs", "Add input").show(ui, &mut method.inputs, |ui, parameter| {
Parameter::new().show(ui, parameter);
Visibility::new().show(settings, ui, &mut method.visibility);
Synchrony::new().show(settings, ui, &mut method.synchrony);
Identifier::new().show(settings, ui, &mut method.identifier);
EditableList::new("Inputs", "Add input").show(settings, ui, &mut method.inputs, |ui, parameter| {
Parameter::new().show(settings, ui, parameter);
});
OptionalField::new("Output").show(ui, &mut method.output, |ui, output| {
Type::new().show(ui, output);
OptionalField::new("Output").show(settings, ui, &mut method.output, |ui, output| {
Type::new().show(settings, ui, output);
});
Attributes::new().show(ui, &mut method.attributes);
Attributes::new().show(settings, ui, &mut method.attributes);
});
}
}
30 changes: 17 additions & 13 deletions tools/editor/src/gui/ui/layout/editor/ir/function/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::gui::ui::editor::settings::Settings;
use crate::gui::ui::editor::widget::Widget;
pub use crate::prelude::*;

mod synchrony;
Expand All @@ -11,27 +13,29 @@ pub use parameter::*;
use crate::gui::ui::{OptionalField, EditableList};
use crate::gui::ui::editor::ir::{Attributes, Identifier, Type, Visibility};

pub struct Function {

}
#[derive(Default)]
pub struct Function;

impl Function {
pub fn new() -> Self {
Self {}
Default::default()
}
}

pub fn show(&mut self, ui: &mut egui::Ui, function: &mut ligen_ir::Function) {
impl Widget for Function {
type Input = ligen_ir::Function;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, function: &mut ligen_ir::Function) {
ui.horizontal_top(|ui| {
Visibility::new().show(ui, &mut function.visibility);
Synchrony::new().show(ui, &mut function.synchrony);
Identifier::new().show(ui, &mut function.identifier);
EditableList::new("Inputs", "Add input").show(ui, &mut function.inputs, |ui, parameter| {
Parameter::new().show(ui, parameter);
Visibility::new().show(settings, ui, &mut function.visibility);
Synchrony::new().show(settings, ui, &mut function.synchrony);
Identifier::new().show(settings, ui, &mut function.identifier);
EditableList::new("Inputs", "Add input").show(settings, ui, &mut function.inputs, |ui, parameter| {
Parameter::new().show(settings, ui, parameter);
});
OptionalField::new("Output").show(ui, &mut function.output, |ui, output| {
Type::new().show(ui, output);
OptionalField::new("Output").show(settings, ui, &mut function.output, |ui, output| {
Type::new().show(settings, ui, output);
});
Attributes::new().show(ui, &mut function.attributes);
Attributes::new().show(settings, ui, &mut function.attributes);
});
}
}
20 changes: 11 additions & 9 deletions tools/editor/src/gui/ui/layout/editor/ir/function/parameter.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
pub use crate::prelude::*;

use crate::gui::ui::editor::ir::{Attributes, Identifier, Type};
use crate::gui::ui::editor::{ir::{Attributes, Identifier, Type}, widget::Widget, settings::Settings};

pub struct Parameter {

}
#[derive(Default)]
pub struct Parameter;

impl Parameter {
pub fn new() -> Self {
Self {}
Default::default()
}
}

pub fn show(&mut self, ui: &mut egui::Ui, parameter: &mut ligen_ir::Parameter) {
impl Widget for Parameter {
type Input = ligen_ir::Parameter;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, parameter: &mut ligen_ir::Parameter) {
ui.horizontal_top(|ui| {
Type::new().show(ui, &mut parameter.type_);
Identifier::new().show(ui, &mut parameter.identifier);
Attributes::new().show(ui, &mut parameter.attributes);
Type::new().show(settings, ui, &mut parameter.type_);
Identifier::new().show(settings, ui, &mut parameter.identifier);
Attributes::new().show(settings, ui, &mut parameter.attributes);
});
}
}
15 changes: 9 additions & 6 deletions tools/editor/src/gui/ui/layout/editor/ir/function/synchrony.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
pub use crate::prelude::*;

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

pub struct Synchrony {
}
#[derive(Default)]
pub struct Synchrony;

impl Synchrony {
pub fn new() -> Self {
Self {}
Default::default()
}
}

pub fn show(&mut self, ui: &mut egui::Ui, synchrony: &mut ligen_ir::Synchrony) {
EnumField::new().id_source("synchrony").show(ui, synchrony);
impl Widget for Synchrony {
type Input = ligen_ir::Synchrony;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, synchrony: &mut ligen_ir::Synchrony) {
EnumField::new().id_source("synchrony").show(settings, ui, synchrony);
}
}
14 changes: 6 additions & 8 deletions tools/editor/src/gui/ui/layout/editor/ir/identifier.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use crate::prelude::*;

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


#[derive(Default)]
Expand All @@ -12,13 +12,11 @@ impl Identifier {
pub fn new() -> Self {
Default::default()
}
}

pub fn editable(&mut self, editable: bool) -> &mut Self {
self.string_field.editable(editable);
self
}

pub fn show(&mut self, ui: &mut egui::Ui, identifier: &mut ligen_ir::Identifier) {
self.string_field.show(ui, identifier)
impl Widget for Identifier {
type Input = ligen_ir::Identifier;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, identifier: &mut ligen_ir::Identifier) {
self.string_field.show(settings, ui, identifier)
}
}
26 changes: 16 additions & 10 deletions tools/editor/src/gui/ui/layout/editor/ir/import.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
use crate::gui::ui::editor::settings::Settings;
use crate::gui::ui::editor::widget::Widget;
pub use crate::prelude::*;

use crate::gui::ui::editor::ir::{Attributes, Identifier, Path, Visibility};
use crate::gui::ui::OptionalField;

pub struct Import {}
#[derive(Default)]
pub struct Import;

impl Import {
pub fn new() -> Self {
Self {}
Default::default()
}
}

pub fn show(&mut self, ui: &mut egui::Ui, import: &mut ligen_ir::Import) {
ui.horizontal_top(|ui| {
Visibility::new().show(ui, &mut import.visibility);
Path::new().show(ui, &mut import.path);
OptionalField::new("as").show(ui, &mut import.renaming, |ui, renaming| {
Identifier::new().show(ui, renaming);
});
Attributes::new().show(ui, &mut import.attributes);
impl Widget for Import {
type Input = ligen_ir::Import;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, import: &mut ligen_ir::Import) {
ui.horizontal_top(|ui| {
Visibility::new().show(settings, ui, &mut import.visibility);
Path::new().show(settings, ui, &mut import.path);
OptionalField::new("as").show(settings, ui, &mut import.renaming, |ui, renaming| {
Identifier::new().show(settings, ui, renaming);
});
Attributes::new().show(settings, ui, &mut import.attributes);
});
}
}
38 changes: 17 additions & 21 deletions tools/editor/src/gui/ui/layout/editor/ir/interface.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
use crate::{prelude::*, gui::ui::EditableList};
use crate::{prelude::*, gui::ui::{EditableList, editor::{widget::Widget, settings::Settings}}};

use super::{Attributes, Method, Function, Object, Path, Identifier, Visibility};

#[derive(Default)]
pub struct Interface {
editable: bool
}
pub struct Interface;

impl Interface {
pub fn new() -> Self {
Default::default()
}
}

pub fn editable(&mut self, editable: bool) -> &mut Self {
self.editable = editable;
self
}

pub fn show(&mut self, ui: &mut egui::Ui, interface: &mut ligen_ir::Interface) {
impl Widget for Interface {
type Input = ligen_ir::Interface;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, interface: &mut ligen_ir::Interface) {
ui.vertical(|ui| {
ui.horizontal_top(|ui| {
Visibility::new().show(ui, &mut interface.visibility);
Identifier::new().show(ui, &mut interface.identifier);
Visibility::new().show(settings, ui, &mut interface.visibility);
Identifier::new().show(settings, ui, &mut interface.identifier);
});
EditableList::new(format!("Objects - Symbols: {}", interface.objects.len()), "Add object").show(ui, &mut interface.objects, |ui, object| {
Object::new().show(ui, object);
EditableList::new(format!("Objects - Symbols: {}", interface.objects.len()), "Add object").show(settings, ui, &mut interface.objects, |ui, object| {
Object::new().show(settings, ui, object);
});
EditableList::new(format!("Functions - Symbols: {}", interface.functions.len()), "Add function").show(ui, &mut interface.functions, |ui, function| {
Function::new().show(ui, function);
EditableList::new(format!("Functions - Symbols: {}", interface.functions.len()), "Add function").show(settings, ui, &mut interface.functions, |ui, function| {
Function::new().show(settings, ui, function);
});
EditableList::new(format!("Methods - Symbols: {}", interface.methods.len()), "Add method").show(ui, &mut interface.methods, |ui, function| {
Method::new().show(ui, function);
EditableList::new(format!("Methods - Symbols: {}", interface.methods.len()), "Add method").show(settings, ui, &mut interface.methods, |ui, function| {
Method::new().show(settings, ui, function);
});
EditableList::new("Interfaces", "Add interface").show(ui, &mut interface.interfaces, |ui, interface| {
Path::new().show(ui, interface);
EditableList::new("Interfaces", "Add interface").show(settings, ui, &mut interface.interfaces, |ui, interface| {
Path::new().show(settings, ui, interface);
});
Attributes::new().show(ui, &mut interface.attributes);
Attributes::new().show(settings, ui, &mut interface.attributes);
});
}
}
Loading

0 comments on commit d831d55

Please sign in to comment.