You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: node-graph/graph-craft/src/document/value.rs
+13-12Lines changed: 13 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -118,9 +118,9 @@ macro_rules! tagged_value {
118
118
// Tries using the default for the tagged value type. If it not implemented, then uses the default used in document_node_types. If it is not used there, then TaggedValue::None is returned.
119
119
Some(match concrete_type.id? {
120
120
x if x == TypeId::of::<()>() => TaggedValue::None,
121
-
// Table-wrapped types need a single-row default with the element's default, not an empty table
122
-
x if x == TypeId::of::<Table<Color>>() => TaggedValue::Color(Table::new_from_element(Color::default())),
123
-
x if x == TypeId::of::<Table<GradientStops>>() => TaggedValue::GradientTable(Table::new_from_element(GradientStops::default())),
121
+
x if x == TypeId::of::<Table<Color>>() => TaggedValue::OptionalColor(Some(Color::default())),
122
+
x if x == TypeId::of::<Option<Color>>() => TaggedValue::OptionalColor(None),
123
+
x if x == TypeId::of::<Table<GradientStops>>() => TaggedValue::GradientStops(GradientStops::default()),
124
124
$( x if x == TypeId::of::<$ty>() => TaggedValue::$identifier(Default::default()),)*
125
125
_ => returnNone,
126
126
})
@@ -202,14 +202,16 @@ tagged_value! {
202
202
#[serde(alias = "ArtboardGroup")]
203
203
Artboard(Table<Artboard>),
204
204
#[serde(deserialize_with = "core_types::misc::migrate_color")]// TODO: Eventually remove this migration document upgrade code
205
-
#[serde(alias = "ColorTable", alias = "OptionalColor", alias = "ColorNotInTable")]
206
-
Color(Table<Color>),
207
-
#[serde(deserialize_with = "graphic_types::vector_types::gradient::migrate_gradient_stops")]// TODO: Eventually remove this migration document upgrade code
208
-
#[serde(alias = "GradientPositions", alias = "GradientStops")]
209
-
GradientTable(Table<GradientStops>),
210
205
// ============
211
206
// STRUCT TYPES
212
207
// ============
208
+
#[serde(alias = "ColorTable", alias = "ColorNotInTable")]
209
+
Color(Color),
210
+
#[serde(deserialize_with = "core_types::misc::migrate_optional_color")]// TODO: Eventually remove this migration document upgrade code
211
+
OptionalColor(Option<Color>),
212
+
#[serde(deserialize_with = "graphic_types::vector_types::gradient::migrate_gradient_stops")]// TODO: Eventually remove this migration document upgrade code
213
+
#[serde(alias = "GradientPositions", alias = "GradientTable")]
214
+
GradientStops(GradientStops),
213
215
FVec2(Vec2),
214
216
FAffine2(Affine2),
215
217
#[serde(alias = "IVec2", alias = "UVec2")]
@@ -397,10 +399,9 @@ impl TaggedValue {
397
399
()if ty == TypeId::of::<u32>() => FromStr::from_str(string).map(TaggedValue::U32).ok()?,
398
400
()if ty == TypeId::of::<DVec2>() => to_dvec2(string).map(TaggedValue::DVec2)?,
399
401
()if ty == TypeId::of::<bool>() => FromStr::from_str(string).map(TaggedValue::Bool).ok()?,
400
-
// `Color` (not in a table) is still currently needed by `BlackAndWhiteNode` and `ColorOverlayNode` GPU `shader_node(PerPixelAdjust)` variants
401
-
()if ty == TypeId::of::<Color>() => to_color(string).map(|color| TaggedValue::Color(Table::new_from_element(color)))?,
402
-
()if ty == TypeId::of::<Table<Color>>() => to_color(string).map(|color| TaggedValue::Color(Table::new_from_element(color)))?,
403
-
()if ty == TypeId::of::<Table<GradientStops>>() => to_gradient(string).map(|color| TaggedValue::GradientTable(Table::new_from_element(color)))?,
402
+
()if ty == TypeId::of::<Color>() => to_color(string).map(TaggedValue::Color)?,
403
+
()if ty == TypeId::of::<Option<Color>>() => TaggedValue::OptionalColor(to_color(string)),
404
+
()if ty == TypeId::of::<GradientStops>() => to_gradient(string).map(TaggedValue::GradientStops)?,
404
405
()if ty == TypeId::of::<Fill>() => to_color(string).map(|color| TaggedValue::Fill(Fill::solid(color)))?,
405
406
()if ty == TypeId::of::<ReferencePoint>() => to_reference_point(string).map(TaggedValue::ReferencePoint)?,
0 commit comments