Skip to content

Commit

Permalink
Organizing IR UI
Browse files Browse the repository at this point in the history
  • Loading branch information
notdanilo committed Oct 26, 2023
1 parent d831d55 commit 08d7ac5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 68 deletions.
8 changes: 8 additions & 0 deletions ligen/ir/src/visibility.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Visibility enumeration.
use std::fmt::Display;

use crate::prelude::*;

#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, EnumIter)]
Expand All @@ -16,3 +18,9 @@ impl Default for Visibility {
Self::Public
}
}

impl Display for Visibility {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
3 changes: 2 additions & 1 deletion tools/editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ ligen-parsing.workspace = true
ligen-cargo.workspace = true
ligen-python-parser.workspace = true
egui_tiles = "0.2.0"
stacker = "0.1.15"
stacker = "0.1.15"
boolinator = "2.4.0"
57 changes: 0 additions & 57 deletions tools/editor/src/gui/ui/layout/editor/ir/menu_button.rs

This file was deleted.

2 changes: 0 additions & 2 deletions tools/editor/src/gui/ui/layout/editor/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ mod type_;
mod function;
mod object;
mod interface;
mod menu_button;

use egui_tiles::UiResponse;
pub use function::*;
Expand All @@ -26,7 +25,6 @@ pub use attributes::*;
pub use project::*;
pub use module::*;
pub use literal::*;
pub use menu_button::*;
pub use interface::*;
use ligen_ir::symbols::Symbols;
use crate::gui::ui::List;
Expand Down
18 changes: 13 additions & 5 deletions tools/editor/src/gui/ui/layout/editor/ir/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ impl Module {
impl Widget for Module {
type Input = ligen_ir::Module;
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, module: &mut ligen_ir::Module) {
CollapsingHeader::new(format!("{} - Symbols: {}", module.identifier, module.count_symbols()))
let text = if settings.display.show_visibility {
format!("{} {}", module.visibility, module.identifier)
} else {
module.identifier.to_string()
};
let text = format!("{} - Symbols: {}", text, module.count_symbols());
CollapsingHeader::new(text)
.id_source("module")
.show(ui, |ui| {
ui.horizontal_top(|ui| {
Visibility::new().show(settings, ui, &mut module.visibility);
Identifier::new().show(settings, ui, &mut module.identifier);
});
if settings.editor.editable_fields {
ui.horizontal_top(|ui| {
Visibility::new().show(settings, ui, &mut module.visibility);
Identifier::new().show(settings, ui, &mut module.identifier);
});
}
EditableList::new(format!("Types - Symbols: {}", module.types.len()), "Add type").show(settings, ui, &mut module.types, |ui, type_| {
TypeDefinition::new().show(settings, ui, type_);
});
Expand Down
3 changes: 2 additions & 1 deletion tools/editor/src/gui/ui/layout/editor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod ir;
pub mod settings;
pub mod widget;
pub mod widget;
pub mod menu_button;
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct DisplaySettings {
pub show_identifier: bool,
pub show_module: bool,
pub show_project: bool,
pub show_symbols_count: bool,
}

impl Default for DisplaySettings {
Expand All @@ -34,6 +35,7 @@ impl Default for DisplaySettings {
show_identifier: true,
show_module: true,
show_project: true,
show_symbols_count: true,
}
}
}
Expand All @@ -59,7 +61,8 @@ impl DisplaySettings {
ui.checkbox(&mut self.show_function, "Function");
ui.checkbox(&mut self.show_identifier, "Identifier");
ui.checkbox(&mut self.show_module, "Module");
ui.checkbox(&mut self.show_project, "Project");
ui.checkbox(&mut self.show_project, "Project");
ui.checkbox(&mut self.show_symbols_count, "Symbols Count");
});
}
}
4 changes: 3 additions & 1 deletion tools/editor/src/gui/ui/layout/menu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::gui::ui::editor::ir;
use crate::gui::ui::panes::Panes;
use crate::prelude::*;

use super::editor::menu_button::EditorMenuButton;

pub trait MenuButton {
fn menu_title(&self) -> String;
fn show_button(&self, ui: &mut egui::Ui, panes: &mut Panes);
Expand All @@ -20,7 +22,7 @@ pub struct Menu {
impl Menu {
pub fn new() -> Self {
let buttons: Vec<Box<dyn MenuButton>> = vec![
Box::new(ir::EditorMenuButton)
Box::new(EditorMenuButton)
];
Self { buttons }
}
Expand Down

0 comments on commit 08d7ac5

Please sign in to comment.