1
1
use crate :: messages:: frontend:: utility_types:: FrontendImageData ;
2
- use crate :: messages:: portfolio:: document:: node_graph:: wrap_network_in_scope;
2
+ use crate :: messages:: portfolio:: document:: node_graph:: { wrap_network_in_scope, LayerIdentifier } ;
3
3
use crate :: messages:: portfolio:: document:: utility_types:: misc:: { LayerMetadata , LayerPanelEntry } ;
4
4
use crate :: messages:: portfolio:: utility_types:: PersistentData ;
5
5
use crate :: messages:: prelude:: * ;
6
6
7
+ use document_legacy:: document:: Document as DocumentLegacy ;
8
+ use document_legacy:: document_metadata:: LayerNodeIdentifier ;
7
9
use document_legacy:: layers:: layer_info:: { LayerDataType , LayerDataTypeDiscriminant } ;
8
10
use document_legacy:: { LayerId , Operation } ;
9
11
@@ -19,7 +21,7 @@ use graphene_core::text::FontCache;
19
21
use graphene_core:: transform:: Transform ;
20
22
use graphene_core:: vector:: style:: ViewMode ;
21
23
22
- use graphene_core:: { Color , SurfaceFrame , SurfaceId } ;
24
+ use graphene_core:: { Color , NodeIdentifier , SurfaceFrame , SurfaceId } ;
23
25
use graphene_std:: wasm_application_io:: { WasmApplicationIo , WasmEditorApi } ;
24
26
use interpreted_executor:: dynamic_executor:: DynamicExecutor ;
25
27
@@ -77,8 +79,8 @@ pub(crate) struct GenerationResponse {
77
79
result : Result < TaggedValue , String > ,
78
80
updates : VecDeque < Message > ,
79
81
new_thumbnails : HashMap < NodeId , SvgSegmentList > ,
80
- new_click_targets : HashMap < NodeId , Vec < ClickTarget > > ,
81
- new_transforms : HashMap < NodeId , DAffine2 > ,
82
+ new_click_targets : HashMap < LayerNodeIdentifier , Vec < ClickTarget > > ,
83
+ new_transforms : HashMap < LayerNodeIdentifier , DAffine2 > ,
82
84
}
83
85
84
86
enum NodeGraphUpdate {
@@ -157,8 +159,8 @@ impl NodeRuntime {
157
159
result,
158
160
updates : responses,
159
161
new_thumbnails : self . thumbnails . clone ( ) ,
160
- new_click_targets : self . click_targets . clone ( ) ,
161
- new_transforms : self . transforms . clone ( ) ,
162
+ new_click_targets : self . click_targets . clone ( ) . into_iter ( ) . map ( | ( id , targets ) | ( LayerNodeIdentifier :: new_unchecked ( id ) , targets ) ) . collect ( ) ,
163
+ new_transforms : self . transforms . clone ( ) . into_iter ( ) . map ( | ( id , transform ) | ( LayerNodeIdentifier :: new_unchecked ( id ) , transform ) ) . collect ( ) ,
162
164
} ;
163
165
self . sender . send_generation_response ( response) ;
164
166
}
@@ -460,7 +462,7 @@ impl NodeGraphExecutor {
460
462
Ok ( ( ) )
461
463
}
462
464
463
- pub fn poll_node_graph_evaluation ( & mut self , transform : DAffine2 , responses : & mut VecDeque < Message > ) -> Result < ( ) , String > {
465
+ pub fn poll_node_graph_evaluation ( & mut self , document : & mut DocumentLegacy , responses : & mut VecDeque < Message > ) -> Result < ( ) , String > {
464
466
let results = self . receiver . try_iter ( ) . collect :: < Vec < _ > > ( ) ;
465
467
for response in results {
466
468
match response {
@@ -473,10 +475,11 @@ impl NodeGraphExecutor {
473
475
new_transforms,
474
476
} ) => {
475
477
self . thumbnails = new_thumbnails;
478
+ document. metadata . update_transforms ( new_transforms) ;
476
479
let node_graph_output = result. map_err ( |e| format ! ( "Node graph evaluation failed: {:?}" , e) ) ?;
477
480
let execution_context = self . futures . remove ( & generation_id) . ok_or_else ( || "Invalid generation ID" . to_string ( ) ) ?;
478
481
responses. extend ( updates) ;
479
- self . process_node_graph_output ( node_graph_output, execution_context. layer_path . clone ( ) , transform , responses, execution_context. document_id ) ?;
482
+ self . process_node_graph_output ( node_graph_output, execution_context. layer_path . clone ( ) , responses, execution_context. document_id ) ?;
480
483
responses. add ( DocumentMessage :: LayerChanged {
481
484
affected_layer_path : execution_context. layer_path ,
482
485
} ) ;
@@ -495,7 +498,7 @@ impl NodeGraphExecutor {
495
498
Ok ( ( ) )
496
499
}
497
500
498
- fn process_node_graph_output ( & mut self , node_graph_output : TaggedValue , layer_path : Vec < LayerId > , _transform : DAffine2 , responses : & mut VecDeque < Message > , document_id : u64 ) -> Result < ( ) , String > {
501
+ fn process_node_graph_output ( & mut self , node_graph_output : TaggedValue , layer_path : Vec < LayerId > , responses : & mut VecDeque < Message > , document_id : u64 ) -> Result < ( ) , String > {
499
502
self . last_output_type . insert ( layer_path. clone ( ) , Some ( node_graph_output. ty ( ) ) ) ;
500
503
match node_graph_output {
501
504
TaggedValue :: VectorData ( vector_data) => {
0 commit comments