Skip to content

Commit f64daff

Browse files
committed
Dynamic type based properties for protonode inputs
1 parent 330903f commit f64daff

File tree

1 file changed

+22
-41
lines changed

1 file changed

+22
-41
lines changed

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::messages::layout::utility_types::widget_prelude::*;
66
use crate::messages::portfolio::document::utility_types::network_interface::InputConnector;
77
use crate::messages::prelude::*;
88
use choice::enum_choice;
9-
use dyn_any::DynAny;
109
use glam::{DAffine2, DVec2};
1110
use graph_craft::document::value::TaggedValue;
1211
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeInput};
@@ -1572,51 +1571,33 @@ pub(crate) fn generate_node_properties(node_id: NodeId, context: &mut NodeProper
15721571
let number_of_inputs = context.network_interface.number_of_inputs(&node_id, context.selection_network_path);
15731572
for input_index in 1..number_of_inputs {
15741573
let row = context.call_widget_override(&node_id, input_index).unwrap_or_else(|| {
1575-
let Some(implementation) = context.network_interface.implementation(&node_id, context.selection_network_path) else {
1576-
log::error!("Could not get implementation for node {node_id}");
1577-
return Vec::new();
1578-
};
1579-
15801574
let mut number_options = (None, None, None);
15811575
let mut display_decimal_places = None;
15821576
let mut step = None;
15831577
let mut unit_suffix = None;
1584-
let input_type = match implementation {
1585-
DocumentNodeImplementation::ProtoNode(proto_node_identifier) => 'early_return: {
1586-
if let Some(field) = graphene_std::registry::NODE_METADATA
1587-
.lock()
1588-
.unwrap()
1589-
.get(proto_node_identifier)
1590-
.and_then(|metadata| metadata.fields.get(input_index))
1591-
{
1592-
number_options = (field.number_min, field.number_max, field.number_mode_range);
1593-
display_decimal_places = field.number_display_decimal_places;
1594-
unit_suffix = field.unit;
1595-
step = field.number_step;
1596-
if let Some(ref default) = field.default_type {
1597-
break 'early_return default.clone();
1598-
}
1599-
}
1600-
1601-
let Some(implementations) = &interpreted_executor::node_registry::NODE_REGISTRY.get(proto_node_identifier) else {
1602-
log::error!("Could not get implementation for protonode {proto_node_identifier:?}");
1603-
return Vec::new();
1604-
};
1605-
1606-
let mut input_types = implementations.keys().filter_map(|item| item.inputs.get(input_index)).collect::<Vec<_>>();
1607-
input_types.sort_by_key(|ty| ty.type_name());
1608-
let input_type = input_types.first().cloned();
1609-
1610-
let Some(input_type) = input_type else { return Vec::new() };
1611-
input_type.clone()
1612-
}
1613-
_ => context
1614-
.network_interface
1615-
.input_type(&InputConnector::node(node_id, input_index), context.selection_network_path)
1616-
.compiled_nested_type()
1617-
.cloned()
1618-
.unwrap_or(concrete!(())),
1578+
let input_type = context
1579+
.network_interface
1580+
.input_type(&InputConnector::node(node_id, input_index), context.selection_network_path)
1581+
.compiled_nested_type()
1582+
.cloned()
1583+
.unwrap_or(concrete!(()));
1584+
let Some(implementation) = context.network_interface.implementation(&node_id, context.selection_network_path) else {
1585+
log::error!("Could not get implementation for node {node_id}");
1586+
return Vec::new();
16191587
};
1588+
if let DocumentNodeImplementation::ProtoNode(proto_node_identifier) = implementation {
1589+
if let Some(field) = graphene_std::registry::NODE_METADATA
1590+
.lock()
1591+
.unwrap()
1592+
.get(proto_node_identifier)
1593+
.and_then(|metadata| metadata.fields.get(input_index))
1594+
{
1595+
number_options = (field.number_min, field.number_max, field.number_mode_range);
1596+
display_decimal_places = field.number_display_decimal_places;
1597+
unit_suffix = field.unit;
1598+
step = field.number_step;
1599+
}
1600+
}
16201601

16211602
property_from_type(node_id, input_index, &input_type, number_options, unit_suffix, display_decimal_places, step, context).unwrap_or_else(|value| value)
16221603
});

0 commit comments

Comments
 (0)