@@ -2053,9 +2053,7 @@ impl NodeNetworkInterface {
2053
2053
} ;
2054
2054
input_connectors. extend ( outward_wires_for_import) ;
2055
2055
}
2056
- let Some ( network) = self . nested_network ( network_path) else {
2057
- return ;
2058
- } ;
2056
+ let Some ( network) = self . nested_network ( network_path) else { return } ;
2059
2057
for export_index in 0 ..network. exports . len ( ) {
2060
2058
input_connectors. push ( InputConnector :: Export ( export_index) ) ;
2061
2059
}
@@ -2506,7 +2504,7 @@ impl NodeNetworkInterface {
2506
2504
}
2507
2505
}
2508
2506
2509
- pub fn try_get_input_dom_rect ( & mut self , input : & InputConnector , network_path : & [ NodeId ] ) -> Option < ( f64 , f64 , f64 , f64 ) > {
2507
+ pub fn try_get_input_rect ( & mut self , input : & InputConnector , network_path : & [ NodeId ] ) -> Option < ( f64 , f64 , f64 , f64 ) > {
2510
2508
let ( ports, index) = match input {
2511
2509
InputConnector :: Node { node_id, input_index } => {
2512
2510
let node_click_target = self . node_click_targets ( node_id, network_path) ?;
@@ -2520,10 +2518,10 @@ impl NodeNetworkInterface {
2520
2518
ports
2521
2519
. input_ports
2522
2520
. iter ( )
2523
- . find_map ( |( input_index, click_target) | if index == input_index { click_target. to_dom_rect ( ) } else { None } )
2521
+ . find_map ( |( input_index, click_target) | if index == input_index { click_target. to_rect ( ) } else { None } )
2524
2522
}
2525
2523
2526
- pub fn try_get_output_dom_rect ( & mut self , output : & OutputConnector , network_path : & [ NodeId ] ) -> Option < ( f64 , f64 , f64 , f64 ) > {
2524
+ pub fn try_get_output_rect ( & mut self , output : & OutputConnector , network_path : & [ NodeId ] ) -> Option < ( f64 , f64 , f64 , f64 ) > {
2527
2525
let ( ports, index) = match output {
2528
2526
OutputConnector :: Node { node_id, output_index } => {
2529
2527
let node_click_target = self . node_click_targets ( node_id, network_path) ?;
@@ -2537,18 +2535,21 @@ impl NodeNetworkInterface {
2537
2535
ports
2538
2536
. output_ports
2539
2537
. iter ( )
2540
- . find_map ( |( input_index, click_target) | if index == input_index { click_target. to_dom_rect ( ) } else { None } )
2538
+ . find_map ( |( input_index, click_target) | if index == input_index { click_target. to_rect ( ) } else { None } )
2541
2539
}
2542
2540
2543
2541
pub fn newly_loaded_input_wire ( & mut self , input : & InputConnector , network_path : & [ NodeId ] ) -> Option < WireUpdate > {
2542
+ #[ allow( clippy:: question_mark) ]
2544
2543
if self . upstream_output_connector ( input, network_path) . is_none ( ) {
2545
2544
return None ;
2546
2545
}
2546
+
2547
2547
if !self . wire_is_loaded ( input, network_path) {
2548
2548
self . load_wire ( input, network_path) ;
2549
2549
} else {
2550
2550
return None ;
2551
2551
}
2552
+
2552
2553
let wire = match input {
2553
2554
InputConnector :: Node { node_id, input_index } => {
2554
2555
let input_metadata = self . transient_input_metadata ( node_id, * input_index, network_path) ?;
@@ -2608,25 +2609,19 @@ impl NodeNetworkInterface {
2608
2609
Previewing :: No => false ,
2609
2610
} ;
2610
2611
2611
- let Some ( wire) = self . wire_path_from_input ( input, dashed, network_path) else {
2612
- return ;
2613
- } ;
2612
+ let Some ( wire) = self . wire_path_from_input ( input, dashed, network_path) else { return } ;
2614
2613
2615
2614
match input {
2616
2615
InputConnector :: Node { node_id, input_index } => {
2617
- let Some ( node_metadata) = self . node_metadata_mut ( node_id, network_path) else {
2618
- return ;
2619
- } ;
2616
+ let Some ( node_metadata) = self . node_metadata_mut ( node_id, network_path) else { return } ;
2620
2617
let Some ( input_metadata) = node_metadata. persistent_metadata . input_metadata . get_mut ( * input_index) else {
2621
2618
log:: error!( "Node metadata must exist on node: {input:?}" ) ;
2622
2619
return ;
2623
2620
} ;
2624
2621
input_metadata. transient_metadata . wire = TransientMetadata :: Loaded ( wire) ;
2625
2622
}
2626
2623
InputConnector :: Export ( export_index) => {
2627
- let Some ( network_metadata) = self . network_metadata_mut ( network_path) else {
2628
- return ;
2629
- } ;
2624
+ let Some ( network_metadata) = self . network_metadata_mut ( network_path) else { return } ;
2630
2625
if * export_index >= network_metadata. transient_metadata . wires . len ( ) {
2631
2626
network_metadata. transient_metadata . wires . resize ( export_index + 1 , TransientMetadata :: Unloaded ) ;
2632
2627
}
@@ -2640,9 +2635,7 @@ impl NodeNetworkInterface {
2640
2635
2641
2636
pub fn unload_all_wires ( & mut self , network_path : & [ NodeId ] ) {
2642
2637
let mut input_connectors = Vec :: new ( ) ;
2643
- let Some ( network) = self . nested_network ( network_path) else {
2644
- return ;
2645
- } ;
2638
+ let Some ( network) = self . nested_network ( network_path) else { return } ;
2646
2639
for export_index in 0 ..network. exports . len ( ) {
2647
2640
input_connectors. push ( InputConnector :: Export ( export_index) ) ;
2648
2641
}
@@ -2702,6 +2695,7 @@ impl NodeNetworkInterface {
2702
2695
}
2703
2696
}
2704
2697
}
2698
+
2705
2699
// When previewing, there may be a second path to the root node
2706
2700
pub fn wire_to_root ( & mut self , network_path : & [ NodeId ] ) -> Option < WireUpdate > {
2707
2701
let current_export = self . upstream_output_connector ( & InputConnector :: Export ( 0 ) , network_path) ?;
@@ -2724,18 +2718,17 @@ impl NodeNetworkInterface {
2724
2718
}
2725
2719
2726
2720
pub fn wire_path_from_input ( & mut self , input : & InputConnector , dashed : bool , network_path : & [ NodeId ] ) -> Option < WirePath > {
2727
- let Some ( end) = self . try_get_input_dom_rect ( input, network_path) else {
2721
+ let Some ( end) = self . try_get_input_rect ( input, network_path) else {
2728
2722
log:: error!( "Could not get dom rect for wire end: {:?}" , input) ;
2729
2723
return None ;
2730
2724
} ;
2731
2725
let input_position = DVec2 {
2732
2726
x : end. 0 + end. 2 / 2. ,
2733
2727
y : end. 1 + end. 3 / 2. ,
2734
2728
} ;
2735
- let Some ( upstream_output) = self . upstream_output_connector ( input, network_path) else {
2736
- return None ;
2737
- } ;
2738
- let Some ( start) = self . try_get_output_dom_rect ( & upstream_output, network_path) else {
2729
+
2730
+ let upstream_output = self . upstream_output_connector ( input, network_path) ?;
2731
+ let Some ( start) = self . try_get_output_rect ( & upstream_output, network_path) else {
2739
2732
log:: error!( "Could not get dom rect for wire start: {:?}" , upstream_output) ;
2740
2733
return None ;
2741
2734
} ;
@@ -6446,15 +6439,15 @@ pub enum WidgetOverride {
6446
6439
// TODO: Custom deserialization/serialization to ensure number of properties row matches number of node inputs
6447
6440
#[ derive( Debug , Clone , Default , PartialEq , serde:: Serialize , serde:: Deserialize ) ]
6448
6441
pub struct InputPersistentMetadata {
6449
- /// A general datastore than can store key value pairs of any types for any input
6450
- /// Each instance of the input node needs to store its own data, since it can
6442
+ /// A general datastore that can store key- value pairs of any types for any input.
6443
+ /// Each instance of the input node needs to store its own data, since it can lose the reference to its node definition if the node signature is modified by the user.
6451
6444
pub input_data : HashMap < String , Value > ,
6452
6445
// An input can override a widget, which would otherwise be automatically generated from the type
6453
6446
// The string is the identifier to the widget override function stored in INPUT_OVERRIDES
6454
6447
pub widget_override : Option < String > ,
6455
- // An empty input name means to use the type as the name
6448
+ /// An empty input name means to use the type as the name.
6456
6449
pub input_name : String ,
6457
- // Tooltip
6450
+ /// Displayed as the tooltip.
6458
6451
pub input_description : String ,
6459
6452
}
6460
6453
@@ -6662,15 +6655,8 @@ pub struct DocumentNodePersistentMetadataInputNames {
6662
6655
impl From < DocumentNodePersistentMetadataInputNames > for DocumentNodePersistentMetadata {
6663
6656
fn from ( old : DocumentNodePersistentMetadataInputNames ) -> Self {
6664
6657
DocumentNodePersistentMetadata {
6665
- reference : old. reference ,
6666
- display_name : old. display_name ,
6667
6658
input_metadata : Vec :: new ( ) ,
6668
- output_names : old. output_names ,
6669
- has_primary_output : old. has_primary_output ,
6670
- locked : old. locked ,
6671
- pinned : old. pinned ,
6672
- node_type_metadata : old. node_type_metadata ,
6673
- network_metadata : old. network_metadata ,
6659
+ ..old. into ( )
6674
6660
}
6675
6661
}
6676
6662
}
@@ -6717,10 +6703,11 @@ impl From<DocumentNodePersistentMetadataPropertiesRow> for DocumentNodePersisten
6717
6703
..Default :: default ( )
6718
6704
} )
6719
6705
}
6706
+
6720
6707
DocumentNodePersistentMetadata {
6708
+ input_metadata : Vec :: new ( ) ,
6721
6709
reference : old. reference ,
6722
6710
display_name : old. display_name ,
6723
- input_metadata : Vec :: new ( ) ,
6724
6711
output_names : old. output_names ,
6725
6712
has_primary_output : old. has_primary_output ,
6726
6713
locked : old. locked ,
@@ -6745,16 +6732,14 @@ where
6745
6732
use serde:: Deserialize ;
6746
6733
6747
6734
let value = Value :: deserialize ( deserializer) ?;
6748
- match serde_json:: from_value :: < DocumentNodePersistentMetadata > ( value. clone ( ) ) {
6749
- Ok ( document) => return Ok ( document) ,
6750
- Err ( _) => { }
6735
+ if let Ok ( document) = serde_json:: from_value :: < DocumentNodePersistentMetadata > ( value. clone ( ) ) {
6736
+ return Ok ( document) ;
6751
6737
} ;
6752
- match serde_json:: from_value :: < DocumentNodePersistentMetadataPropertiesRow > ( value. clone ( ) ) {
6753
- Ok ( document) => return Ok ( document. into ( ) ) ,
6754
- Err ( _) => { }
6738
+ if let Ok ( document) = serde_json:: from_value :: < DocumentNodePersistentMetadataPropertiesRow > ( value. clone ( ) ) {
6739
+ return Ok ( document. into ( ) ) ;
6755
6740
} ;
6756
6741
match serde_json:: from_value :: < DocumentNodePersistentMetadataInputNames > ( value. clone ( ) ) {
6757
- Ok ( document) => return Ok ( document. into ( ) ) ,
6742
+ Ok ( document) => Ok ( document. into ( ) ) ,
6758
6743
Err ( e) => Err ( serde:: de:: Error :: custom ( e) ) ,
6759
6744
}
6760
6745
}
0 commit comments