Skip to content

Commit 3657b37

Browse files
TrueDoctorKeavon
andauthored
Deprecate LetNodes in favor of new scope API (#1814)
* WIP * Start deprecating let nodes * Replace WasmEditorApi network imports with new Scope input * Add missing unwrap * Add #[serde(default)] to scope_injections * Restructure WasmEditorApi definition to be available as a TaggedValue * Fix text node * Use stable toolchain in nix shell again * Code review * FIx text node and remove all remaining warnings * Require executor input to be 'static --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
1 parent a17ed68 commit 3657b37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+776
-982
lines changed

Cargo.lock

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ resolver = "2"
3030
dyn-any = { path = "libraries/dyn-any", features = ["derive", "glam"] }
3131
graphene-core = { path = "node-graph/gcore" }
3232
graph-craft = { path = "node-graph/graph-craft", features = ["serde"] }
33+
wgpu-executor = { path = "node-graph/wgpu-executor" }
3334
bezier-rs = { path = "libraries/bezier-rs", features = ["dyn-any"] }
3435
node-macro = { path = "node-graph/node-macro" }
3536

editor/src/dispatcher.rs

Lines changed: 67 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -410,65 +410,78 @@ mod test {
410410
assert_eq!(layers_after_copy[5], shape_id);
411411
}
412412

413-
#[tokio::test]
413+
#[test]
414414
/// This test will fail when you make changes to the underlying serialization format for a document.
415-
async fn check_if_demo_art_opens() {
416-
use crate::messages::layout::utility_types::widget_prelude::*;
417-
418-
let print_problem_to_terminal_on_failure = |value: &String| {
419-
println!();
420-
println!("-------------------------------------------------");
421-
println!("Failed test due to receiving a DisplayDialogError while loading a Graphite demo file.");
422-
println!();
423-
println!("DisplayDialogError details:");
424-
println!();
425-
println!("Description: {value}");
426-
println!("-------------------------------------------------");
427-
println!();
428-
429-
panic!()
430-
};
431-
432-
init_logger();
433-
let mut editor = Editor::create();
434-
435-
for (document_name, _, file_name) in crate::messages::dialog::simple_dialogs::ARTWORK {
436-
let document_serialized_content = std::fs::read_to_string(format!("../demo-artwork/{file_name}")).unwrap();
437-
438-
assert_eq!(
439-
document_serialized_content.lines().count(),
440-
1,
441-
"Demo artwork '{document_name}' has more than 1 line (remember to open and re-save it in Graphite)",
442-
);
443-
444-
let responses = editor.handle_message(PortfolioMessage::OpenDocumentFile {
445-
document_name: document_name.into(),
446-
document_serialized_content,
447-
});
448-
println!("Responses:\n{responses:#?}");
449-
450-
// Check if the graph renders
451-
let portfolio = &mut editor.dispatcher.message_handlers.portfolio_message_handler;
452-
portfolio
453-
.executor
454-
.submit_node_graph_evaluation(portfolio.documents.get_mut(&portfolio.active_document_id.unwrap()).unwrap(), glam::UVec2::ONE)
455-
.expect("submit_node_graph_evaluation failed");
456-
crate::node_graph_executor::run_node_graph().await;
457-
let mut messages = VecDeque::new();
458-
editor.poll_node_graph_evaluation(&mut messages).expect("Graph should render");
459-
460-
for response in responses {
461-
// Check for the existence of the file format incompatibility warning dialog after opening the test file
462-
if let FrontendMessage::UpdateDialogColumn1 { layout_target: _, diff } = response {
463-
if let DiffUpdate::SubLayout(sub_layout) = &diff[0].new_value {
464-
if let LayoutGroup::Row { widgets } = &sub_layout[0] {
465-
if let Widget::TextLabel(TextLabel { value, .. }) = &widgets[0].widget {
466-
print_problem_to_terminal_on_failure(value);
415+
fn check_if_demo_art_opens() {
416+
futures::executor::block_on(async {
417+
use crate::messages::layout::utility_types::widget_prelude::*;
418+
419+
let print_problem_to_terminal_on_failure = |value: &String| {
420+
println!();
421+
println!("-------------------------------------------------");
422+
println!("Failed test due to receiving a DisplayDialogError while loading a Graphite demo file.");
423+
println!();
424+
println!("DisplayDialogError details:");
425+
println!();
426+
println!("Description: {value}");
427+
println!("-------------------------------------------------");
428+
println!();
429+
430+
panic!()
431+
};
432+
433+
init_logger();
434+
let mut editor = Editor::create();
435+
436+
// UNCOMMENT THIS FOR RUNNING UNDER MIRI
437+
//
438+
// let files = [
439+
// include_str!("../../demo-artwork/isometric-fountain.graphite"),
440+
// include_str!("../../demo-artwork/just-a-potted-cactus.graphite"),
441+
// include_str!("../../demo-artwork/procedural-string-lights.graphite"),
442+
// include_str!("../../demo-artwork/red-dress.graphite"),
443+
// include_str!("../../demo-artwork/valley-of-spires.graphite"),
444+
// ];
445+
// for (id, document_serialized_content) in files.iter().enumerate() {
446+
// let document_name = format!("document {id}");
447+
448+
for (document_name, _, file_name) in crate::messages::dialog::simple_dialogs::ARTWORK {
449+
let document_serialized_content = std::fs::read_to_string(format!("../demo-artwork/{file_name}")).unwrap();
450+
451+
assert_eq!(
452+
document_serialized_content.lines().count(),
453+
1,
454+
"Demo artwork '{document_name}' has more than 1 line (remember to open and re-save it in Graphite)",
455+
);
456+
457+
let responses = editor.handle_message(PortfolioMessage::OpenDocumentFile {
458+
document_name: document_name.into(),
459+
document_serialized_content: document_serialized_content.into(),
460+
});
461+
462+
// Check if the graph renders
463+
let portfolio = &mut editor.dispatcher.message_handlers.portfolio_message_handler;
464+
portfolio
465+
.executor
466+
.submit_node_graph_evaluation(portfolio.documents.get_mut(&portfolio.active_document_id.unwrap()).unwrap(), glam::UVec2::ONE)
467+
.expect("submit_node_graph_evaluation failed");
468+
crate::node_graph_executor::run_node_graph().await;
469+
let mut messages = VecDeque::new();
470+
editor.poll_node_graph_evaluation(&mut messages).expect("Graph should render");
471+
472+
for response in responses {
473+
// Check for the existence of the file format incompatibility warning dialog after opening the test file
474+
if let FrontendMessage::UpdateDialogColumn1 { layout_target: _, diff } = response {
475+
if let DiffUpdate::SubLayout(sub_layout) = &diff[0].new_value {
476+
if let LayoutGroup::Row { widgets } = &sub_layout[0] {
477+
if let Widget::TextLabel(TextLabel { value, .. }) = &widgets[0].widget {
478+
print_problem_to_terminal_on_failure(value);
479+
}
467480
}
468481
}
469482
}
470483
}
471484
}
472-
}
485+
});
473486
}
474487
}

editor/src/messages/dialog/export_dialog/export_dialog_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl LayoutHolder for ExportDialogMessageHandler {
8484
NumberInput::new(Some(self.scale_factor))
8585
.unit("")
8686
.min(0.)
87-
.max((1_u64 << std::f64::MANTISSA_DIGITS) as f64)
87+
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
8888
.disabled(self.file_type == FileType::Svg)
8989
.on_update(|number_input: &NumberInput| ExportDialogMessage::ScaleFactor(number_input.value.unwrap()).into())
9090
.min_width(200)

editor/src/messages/dialog/new_document_dialog/new_document_dialog_message_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
9595
.label("W")
9696
.unit(" px")
9797
.min(0.)
98-
.max((1_u64 << std::f64::MANTISSA_DIGITS) as f64)
98+
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
9999
.is_integer(true)
100100
.disabled(self.infinite)
101101
.min_width(100)
@@ -106,7 +106,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
106106
.label("H")
107107
.unit(" px")
108108
.min(0.)
109-
.max((1_u64 << std::f64::MANTISSA_DIGITS) as f64)
109+
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
110110
.is_integer(true)
111111
.disabled(self.infinite)
112112
.min_width(100)

editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl PreferencesDialogMessageHandler {
6363
NumberInput::new(Some(preferences.imaginate_refresh_frequency))
6464
.unit(" seconds")
6565
.min(0.)
66-
.max((1_u64 << std::f64::MANTISSA_DIGITS) as f64)
66+
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
6767
.min_width(200)
6868
.on_update(|number_input: &NumberInput| PreferencesMessage::ImaginateRefreshFrequency { seconds: number_input.value.unwrap() }.into())
6969
.widget_holder(),

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
306306
let insert_index = parent
307307
.children(self.metadata())
308308
.enumerate()
309-
.find_map(|(index, item)| self.selected_nodes.selected_layers(self.metadata()).any(|x| x == item).then_some(index as usize))
309+
.find_map(|(index, item)| self.selected_nodes.selected_layers(self.metadata()).any(|x| x == item).then_some(index))
310310
.unwrap_or(0);
311311

312312
// Store a history step before doing anything

editor/src/messages/portfolio/document/graph_operation/utility_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<'a> ModifyInputsContext<'a> {
321321
pub fn insert_text(&mut self, text: String, font: Font, size: f64, layer: NodeId) {
322322
let text = resolve_document_node_type("Text").expect("Text node does not exist").to_document_node(
323323
[
324-
NodeInput::network(graph_craft::concrete!(graphene_std::wasm_application_io::WasmEditorApi), 0),
324+
NodeInput::scope("editor-api"),
325325
NodeInput::value(TaggedValue::String(text), false),
326326
NodeInput::value(TaggedValue::Font(font), false),
327327
NodeInput::value(TaggedValue::F64(size), false),

0 commit comments

Comments
 (0)