Speak our record wire kind in the type defaults and artboard exports

This commit is contained in:
Dennis Kobert
2026-09-08 15:11:33 +00:00
parent 8555e6fb79
commit b93b395d2f
3 changed files with 15 additions and 24 deletions
@@ -35,9 +35,9 @@ use crate::node_graph_executor::NodeGraphExecutor;
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graph_craft::application_io::resource::ResourceId; use graph_craft::application_io::resource::ResourceId;
use graph_craft::application_io::wgpu_available; use graph_craft::application_io::wgpu_available;
use graph_craft::concrete;
use graph_craft::document::value::TaggedValue; use graph_craft::document::value::TaggedValue;
use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork}; use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork};
use graph_craft::list;
use graphene_std::Cover; use graphene_std::Cover;
use graphene_std::math::quad::Quad; use graphene_std::math::quad::Quad;
use graphene_std::path_bool_nodes::boolean_intersect; use graphene_std::path_bool_nodes::boolean_intersect;
@@ -3803,7 +3803,7 @@ impl DocumentMessageHandler {
/// Create a network interface with a single export /// Create a network interface with a single export
fn default_document_network_interface() -> NodeNetworkInterface { fn default_document_network_interface() -> NodeNetworkInterface {
let mut network_interface = NodeNetworkInterface::default(); let mut network_interface = NodeNetworkInterface::default();
network_interface.add_export(TaggedValue::TypeDefault(list!(graphene_std::Artboard)), -1, "", &[]); network_interface.add_export(TaggedValue::TypeDefault(concrete!(graphene_std::list::List<graphene_std::Artboard>)), -1, "", &[]);
network_interface network_interface
} }
@@ -9,9 +9,9 @@ use crate::messages::portfolio::document::utility_types::nodes::CollapsedLayers;
use crate::messages::prelude::*; use crate::messages::prelude::*;
use crate::messages::tool::common_functionality::graph_modification_utils::get_clip_mode; use crate::messages::tool::common_functionality::graph_modification_utils::get_clip_mode;
use glam::{DAffine2, DVec2, IVec2}; use glam::{DAffine2, DVec2, IVec2};
use graph_craft::concrete;
use graph_craft::document::value::TaggedValue; use graph_craft::document::value::TaggedValue;
use graph_craft::document::{NodeId, NodeInput}; use graph_craft::document::{NodeId, NodeInput};
use graph_craft::list;
use graphene_std::renderer::convert_usvg_path::convert_usvg_path; use graphene_std::renderer::convert_usvg_path::convert_usvg_path;
use graphene_std::text::{Font, TypesettingConfig}; use graphene_std::text::{Font, TypesettingConfig};
use graphene_std::vector::style::{Gradient, GradientForm, GradientSettings, GradientSpace, GradientSpread, GradientStop, Stroke, StrokeAlign, StrokeCap, StrokeJoin}; use graphene_std::vector::style::{Gradient, GradientForm, GradientSettings, GradientSpace, GradientSpread, GradientStop, Stroke, StrokeAlign, StrokeCap, StrokeJoin};
@@ -252,7 +252,7 @@ impl MessageHandler<GraphOperationMessage, GraphOperationMessageContext<'_>> for
} }
// Set the bottom input of the artboard back to artboard // Set the bottom input of the artboard back to artboard
let bottom_input = NodeInput::type_default(list!(Artboard), true); let bottom_input = NodeInput::type_default(concrete!(graphene_std::list::List<Artboard>), true);
network_interface.set_input(&InputConnector::primary_input(artboard_layer.to_node()), bottom_input, &[]); network_interface.set_input(&InputConnector::primary_input(artboard_layer.to_node()), bottom_input, &[]);
} else { } else {
// We have some non layers (e.g. just a rectangle node). We disconnect the bottom input and connect it to the left input. // We have some non layers (e.g. just a rectangle node). We disconnect the bottom input and connect it to the left input.
@@ -260,7 +260,7 @@ impl MessageHandler<GraphOperationMessage, GraphOperationMessageContext<'_>> for
network_interface.set_input(&InputConnector::layer_secondary_input(artboard_layer.to_node()), primary_input, &[]); network_interface.set_input(&InputConnector::layer_secondary_input(artboard_layer.to_node()), primary_input, &[]);
// Set the bottom input of the artboard back to artboard // Set the bottom input of the artboard back to artboard
let bottom_input = NodeInput::type_default(list!(Artboard), true); let bottom_input = NodeInput::type_default(concrete!(graphene_std::list::List<Artboard>), true);
network_interface.set_input(&InputConnector::primary_input(artboard_layer.to_node()), bottom_input, &[]); network_interface.set_input(&InputConnector::primary_input(artboard_layer.to_node()), bottom_input, &[]);
} }
} }
+10 -19
View File
@@ -274,7 +274,7 @@ macro_rules! tagged_value {
// ======================= // =======================
// AUTO-GENERATED VARIANTS // AUTO-GENERATED VARIANTS
// ======================= // =======================
$( Self::$identifier(_) => item!($ty), )* $( Self::$identifier(_) => concrete!($ty), )*
// ======================= // =======================
// NON-SERIALIZED VARIANTS // NON-SERIALIZED VARIANTS
// ======================= // =======================
@@ -511,18 +511,9 @@ macro_rules! tagged_value {
} }
Type::Fn(_, output) => TaggedValue::from_type(output), Type::Fn(_, output) => TaggedValue::from_type(output),
Type::Future(output) => TaggedValue::from_type(output), Type::Future(output) => TaggedValue::from_type(output),
// Element types with a dedicated variant use it directly (the variant's value is a rank-0 cell); the rest store the structural type // One wire kind: a record input types by its element, so the element's own
Type::Item(element) => TaggedValue::from_type(element).or_else(|| { // dedicated variant is used where there is one and the structural type otherwise.
macro_rules! check { Type::Record(element) => TaggedValue::from_type(element).or_else(|| {
($type_default:ty) => {
if **element == concrete!($type_default) { return Some(TaggedValue::TypeDefault(input.clone())); }
};
}
for_each_item_type_default!(check);
None
}),
// Structural lists match by element; `List<f64>` stays the dedicated `F64Array` variant
Type::List(element) => {
if **element == concrete!(f64) { if **element == concrete!(f64) {
return Some(TaggedValue::F64Array(Vec::new())); return Some(TaggedValue::F64Array(Vec::new()));
} }
@@ -534,9 +525,10 @@ macro_rules! tagged_value {
if **element == concrete!($type_default) { return Some(TaggedValue::TypeDefault(input.clone())); } if **element == concrete!($type_default) { return Some(TaggedValue::TypeDefault(input.clone())); }
}; };
} }
for_each_item_type_default!(check);
for_each_list_type_default!(check); for_each_list_type_default!(check);
None None
} })
} }
} }
@@ -802,8 +794,7 @@ impl TaggedValue {
} }
Type::Fn(_, output) => TaggedValue::from_primitive_string(string, output), Type::Fn(_, output) => TaggedValue::from_primitive_string(string, output),
Type::Future(fut) => TaggedValue::from_primitive_string(string, fut), Type::Future(fut) => TaggedValue::from_primitive_string(string, fut),
Type::Item(element) => TaggedValue::from_primitive_string(string, element), Type::Record(element) => TaggedValue::from_primitive_string(string, element),
Type::List(element) => TaggedValue::from_primitive_string(string, element),
} }
} }
@@ -816,12 +807,12 @@ impl TaggedValue {
/// The stored form of a paint input's red-slash "no paint" choice: the `Item<Graphic>` type default, materializing as a `Graphic::None` paint. /// The stored form of a paint input's red-slash "no paint" choice: the `Item<Graphic>` type default, materializing as a `Graphic::None` paint.
pub fn no_paint() -> Self { pub fn no_paint() -> Self {
TaggedValue::TypeDefault(item!(Graphic)) TaggedValue::TypeDefault(concrete!(Graphic))
} }
/// Whether this is the `Item<Graphic>` type default created by [`Self::no_paint`] (and by disconnecting a paint wire). /// Whether this is the `Item<Graphic>` type default created by [`Self::no_paint`] (and by disconnecting a paint wire).
pub fn is_no_paint(&self) -> bool { pub fn is_no_paint(&self) -> bool {
matches!(self, TaggedValue::TypeDefault(td) if *td == item!(Graphic)) matches!(self, TaggedValue::TypeDefault(td) if *td == concrete!(Graphic))
} }
} }
@@ -1082,7 +1073,7 @@ mod paint_default_parsing {
"a `List<Graphic>` paint wire should resolve its color default" "a `List<Graphic>` paint wire should resolve its color default"
); );
assert_eq!( assert_eq!(
TaggedValue::from_primitive_string("Color::BLACK", &item!(Graphic)), TaggedValue::from_primitive_string("Color::BLACK", &concrete!(Graphic)),
black, black,
"an `Item<Graphic>` paint wire should resolve its color default" "an `Item<Graphic>` paint wire should resolve its color default"
); );