Skip to content

Commit

Permalink
Make shader code editable.
Browse files Browse the repository at this point in the history
  • Loading branch information
antaalt committed Mar 20, 2024
1 parent a15df59 commit 990cbe3
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/graph/nodes/shader_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,29 @@ impl ProtosNode for ShaderNode {
fn ui(&self, _graph: &ProtosGraph, _node_id: NodeId, ui: &mut egui::Ui) {
gfx::visit_resource_mut(&self.shader, |shader| {
shader.visit_desc_mut(|desc| {
let language = "wgsl";
let language = "rs";
let theme = egui_extras::syntax_highlighting::CodeTheme::from_memory(ui.ctx());
egui_extras::syntax_highlighting::code_view_ui(ui, &theme, desc.shader.as_str(), language);
ui.text_edit_multiline(&mut desc.shader).changed()
let mut layouter = |ui: &egui::Ui, string: &str, wrap_width: f32| {
let mut layout_job =
egui_extras::syntax_highlighting::highlight(ui.ctx(), &theme, string, language);
layout_job.wrap.max_width = wrap_width;
ui.fonts(|f| f.layout_job(layout_job))
};

egui::ScrollArea::vertical().show(ui, |ui| {
ui.add(
egui::TextEdit::multiline(&mut desc.shader)
.font(egui::TextStyle::Monospace) // for cursor height
.code_editor()
.desired_rows(10)
.lock_focus(true)
.desired_width(f32::INFINITY)
.layouter(&mut layouter),
);
});
//egui_extras::syntax_highlighting::code_view_ui(ui, &theme, desc.shader.as_str(), language);
//ui.text_edit_multiline(&mut desc.shader).changed()
true
});
});
}
Expand Down

0 comments on commit 990cbe3

Please sign in to comment.