mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 19:08:05 +08:00
Migrate remaining node graph data types from Vec to Table (#4067)
* Move Vec<String> to Table<String> * Remove old VecDVec2 * Move Vec<u8> to Table<u8> * Move Vec<f64> to Table<f64> * Move [f64; 4] to Table<f64> * Move Vec<NodeId> to Table<NodeId> * Tidy up the TaggedValue variants * Move Vec<BrushStroke> to Table<BrushStroke> * Add missing type implementations * Fix tests ---------
This commit is contained in:
@@ -216,7 +216,7 @@ pub enum DocumentNodeMetadata {
|
||||
impl DocumentNodeMetadata {
|
||||
pub fn ty(&self) -> Type {
|
||||
match self {
|
||||
DocumentNodeMetadata::DocumentNodePath => concrete!(Vec<NodeId>),
|
||||
DocumentNodeMetadata::DocumentNodePath => concrete!(core_types::table::Table<NodeId>),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -930,7 +930,10 @@ impl NodeNetwork {
|
||||
let (tagged_value, exposed) = match previous_export {
|
||||
NodeInput::Value { tagged_value, exposed } => (tagged_value, exposed),
|
||||
NodeInput::Reflection(reflect) => match reflect {
|
||||
DocumentNodeMetadata::DocumentNodePath => (TaggedValue::NodePath(path.to_vec()).into(), false),
|
||||
DocumentNodeMetadata::DocumentNodePath => {
|
||||
let table: core_types::table::Table<NodeId> = path.iter().copied().map(core_types::table::TableRow::new_from_element).collect();
|
||||
(TaggedValue::NodeIdTable(table).into(), false)
|
||||
}
|
||||
},
|
||||
previous_export => {
|
||||
*export = previous_export;
|
||||
|
||||
@@ -4,28 +4,27 @@ use crate::proto::{Any as DAny, FutureAny};
|
||||
use brush_nodes::brush_cache::BrushCache;
|
||||
use brush_nodes::brush_stroke::BrushStroke;
|
||||
use core_types::table::Table;
|
||||
use core_types::transform::Footprint;
|
||||
use core_types::uuid::NodeId;
|
||||
use core_types::{CacheHash, Color, ContextFeatures, MemoHash, Node, Type};
|
||||
use dyn_any::DynAny;
|
||||
pub use dyn_any::StaticType;
|
||||
use glam::{Affine2, Vec2};
|
||||
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
|
||||
use graphic_types::Artboard;
|
||||
use graphic_types::Graphic;
|
||||
use graphic_types::Vector;
|
||||
use graphic_types::raster_types::Image;
|
||||
use graphic_types::raster_types::{CPU, Raster};
|
||||
use graphic_types::vector_types::vector;
|
||||
use graphic_types::vector_types::vector::ReferencePoint;
|
||||
use graphic_types::vector_types::vector::style::Fill;
|
||||
use graphic_types::vector_types::vector::style::GradientStops;
|
||||
use graphic_types::raster_types::{CPU, Image, Raster};
|
||||
use graphic_types::vector_types::vector::style::{Fill, Gradient, GradientStops, Stroke};
|
||||
use graphic_types::vector_types::vector::{self, ReferencePoint};
|
||||
use graphic_types::{Artboard, Graphic, Vector};
|
||||
use raster_nodes::curve::Curve;
|
||||
use rendering::RenderMetadata;
|
||||
use std::fmt::Display;
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use std::str::FromStr;
|
||||
pub use std::sync::Arc;
|
||||
use text_nodes::Font;
|
||||
use text_nodes::vector_types::GradientStop;
|
||||
use vector::VectorModification;
|
||||
|
||||
pub struct TaggedValueTypeError;
|
||||
|
||||
@@ -166,27 +165,14 @@ macro_rules! tagged_value {
|
||||
}
|
||||
|
||||
tagged_value! {
|
||||
// ===============
|
||||
// PRIMITIVE TYPES
|
||||
// ===============
|
||||
F32(f32),
|
||||
F64(f64),
|
||||
U32(u32),
|
||||
U64(u64),
|
||||
Bool(bool),
|
||||
String(String),
|
||||
// ========================
|
||||
// LISTS OF PRIMITIVE TYPES
|
||||
// ========================
|
||||
#[serde(alias = "VecF32")] // TODO: Eventually remove this alias document upgrade code
|
||||
VecF64(Vec<f64>),
|
||||
VecDVec2(Vec<DVec2>),
|
||||
F64Array4([f64; 4]),
|
||||
VecString(Vec<String>),
|
||||
NodePath(Vec<NodeId>),
|
||||
// ===========
|
||||
// TABLE TYPES
|
||||
// ===========
|
||||
StringTable(Table<String>),
|
||||
#[serde(deserialize_with = "core_types::misc::migrate_vec_f64_to_table")] // TODO: Eventually remove this migration document upgrade code
|
||||
#[serde(alias = "VecF64", alias = "VecF32", alias = "F64Array4")]
|
||||
F64Table(Table<f64>),
|
||||
NodeIdTable(Table<NodeId>),
|
||||
#[serde(deserialize_with = "graphic_types::migrations::migrate_vector")] // TODO: Eventually remove this migration document upgrade code
|
||||
#[serde(alias = "VectorData")]
|
||||
Vector(Table<Vector>),
|
||||
@@ -205,24 +191,32 @@ tagged_value! {
|
||||
#[serde(deserialize_with = "graphic_types::vector_types::gradient::migrate_gradient_stops")] // TODO: Eventually remove this migration document upgrade code
|
||||
#[serde(alias = "GradientPositions", alias = "GradientStops")]
|
||||
GradientTable(Table<GradientStops>),
|
||||
#[serde(deserialize_with = "brush_nodes::migrations::migrate_brush_strokes_to_table")] // TODO: Eventually remove this migration document upgrade code
|
||||
#[serde(alias = "BrushStrokes")]
|
||||
BrushStrokeTable(Table<BrushStroke>),
|
||||
// ============
|
||||
// STRUCT TYPES
|
||||
// SCALAR TYPES
|
||||
// ============
|
||||
F32(f32),
|
||||
F64(f64),
|
||||
U32(u32),
|
||||
U64(u64),
|
||||
Bool(bool),
|
||||
String(String),
|
||||
FVec2(Vec2),
|
||||
FAffine2(Affine2),
|
||||
#[serde(alias = "IVec2", alias = "UVec2")]
|
||||
DVec2(DVec2),
|
||||
DAffine2(DAffine2),
|
||||
Stroke(graphic_types::vector_types::vector::style::Stroke),
|
||||
Gradient(graphic_types::vector_types::vector::style::Gradient),
|
||||
Font(text_nodes::Font),
|
||||
BrushStrokes(Vec<BrushStroke>),
|
||||
Stroke(Stroke),
|
||||
Gradient(Gradient),
|
||||
Font(Font),
|
||||
BrushCache(BrushCache),
|
||||
DocumentNode(DocumentNode),
|
||||
ContextFeatures(ContextFeatures),
|
||||
Curve(raster_nodes::curve::Curve),
|
||||
Footprint(core_types::transform::Footprint),
|
||||
VectorModification(Box<vector::VectorModification>),
|
||||
Curve(Curve),
|
||||
Footprint(Footprint),
|
||||
VectorModification(Box<VectorModification>),
|
||||
ImageData(Image<Color>),
|
||||
// ==========
|
||||
// ENUM TYPES
|
||||
|
||||
@@ -951,7 +951,7 @@ mod test {
|
||||
// If this assert fails: These NodeIds seem to be changing when you modify TaggedValue, just update them.
|
||||
assert_eq!(
|
||||
ids,
|
||||
vec![NodeId(2791689253855410677), NodeId(11246167042277902310), NodeId(1014827049498980779), NodeId(4864562752646903491)]
|
||||
vec![NodeId(12189222519765806511), NodeId(15012204941197567462), NodeId(15525229164021892418), NodeId(1252248957706694248)]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user