Convert u64 IDs to newtypes (#1532)

This commit is contained in:
Keavon Chambers
2023-12-22 03:24:13 -08:00
committed by GitHub
parent 7bfe0ce55b
commit 34f952bad1
38 changed files with 565 additions and 446 deletions

View File

@@ -68,7 +68,7 @@ mod test {
preferences: r#"{"imaginate_server_hostname":"https://exchange-encoding-watched-insured.trycloudflare.com/","imaginate_refresh_frequency":1,"zoom_with_scroll":false}"#.to_string(),
}),
PortfolioMessage::OpenDocumentFileWithId {
document_id: 0,
document_id: DocumentId(0),
document_name: "".into(),
document_is_auto_saved: true,
document_is_saved: true,

View File

@@ -256,7 +256,7 @@ impl Dispatcher {
mod test {
use crate::application::Editor;
use crate::messages::portfolio::document::utility_types::clipboards::Clipboard;
use crate::messages::portfolio::document::utility_types::document_metadata::{self, LayerNodeIdentifier};
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
use crate::messages::prelude::*;
use crate::messages::tool::tool_messages::tool_prelude::ToolType;
use crate::test_utils::EditorTestUtils;
@@ -359,7 +359,7 @@ mod test {
fn copy_paste_folder() {
let mut editor = create_editor_with_three_layers();
const FOLDER_ID: NodeId = 3;
const FOLDER_ID: NodeId = NodeId(3);
editor.handle_message(GraphOperationMessage::NewCustomLayer {
id: FOLDER_ID,
@@ -369,9 +369,6 @@ mod test {
});
editor.handle_message(NodeGraphMessage::SelectedNodesSet { nodes: vec![FOLDER_ID] });
let document_before_added_shapes = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().clone();
let folder_layer = LayerNodeIdentifier::new(FOLDER_ID, &document_before_added_shapes.network);
editor.drag_tool(ToolType::Line, 0., 0., 10., 10.);
editor.drag_tool(ToolType::Freehand, 10., 20., 30., 40.);
@@ -388,19 +385,20 @@ mod test {
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().clone();
let layers_before_added_shapes = document_before_added_shapes.metadata.all_layers().collect::<Vec<_>>();
let layers_before_copy = document_before_copy.metadata.all_layers().collect::<Vec<_>>();
let layers_after_copy = document_after_copy.metadata.all_layers().collect::<Vec<_>>();
let [original_folder, original_freehand, original_line, original_ellipse, original_polygon, original_rect] = layers_before_copy[..] else {
panic!("Layers before incorrect");
};
let [duplicated_folder, freehand_dup, line_dup, folder, freehand, line, ellipse, polygon, rect] = layers_after_copy[..] else {
let [_, _, _, folder, freehand, line, ellipse, polygon, rect] = layers_after_copy[..] else {
panic!("Layers after incorrect");
};
assert_eq!(original_folder, folder);
assert_eq!(original_freehand, freehand);
assert_eq!(original_line, line);
assert_eq!(original_ellipse, ellipse);
assert_eq!(original_rect, rect);
assert_eq!(original_polygon, polygon);
assert_eq!(original_rect, rect);
}
#[test]

View File

@@ -1,6 +1,7 @@
use crate::messages::layout::utility_types::widget_prelude::*;
use crate::messages::prelude::*;
use graph_craft::document::NodeId;
use graphene_core::uuid::generate_uuid;
use glam::{DVec2, IVec2, UVec2};
@@ -26,7 +27,7 @@ impl MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessageHa
let create_artboard = !self.infinite && self.dimensions.x > 0 && self.dimensions.y > 0;
if create_artboard {
let id = generate_uuid();
let id = NodeId(generate_uuid());
responses.add(GraphOperationMessage::NewArtboard {
id,
artboard: graphene_core::Artboard::new(IVec2::ZERO, self.dimensions.as_ivec2()),

View File

@@ -7,7 +7,17 @@ use serde::{Deserialize, Serialize};
#[impl_message(Message, Layout)]
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub enum LayoutMessage {
ResendActiveWidget { layout_target: LayoutTarget, dirty_id: u64 },
SendLayout { layout: Layout, layout_target: LayoutTarget },
UpdateLayout { layout_target: LayoutTarget, widget_id: u64, value: serde_json::Value },
ResendActiveWidget {
layout_target: LayoutTarget,
dirty_id: WidgetId,
},
SendLayout {
layout: Layout,
layout_target: LayoutTarget,
},
UpdateLayout {
layout_target: LayoutTarget,
widget_id: WidgetId,
value: serde_json::Value,
},
}

View File

@@ -14,7 +14,7 @@ pub struct LayoutMessageHandler {
impl LayoutMessageHandler {
/// Get the widget path for the widget with the specified id
fn get_widget_path(widget_layout: &WidgetLayout, id: u64) -> Option<(&WidgetHolder, Vec<usize>)> {
fn get_widget_path(widget_layout: &WidgetLayout, id: WidgetId) -> Option<(&WidgetHolder, Vec<usize>)> {
let mut stack = widget_layout.layout.iter().enumerate().map(|(index, val)| (vec![index], val)).collect::<Vec<_>>();
while let Some((mut widget_path, group)) = stack.pop() {
match group {

View File

@@ -10,6 +10,16 @@ use crate::messages::prelude::*;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, serde::Serialize, serde::Deserialize, specta::Type)]
pub struct WidgetId(pub u64);
impl core::fmt::Display for WidgetId {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.0)
}
}
#[remain::sorted]
#[derive(PartialEq, Clone, Debug, Hash, Eq, Copy, Serialize, Deserialize, specta::Type)]
#[repr(u8)]
@@ -419,14 +429,17 @@ impl LayoutGroup {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, specta::Type)]
pub struct WidgetHolder {
#[serde(rename = "widgetId")]
pub widget_id: u64,
pub widget_id: WidgetId,
pub widget: Widget,
}
impl WidgetHolder {
#[deprecated(since = "0.0.0", note = "Please use the builder pattern, e.g. TextLabel::new(\"hello\").widget_holder()")]
pub fn new(widget: Widget) -> Self {
Self { widget_id: generate_uuid(), widget }
Self {
widget_id: WidgetId(generate_uuid()),
widget,
}
}
/// Diffing updates self (where self is old) based on new, updating the list of modifications as it does so.

View File

@@ -174,8 +174,8 @@ fn root_network() -> NodeNetwork {
name: "Output".into(),
inputs: vec![NodeInput::value(TaggedValue::GraphicGroup(Default::default()), true), NodeInput::Network(concrete!(WasmEditorApi))],
implementation: graph_craft::document::DocumentNodeImplementation::Network(NodeNetwork {
inputs: vec![3, 0],
outputs: vec![NodeOutput::new(3, 0)],
inputs: vec![NodeId(3), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(3), 0)],
nodes: [
DocumentNode {
name: "EditorApi".to_string(),
@@ -185,7 +185,7 @@ fn root_network() -> NodeNetwork {
},
DocumentNode {
name: "Create Canvas".to_string(),
inputs: vec![NodeInput::node(0, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_std::wasm_application_io::CreateSurfaceNode")),
skip_deduplication: true,
..Default::default()
@@ -193,16 +193,16 @@ fn root_network() -> NodeNetwork {
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
DocumentNode {
name: "RenderNode".to_string(),
inputs: vec![
NodeInput::node(0, 0),
NodeInput::node(NodeId(0), 0),
NodeInput::Network(graphene_core::Type::Fn(Box::new(concrete!(Footprint)), Box::new(generic!(T)))),
NodeInput::node(2, 0),
NodeInput::node(NodeId(2), 0),
],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_std::wasm_application_io::RenderNode<_, _, _>")),
..Default::default()
@@ -210,7 +210,7 @@ fn root_network() -> NodeNetwork {
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -345,7 +345,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
}
CommitTransaction => (),
CreateEmptyFolder { parent } => {
let id = generate_uuid();
let id = NodeId(generate_uuid());
responses.add(GraphOperationMessage::NewCustomLayer {
id,
@@ -416,7 +416,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
// TODO: Add code that changes the insert index of the new folder based on the selected layer
let parent = self.metadata().deepest_common_ancestor(self.metadata().selected_layers(), true).unwrap_or(LayerNodeIdentifier::ROOT);
let folder_id = generate_uuid();
let folder_id = NodeId(generate_uuid());
responses.add(PortfolioMessage::Copy { clipboard: Clipboard::Internal });
responses.add(DocumentMessage::DeleteSelectedLayers);
@@ -547,7 +547,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
let image_frame = ImageFrame { image, ..Default::default() };
use crate::messages::tool::common_functionality::graph_modification_utils;
let layer = graph_modification_utils::new_image_layer(image_frame, generate_uuid(), self.new_layer_parent(), responses);
let layer = graph_modification_utils::new_image_layer(image_frame, NodeId(generate_uuid()), self.new_layer_parent(), responses);
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![layer.to_node()] });
@@ -907,14 +907,14 @@ impl DocumentMessageHandler {
path.push(layer_node);
// TODO: Skip if folder is not expanded.
structure.push(LayerNodeIdentifier::new_unchecked(space));
structure.push(LayerNodeIdentifier::new_unchecked(NodeId(space)));
self.serialize_structure(layer_node, structure, data, path);
space = 0;
path.pop();
}
}
structure.push(LayerNodeIdentifier::new_unchecked(space | 1 << 63));
structure.push(LayerNodeIdentifier::new_unchecked(NodeId(space | 1 << 63)));
}
/// Serializes the layer structure into a condensed 1D structure.
@@ -954,10 +954,10 @@ impl DocumentMessageHandler {
let mut data = Vec::new();
self.serialize_structure(self.metadata().root(), &mut structure, &mut data, &mut vec![]);
structure[0] = LayerNodeIdentifier::new_unchecked(structure.len() as NodeId - 1);
structure[0] = LayerNodeIdentifier::new_unchecked(NodeId(structure.len() as u64 - 1));
structure.extend(data);
structure.iter().map(|id| id.to_node()).collect::<Vec<_>>().as_slice().into()
structure.iter().map(|id| id.to_node().0).collect::<Vec<_>>().as_slice().into()
}
/// Places a document into the history system

View File

@@ -118,7 +118,7 @@ impl<'a> ModifyInputsContext<'a> {
} else {
// The user has connected another node to the output. Insert a layer node between the output and the node.
let node = resolve_document_node_type("Layer").expect("Layer node").default_document_node();
let node_id = self.insert_between(generate_uuid(), NodeOutput::new(node_id, output_index), output, node, 0, 0, IVec2::new(-8, 0))?;
let node_id = self.insert_between(NodeId(generate_uuid()), NodeOutput::new(node_id, output_index), output, node, 0, 0, IVec2::new(-8, 0))?;
sibling_layer = Some(NodeOutput::new(node_id, 0));
}
@@ -182,7 +182,7 @@ impl<'a> ModifyInputsContext<'a> {
Default::default(),
);
self.responses.add(NodeGraphMessage::SendGraph { should_rerender: true });
self.insert_node_before(generate_uuid(), layer, 0, artboard_node, IVec2::new(-8, 0))
self.insert_node_before(NodeId(generate_uuid()), layer, 0, artboard_node, IVec2::new(-8, 0))
}
fn insert_vector_data(&mut self, subpaths: Vec<Subpath<ManipulatorGroupId>>, layer: NodeId) {
@@ -195,15 +195,15 @@ impl<'a> ModifyInputsContext<'a> {
let fill = resolve_document_node_type("Fill").expect("Fill node does not exist").default_document_node();
let stroke = resolve_document_node_type("Stroke").expect("Stroke node does not exist").default_document_node();
let stroke_id = generate_uuid();
let stroke_id = NodeId(generate_uuid());
self.insert_node_before(stroke_id, layer, 0, stroke, IVec2::new(-8, 0));
let fill_id = generate_uuid();
let fill_id = NodeId(generate_uuid());
self.insert_node_before(fill_id, stroke_id, 0, fill, IVec2::new(-8, 0));
let transform_id = generate_uuid();
let transform_id = NodeId(generate_uuid());
self.insert_node_before(transform_id, fill_id, 0, transform, IVec2::new(-8, 0));
let cull_id = generate_uuid();
let cull_id = NodeId(generate_uuid());
self.insert_node_before(cull_id, transform_id, 0, cull, IVec2::new(-8, 0));
let shape_id = generate_uuid();
let shape_id = NodeId(generate_uuid());
self.insert_node_before(shape_id, cull_id, 0, shape, IVec2::new(-8, 0));
self.responses.add(NodeGraphMessage::SendGraph { should_rerender: true });
}
@@ -223,15 +223,15 @@ impl<'a> ModifyInputsContext<'a> {
let fill = resolve_document_node_type("Fill").expect("Fill node does not exist").default_document_node();
let stroke = resolve_document_node_type("Stroke").expect("Stroke node does not exist").default_document_node();
let stroke_id = generate_uuid();
let stroke_id = NodeId(generate_uuid());
self.insert_node_before(stroke_id, layer, 0, stroke, IVec2::new(-8, 0));
let fill_id = generate_uuid();
let fill_id = NodeId(generate_uuid());
self.insert_node_before(fill_id, stroke_id, 0, fill, IVec2::new(-8, 0));
let transform_id = generate_uuid();
let transform_id = NodeId(generate_uuid());
self.insert_node_before(transform_id, fill_id, 0, transform, IVec2::new(-8, 0));
let cull_id = generate_uuid();
let cull_id = NodeId(generate_uuid());
self.insert_node_before(cull_id, transform_id, 0, cull, IVec2::new(-8, 0));
let text_id = generate_uuid();
let text_id = NodeId(generate_uuid());
self.insert_node_before(text_id, cull_id, 0, text, IVec2::new(-8, 0));
self.responses.add(NodeGraphMessage::SendGraph { should_rerender: true });
}
@@ -244,11 +244,11 @@ impl<'a> ModifyInputsContext<'a> {
let sample = resolve_document_node_type("Sample").expect("Sample node does not exist").default_document_node();
let transform = resolve_document_node_type("Transform").expect("Transform node does not exist").default_document_node();
let transform_id = generate_uuid();
let transform_id = NodeId(generate_uuid());
self.insert_node_before(transform_id, layer, 0, transform, IVec2::new(-8, 0));
let sample_id = generate_uuid();
let sample_id = NodeId(generate_uuid());
self.insert_node_before(sample_id, transform_id, 0, sample, IVec2::new(-8, 0));
let image_id = generate_uuid();
let image_id = NodeId(generate_uuid());
self.insert_node_before(image_id, sample_id, 0, image, IVec2::new(-8, 0));
self.responses.add(NodeGraphMessage::SendGraph { should_rerender: true });
}
@@ -283,7 +283,7 @@ impl<'a> ModifyInputsContext<'a> {
let metadata = output_node.metadata.clone();
let new_input = output_node.inputs.first().cloned().filter(|input| input.as_node().is_some());
let node_id = generate_uuid();
let node_id = NodeId(generate_uuid());
output_node.inputs[0] = NodeInput::node(node_id, 0);
@@ -678,10 +678,10 @@ impl MessageHandler<GraphOperationMessage, (&mut NodeNetwork, &mut DocumentMetad
let mut modify_inputs = ModifyInputsContext::new(document_network, document_metadata, node_graph, responses);
if let Some(layer) = modify_inputs.create_layer_with_insert_index(id, insert_index, parent) {
let new_ids: HashMap<_, _> = nodes.iter().map(|(&id, _)| (id, crate::application::generate_uuid())).collect();
let new_ids: HashMap<_, _> = nodes.iter().map(|(&id, _)| (id, NodeId(generate_uuid()))).collect();
let shift = nodes
.get(&0)
.get(&NodeId(0))
.and_then(|node| {
modify_inputs
.document_network
@@ -704,7 +704,7 @@ impl MessageHandler<GraphOperationMessage, (&mut NodeNetwork, &mut DocumentMetad
}
if let Some(layer_node) = modify_inputs.document_network.nodes.get_mut(&layer) {
if let Some(&input) = new_ids.get(&0) {
if let Some(&input) = new_ids.get(&NodeId(0)) {
layer_node.inputs[0] = NodeInput::node(input, 0)
}
}

View File

@@ -1,5 +1,6 @@
pub use self::document_node_types::*;
use super::load_network_structure;
use crate::application::generate_uuid;
use crate::messages::input_mapper::utility_types::macros::action_keys;
use crate::messages::layout::utility_types::widget_prelude::*;
use crate::messages::portfolio::document::utility_types::document_metadata::{DocumentMetadata, LayerNodeIdentifier};
@@ -512,7 +513,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
};
// Collect the selected nodes
let new_ids = &metadata.selected_nodes().copied().enumerate().map(|(new, old)| (old, new as NodeId)).collect();
let new_ids = &metadata.selected_nodes().copied().enumerate().map(|(new, old)| (old, NodeId(new as u64))).collect();
let copied_nodes: Vec<_> = Self::copy_nodes(network, new_ids).collect();
// Prefix to show that this is nodes
@@ -522,7 +523,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
responses.add(FrontendMessage::TriggerTextCopy { copy_text });
}
NodeGraphMessage::CreateNode { node_id, node_type, x, y } => {
let node_id = node_id.unwrap_or_else(crate::application::generate_uuid);
let node_id = node_id.unwrap_or_else(|| NodeId(generate_uuid()));
let Some(document_node_type) = document_node_types::resolve_document_node_type(&node_type) else {
responses.add(DialogMessage::DisplayDialogError {
@@ -608,7 +609,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
if let Some(network) = document_network.nested_network(&self.network) {
responses.add(DocumentMessage::StartTransaction);
let new_ids = &metadata.selected_nodes().map(|&id| (id, crate::application::generate_uuid())).collect();
let new_ids = &metadata.selected_nodes().map(|&id| (id, NodeId(generate_uuid()))).collect();
metadata.clear_selected_nodes();
responses.add(BroadcastEvent::SelectionChanged);
@@ -722,7 +723,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
responses.add(DocumentMessage::StartTransaction);
let new_ids: HashMap<_, _> = data.iter().map(|&(id, _)| (id, crate::application::generate_uuid())).collect();
let new_ids: HashMap<_, _> = data.iter().map(|&(id, _)| (id, NodeId(generate_uuid()))).collect();
for (old_id, mut document_node) in data {
// Shift copied node
document_node.metadata.position += shift;

View File

@@ -203,11 +203,11 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Layer",
category: "General",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![0, 2],
outputs: vec![NodeOutput::new(2, 0)],
inputs: vec![NodeId(0), NodeId(2)],
outputs: vec![NodeOutput::new(NodeId(2), 0)],
nodes: [
(
0,
NodeId(0),
DocumentNode {
name: "To Graphic Element".to_string(),
inputs: vec![NodeInput::Network(generic!(T))],
@@ -217,19 +217,19 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
),
// The monitor node is used to display a thumbnail in the UI.
(
1,
NodeId(1),
DocumentNode {
inputs: vec![NodeInput::node(0, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0)],
..monitor_node()
},
),
(
2,
NodeId(2),
DocumentNode {
name: "ConstructLayer".to_string(),
manual_composition: Some(concrete!(Footprint)),
inputs: vec![
NodeInput::node(1, 0),
NodeInput::node(NodeId(1), 0),
NodeInput::Network(graphene_core::Type::Fn(Box::new(concrete!(Footprint)), Box::new(concrete!(graphene_core::GraphicGroup)))),
],
implementation: DocumentNodeImplementation::proto("graphene_core::ConstructLayerNode<_, _>"),
@@ -284,8 +284,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Load Image",
category: "Structural",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![0, 0],
outputs: vec![NodeOutput::new(1, 0)],
inputs: vec![NodeId(0), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(1), 0)],
nodes: [
DocumentNode {
name: "Load Resource".to_string(),
@@ -295,14 +295,14 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "Decode Image".to_string(),
inputs: vec![NodeInput::node(0, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_std::wasm_application_io::DecodeImageNode")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -329,8 +329,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Create Canvas",
category: "Structural",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![0],
outputs: vec![NodeOutput::new(1, 0)],
inputs: vec![NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(1), 0)],
nodes: [
DocumentNode {
name: "Create Canvas".to_string(),
@@ -342,14 +342,14 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(0, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -368,8 +368,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Draw Canvas",
category: "Structural",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![0, 2],
outputs: vec![NodeOutput::new(3, 0)],
inputs: vec![NodeId(0), NodeId(2)],
outputs: vec![NodeOutput::new(NodeId(3), 0)],
nodes: [
DocumentNode {
name: "Convert Image Frame".to_string(),
@@ -387,20 +387,20 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
DocumentNode {
name: "Draw Canvas".to_string(),
inputs: vec![NodeInput::node(0, 0), NodeInput::node(2, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0), NodeInput::node(NodeId(2), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_std::wasm_application_io::DrawImageFrameNode<_>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -426,8 +426,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Begin Scope",
category: "Ignore",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![0],
outputs: vec![NodeOutput::new(1, 0), NodeOutput::new(2, 0)],
inputs: vec![NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(1), 0), NodeOutput::new(NodeId(2), 0)],
nodes: [
DocumentNode {
name: "SetNode".to_string(),
@@ -437,21 +437,21 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "LetNode".to_string(),
inputs: vec![NodeInput::node(0, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::LetNode<_>")),
..Default::default()
},
DocumentNode {
name: "RefNode".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::lambda(1, 0)],
inputs: vec![NodeInput::lambda(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::RefNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
@@ -501,8 +501,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Output",
category: "Ignore",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![3, 0],
outputs: vec![NodeOutput::new(4, 0)],
inputs: vec![NodeId(3), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(4), 0)],
nodes: [
DocumentNode {
name: "EditorApi".to_string(),
@@ -512,7 +512,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "Create Canvas".to_string(),
inputs: vec![NodeInput::node(0, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_std::wasm_application_io::CreateSurfaceNode")),
skip_deduplication: true,
..Default::default()
@@ -520,7 +520,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
@@ -532,14 +532,14 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "RenderNode".to_string(),
inputs: vec![NodeInput::node(0, 0), NodeInput::node(3, 0), NodeInput::node(2, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0), NodeInput::node(NodeId(3), 0), NodeInput::node(NodeId(2), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_std::wasm_application_io::RenderNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -809,8 +809,13 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Split Channels",
category: "Image Adjustments",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![0],
outputs: vec![NodeOutput::new(1, 0), NodeOutput::new(2, 0), NodeOutput::new(3, 0), NodeOutput::new(4, 0)],
inputs: vec![NodeId(0)],
outputs: vec![
NodeOutput::new(NodeId(1), 0),
NodeOutput::new(NodeId(2), 0),
NodeOutput::new(NodeId(3), 0),
NodeOutput::new(NodeId(4), 0),
],
nodes: [
// The input image feeds into the identity, then we take its passed-through value when the other channels are reading from it instead of the original input.
// We do this for technical restrictions imposed by Graphene which doesn't allow an input to feed into multiple interior nodes in the subgraph.
@@ -823,32 +828,32 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "RedNode".to_string(),
inputs: vec![NodeInput::node(0, 0), NodeInput::value(TaggedValue::RedGreenBlue(RedGreenBlue::Red), false)],
inputs: vec![NodeInput::node(NodeId(0), 0), NodeInput::value(TaggedValue::RedGreenBlue(RedGreenBlue::Red), false)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::raster::ExtractChannelNode<_>")),
..Default::default()
},
DocumentNode {
name: "GreenNode".to_string(),
inputs: vec![NodeInput::node(0, 0), NodeInput::value(TaggedValue::RedGreenBlue(RedGreenBlue::Green), false)],
inputs: vec![NodeInput::node(NodeId(0), 0), NodeInput::value(TaggedValue::RedGreenBlue(RedGreenBlue::Green), false)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::raster::ExtractChannelNode<_>")),
..Default::default()
},
DocumentNode {
name: "BlueNode".to_string(),
inputs: vec![NodeInput::node(0, 0), NodeInput::value(TaggedValue::RedGreenBlue(RedGreenBlue::Blue), false)],
inputs: vec![NodeInput::node(NodeId(0), 0), NodeInput::value(TaggedValue::RedGreenBlue(RedGreenBlue::Blue), false)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::raster::ExtractChannelNode<_>")),
..Default::default()
},
DocumentNode {
name: "AlphaNode".to_string(),
inputs: vec![NodeInput::node(0, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::raster::ExtractAlphaNode<>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
@@ -913,8 +918,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Uniform",
category: "Gpu",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![1, 0],
outputs: vec![NodeOutput::new(2, 0)],
inputs: vec![NodeId(1), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(2), 0)],
nodes: [
DocumentNode {
name: "Extract Executor".to_string(),
@@ -924,21 +929,21 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "Create Uniform".to_string(),
inputs: vec![NodeInput::Network(generic!(T)), NodeInput::node(0, 0)],
inputs: vec![NodeInput::Network(generic!(T)), NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("gpu_executor::UniformNode<_>")),
..Default::default()
},
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -965,8 +970,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Storage",
category: "Gpu",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![1, 0],
outputs: vec![NodeOutput::new(2, 0)],
inputs: vec![NodeId(1), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(2), 0)],
nodes: [
DocumentNode {
name: "Extract Executor".to_string(),
@@ -976,21 +981,21 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "Create Storage".to_string(),
inputs: vec![NodeInput::Network(concrete!(Vec<u8>)), NodeInput::node(0, 0)],
inputs: vec![NodeInput::Network(concrete!(Vec<u8>)), NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("gpu_executor::StorageNode<_>")),
..Default::default()
},
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -1017,8 +1022,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "CreateOutputBuffer",
category: "Gpu",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![1, 1, 0],
outputs: vec![NodeOutput::new(2, 0)],
inputs: vec![NodeId(1), NodeId(1), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(2), 0)],
nodes: [
DocumentNode {
name: "Extract Executor".to_string(),
@@ -1028,21 +1033,21 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "Create Output Buffer".to_string(),
inputs: vec![NodeInput::Network(concrete!(usize)), NodeInput::node(0, 0), NodeInput::Network(concrete!(Type))],
inputs: vec![NodeInput::Network(concrete!(usize)), NodeInput::node(NodeId(0), 0), NodeInput::Network(concrete!(Type))],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("gpu_executor::CreateOutputBufferNode<_, _>")),
..Default::default()
},
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -1075,8 +1080,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "CreateComputePass",
category: "Gpu",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![1, 0, 1, 1],
outputs: vec![NodeOutput::new(2, 0)],
inputs: vec![NodeId(1), NodeId(0), NodeId(1), NodeId(1)],
outputs: vec![NodeOutput::new(NodeId(2), 0)],
nodes: [
DocumentNode {
name: "Extract Executor".to_string(),
@@ -1088,7 +1093,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Create Compute Pass".to_string(),
inputs: vec![
NodeInput::Network(concrete!(gpu_executor::PipelineLayout<WgpuExecutor>)),
NodeInput::node(0, 0),
NodeInput::node(NodeId(0), 0),
NodeInput::Network(concrete!(ShaderInput<WgpuExecutor>)),
NodeInput::Network(concrete!(gpu_executor::ComputePassDimensions)),
],
@@ -1098,14 +1103,14 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -1177,8 +1182,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "ExecuteComputePipeline",
category: "Gpu",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![1, 0],
outputs: vec![NodeOutput::new(2, 0)],
inputs: vec![NodeId(1), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(2), 0)],
nodes: [
DocumentNode {
name: "Extract Executor".to_string(),
@@ -1188,21 +1193,21 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "Execute Compute Pipeline".to_string(),
inputs: vec![NodeInput::Network(concrete!(<WgpuExecutor as GpuExecutor>::CommandBuffer)), NodeInput::node(0, 0)],
inputs: vec![NodeInput::Network(concrete!(<WgpuExecutor as GpuExecutor>::CommandBuffer)), NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("gpu_executor::ExecuteComputePipelineNode<_>")),
..Default::default()
},
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -1229,8 +1234,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "ReadOutputBuffer",
category: "Gpu",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![1, 0],
outputs: vec![NodeOutput::new(2, 0)],
inputs: vec![NodeId(1), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(2), 0)],
nodes: [
DocumentNode {
name: "Extract Executor".to_string(),
@@ -1240,21 +1245,21 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "Read Output Buffer".to_string(),
inputs: vec![NodeInput::Network(concrete!(Arc<ShaderInput<WgpuExecutor>>)), NodeInput::node(0, 0)],
inputs: vec![NodeInput::Network(concrete!(Arc<ShaderInput<WgpuExecutor>>)), NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("gpu_executor::ReadOutputBufferNode<_, _>")),
..Default::default()
},
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -1281,8 +1286,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "CreateGpuSurface",
category: "Gpu",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![0],
outputs: vec![NodeOutput::new(1, 0)],
inputs: vec![NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(1), 0)],
nodes: [
DocumentNode {
name: "Create Gpu Surface".to_string(),
@@ -1293,14 +1298,14 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(0, 0)],
inputs: vec![NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -1320,8 +1325,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "RenderTexture",
category: "Gpu",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![1, 1, 0],
outputs: vec![NodeOutput::new(1, 0)],
inputs: vec![NodeId(1), NodeId(1), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(1), 0)],
nodes: [
DocumentNode {
name: "Extract Executor".to_string(),
@@ -1334,7 +1339,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
inputs: vec![
NodeInput::Network(concrete!(ShaderInputFrame<WgpuExecutor>)),
NodeInput::Network(concrete!(Arc<SurfaceHandle<<WgpuExecutor as GpuExecutor>::Surface>>)),
NodeInput::node(0, 0),
NodeInput::node(NodeId(0), 0),
],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("gpu_executor::RenderTextureNode<_, _>")),
..Default::default()
@@ -1342,7 +1347,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -1374,8 +1379,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "UploadTexture",
category: "Gpu",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![1, 0],
outputs: vec![NodeOutput::new(2, 0)],
inputs: vec![NodeId(1), NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(2), 0)],
nodes: [
DocumentNode {
name: "Extract Executor".to_string(),
@@ -1385,21 +1390,21 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
DocumentNode {
name: "Upload Texture".to_string(),
inputs: vec![NodeInput::Network(concrete!(ImageFrame<Color>)), NodeInput::node(0, 0)],
inputs: vec![NodeInput::Network(concrete!(ImageFrame<Color>)), NodeInput::node(NodeId(0), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("gpu_executor::UploadTextureNode<_>")),
..Default::default()
},
DocumentNode {
name: "Cache".to_string(),
manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)],
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -2149,8 +2154,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Transform",
category: "Transform",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![0, 1, 1, 1, 1, 1],
outputs: vec![NodeOutput::new(1, 0)],
inputs: vec![NodeId(0), NodeId(1), NodeId(1), NodeId(1), NodeId(1), NodeId(1)],
outputs: vec![NodeOutput::new(NodeId(1), 0)],
nodes: [
DocumentNode {
inputs: vec![NodeInput::Network(concrete!(VectorData))],
@@ -2159,7 +2164,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
DocumentNode {
name: "Transform".to_string(),
inputs: vec![
NodeInput::node(0, 0),
NodeInput::node(NodeId(0), 0),
NodeInput::Network(concrete!(DVec2)),
NodeInput::Network(concrete!(f32)),
NodeInput::Network(concrete!(DVec2)),
@@ -2173,7 +2178,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
]
.into_iter()
.enumerate()
.map(|(id, node)| (id as NodeId, node))
.map(|(id, node)| (NodeId(id as u64), node))
.collect(),
..Default::default()
}),
@@ -2375,22 +2380,40 @@ pub static IMAGINATE_NODE: Lazy<DocumentNodeDefinition> = Lazy::new(|| DocumentN
name: "Imaginate",
category: "Image Synthesis",
implementation: NodeImplementation::DocumentNode(NodeNetwork {
inputs: vec![0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
outputs: vec![NodeOutput::new(1, 0)],
inputs: vec![
NodeId(0),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
NodeId(1),
],
outputs: vec![NodeOutput::new(NodeId(1), 0)],
nodes: [
(
0,
NodeId(0),
DocumentNode {
inputs: vec![NodeInput::Network(concrete!(ImageFrame<Color>))],
..monitor_node()
},
),
(
1,
NodeId(1),
DocumentNode {
name: "Imaginate".into(),
inputs: vec![
NodeInput::node(0, 0),
NodeInput::node(NodeId(0), 0),
NodeInput::Network(concrete!(WasmEditorApi)),
NodeInput::Network(concrete!(ImaginateController)),
NodeInput::Network(concrete!(f64)),
@@ -2468,9 +2491,9 @@ impl DocumentNodeDefinition {
/*
NodeNetwork {
inputs: (0..num_inputs).map(|_| 0).collect(),
outputs: vec![NodeOutput::new(0, 0)],
outputs: vec![NodeOutput::new(NodeId(0), 0)],
nodes: [(
0,
NodeId(0),
DocumentNode {
name: format!("{}_impl", self.name),
// TODO: Allow inserting nodes that contain other nodes.
@@ -2483,8 +2506,6 @@ impl DocumentNodeDefinition {
.collect(),
..Default::default()
}
}
*/
NodeImplementation::Extract => return DocumentNodeImplementation::Extract,
};
@@ -2555,7 +2576,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, hash: u64) -> NodeNetwork
let inner_network = DocumentNode {
name: "Scope".to_string(),
implementation: DocumentNodeImplementation::Network(network),
inputs: core::iter::repeat(NodeInput::node(0, 1)).take(len).collect(),
inputs: core::iter::repeat(NodeInput::node(NodeId(0), 1)).take(len).collect(),
..Default::default()
};
@@ -2563,7 +2584,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, hash: u64) -> NodeNetwork
.expect("Begin Scope node type not found")
.to_document_node(vec![input_type.unwrap()], DocumentNodeMetadata::default());
if let DocumentNodeImplementation::Network(g) = &mut begin_scope.implementation {
if let Some(node) = g.nodes.get_mut(&0) {
if let Some(node) = g.nodes.get_mut(&NodeId(0)) {
node.world_state_hash = hash;
}
}
@@ -2574,20 +2595,20 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, hash: u64) -> NodeNetwork
inner_network,
resolve_document_node_type("End Scope")
.expect("End Scope node type not found")
.to_document_node(vec![NodeInput::node(0, 0), NodeInput::node(1, 0)], DocumentNodeMetadata::default()),
.to_document_node(vec![NodeInput::node(NodeId(0), 0), NodeInput::node(NodeId(1), 0)], DocumentNodeMetadata::default()),
];
NodeNetwork {
inputs: vec![0],
outputs: vec![NodeOutput::new(2, 0)],
nodes: nodes.into_iter().enumerate().map(|(id, node)| (id as NodeId, node)).collect(),
inputs: vec![NodeId(0)],
outputs: vec![NodeOutput::new(NodeId(2), 0)],
nodes: nodes.into_iter().enumerate().map(|(id, node)| (NodeId(id as u64), node)).collect(),
..Default::default()
}
}
pub fn new_image_network(output_offset: i32, output_node_id: NodeId) -> NodeNetwork {
let mut network = NodeNetwork {
inputs: vec![0],
inputs: vec![NodeId(0)],
..Default::default()
};
network.push_node(
@@ -2611,7 +2632,7 @@ pub fn new_text_network(text: String, font: Font, size: f64) -> NodeNetwork {
let output = resolve_document_node_type("Output").expect("Output node does not exist");
let mut network = NodeNetwork {
inputs: vec![0],
inputs: vec![NodeId(0)],
..Default::default()
};
network.push_node(text_generator.to_document_node(

View File

@@ -363,12 +363,12 @@ impl core::fmt::Debug for LayerNodeIdentifier {
}
impl LayerNodeIdentifier {
pub const ROOT: Self = LayerNodeIdentifier::new_unchecked(0);
pub const ROOT: Self = LayerNodeIdentifier::new_unchecked(NodeId(0));
/// Construct a [`LayerNodeIdentifier`] without checking if it is a layer node
pub const fn new_unchecked(node_id: NodeId) -> Self {
// Safety: will always be >=1
Self(unsafe { NonZeroU64::new_unchecked(node_id + 1) })
Self(unsafe { NonZeroU64::new_unchecked(node_id.0 + 1) })
}
/// Construct a [`LayerNodeIdentifier`], debug asserting that it is a layer node
@@ -384,7 +384,7 @@ impl LayerNodeIdentifier {
/// Access the node id of this layer
pub fn to_node(self) -> NodeId {
u64::from(self.0) - 1
NodeId(u64::from(self.0) - 1)
}
/// Access the parent layer if possible
@@ -662,32 +662,44 @@ fn test_tree() {
let mut document_metadata = DocumentMetadata::default();
let root = document_metadata.root();
let document_metadata = &mut document_metadata;
root.push_child(document_metadata, LayerNodeIdentifier::new_unchecked(3));
assert_eq!(root.children(document_metadata).collect::<Vec<_>>(), vec![LayerNodeIdentifier::new_unchecked(3)]);
root.push_child(document_metadata, LayerNodeIdentifier::new_unchecked(6));
assert_eq!(root.children(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(), vec![3, 6]);
assert_eq!(root.decendants(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(), vec![3, 6]);
LayerNodeIdentifier::new_unchecked(3).add_after(document_metadata, LayerNodeIdentifier::new_unchecked(4));
LayerNodeIdentifier::new_unchecked(3).add_before(document_metadata, LayerNodeIdentifier::new_unchecked(2));
LayerNodeIdentifier::new_unchecked(6).add_before(document_metadata, LayerNodeIdentifier::new_unchecked(5));
LayerNodeIdentifier::new_unchecked(6).add_after(document_metadata, LayerNodeIdentifier::new_unchecked(9));
LayerNodeIdentifier::new_unchecked(6).push_child(document_metadata, LayerNodeIdentifier::new_unchecked(8));
LayerNodeIdentifier::new_unchecked(6).push_front_child(document_metadata, LayerNodeIdentifier::new_unchecked(7));
root.push_front_child(document_metadata, LayerNodeIdentifier::new_unchecked(1));
assert_eq!(root.children(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(), vec![1, 2, 3, 4, 5, 6, 9]);
root.push_child(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(3)));
assert_eq!(root.children(document_metadata).collect::<Vec<_>>(), vec![LayerNodeIdentifier::new_unchecked(NodeId(3))]);
root.push_child(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(6)));
assert_eq!(root.children(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(), vec![NodeId(3), NodeId(6)]);
assert_eq!(root.decendants(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(), vec![NodeId(3), NodeId(6)]);
LayerNodeIdentifier::new_unchecked(NodeId(3)).add_after(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(4)));
LayerNodeIdentifier::new_unchecked(NodeId(3)).add_before(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(2)));
LayerNodeIdentifier::new_unchecked(NodeId(6)).add_before(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(5)));
LayerNodeIdentifier::new_unchecked(NodeId(6)).add_after(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(9)));
LayerNodeIdentifier::new_unchecked(NodeId(6)).push_child(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(8)));
LayerNodeIdentifier::new_unchecked(NodeId(6)).push_front_child(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(7)));
root.push_front_child(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(1)));
assert_eq!(
root.children(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(),
vec![NodeId(1), NodeId(2), NodeId(3), NodeId(4), NodeId(5), NodeId(6), NodeId(9)]
);
assert_eq!(
root.decendants(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(),
vec![1, 2, 3, 4, 5, 6, 7, 8, 9]
vec![NodeId(1), NodeId(2), NodeId(3), NodeId(4), NodeId(5), NodeId(6), NodeId(7), NodeId(8), NodeId(9)]
);
assert_eq!(
root.decendants(document_metadata).map(LayerNodeIdentifier::to_node).rev().collect::<Vec<_>>(),
vec![9, 8, 7, 6, 5, 4, 3, 2, 1]
vec![NodeId(9), NodeId(8), NodeId(7), NodeId(6), NodeId(5), NodeId(4), NodeId(3), NodeId(2), NodeId(1)]
);
assert!(root.children(document_metadata).all(|child| child.parent(document_metadata) == Some(root)));
LayerNodeIdentifier::new_unchecked(6).delete(document_metadata);
LayerNodeIdentifier::new_unchecked(1).delete(document_metadata);
LayerNodeIdentifier::new_unchecked(9).push_child(document_metadata, LayerNodeIdentifier::new_unchecked(10));
assert_eq!(root.children(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(), vec![2, 3, 4, 5, 9]);
assert_eq!(root.decendants(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(), vec![2, 3, 4, 5, 9, 10]);
assert_eq!(root.decendants(document_metadata).map(LayerNodeIdentifier::to_node).rev().collect::<Vec<_>>(), vec![10, 9, 5, 4, 3, 2]);
LayerNodeIdentifier::new_unchecked(NodeId(6)).delete(document_metadata);
LayerNodeIdentifier::new_unchecked(NodeId(1)).delete(document_metadata);
LayerNodeIdentifier::new_unchecked(NodeId(9)).push_child(document_metadata, LayerNodeIdentifier::new_unchecked(NodeId(10)));
assert_eq!(
root.children(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(),
vec![NodeId(2), NodeId(3), NodeId(4), NodeId(5), NodeId(9)]
);
assert_eq!(
root.decendants(document_metadata).map(LayerNodeIdentifier::to_node).collect::<Vec<_>>(),
vec![NodeId(2), NodeId(3), NodeId(4), NodeId(5), NodeId(9), NodeId(10)]
);
assert_eq!(
root.decendants(document_metadata).map(LayerNodeIdentifier::to_node).rev().collect::<Vec<_>>(),
vec![NodeId(10), NodeId(9), NodeId(5), NodeId(4), NodeId(3), NodeId(2)]
);
}

View File

@@ -4,6 +4,10 @@ use glam::DVec2;
use serde::{Deserialize, Serialize};
use std::fmt;
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, serde::Serialize, serde::Deserialize, specta::Type)]
pub struct DocumentId(pub u64);
#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize, Hash)]
pub enum FlipAxis {
X,

View File

@@ -187,7 +187,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
.network()
.upstream_flow_back_from_nodes(vec![node], false)
.enumerate()
.map(|(index, (_, node_id))| (node_id, index as NodeId))
.map(|(index, (_, node_id))| (node_id, NodeId(index as u64)))
.collect(),
)
.collect(),
@@ -327,7 +327,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
}
PortfolioMessage::NewDocumentWithName { name } => {
let new_document = DocumentMessageHandler::with_name(name, ipp, responses);
let document_id = generate_uuid();
let document_id = DocumentId(generate_uuid());
if self.active_document().is_some() {
responses.add(BroadcastEvent::ToolAbort);
responses.add(NavigationMessage::TranslateCanvas { delta: (0., 0.).into() });
@@ -353,7 +353,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
document_serialized_content,
} => {
responses.add(PortfolioMessage::OpenDocumentFileWithId {
document_id: generate_uuid(),
document_id: DocumentId(generate_uuid()),
document_name,
document_is_auto_saved: false,
document_is_saved: true,
@@ -389,7 +389,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
let paste = |entry: &CopyBufferEntry, responses: &mut VecDeque<_>| {
if self.active_document().is_some() {
trace!("Pasting into folder {parent:?} as index: {insert_index}");
let id = generate_uuid();
let id = NodeId(generate_uuid());
responses.add(GraphOperationMessage::NewCustomLayer {
id,
nodes: entry.nodes.clone(),
@@ -422,7 +422,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
for entry in data.into_iter().rev() {
document.load_layer_resources(responses);
let id = generate_uuid();
let id = NodeId(generate_uuid());
responses.add(GraphOperationMessage::NewCustomLayer {
id,
nodes: entry.nodes,

View File

@@ -51,14 +51,12 @@ pub use crate::messages::tool::tool_messages::text_tool::{TextToolMessage, TextT
// Helper
pub use crate::messages::globals::global_variables::*;
pub use crate::messages::portfolio::document::node_graph::TransformIn;
pub use crate::messages::portfolio::document::utility_types::misc::DocumentId;
pub use graphite_proc_macros::*;
pub use std::collections::{HashMap, HashSet, VecDeque};
// TODO: Convert from a type alias to a newtype
pub type DocumentId = u64;
pub trait Responses {
fn add(&mut self, message: impl Into<Message>);

View File

@@ -7,6 +7,7 @@ use crate::messages::tool::common_functionality::snapping::SnapManager;
use crate::messages::tool::common_functionality::transformation_cage::*;
use glam::{IVec2, Vec2Swizzles};
use graph_craft::document::NodeId;
#[derive(Default)]
pub struct ArtboardTool {
@@ -273,7 +274,7 @@ impl Fsm for ArtboardToolFsmState {
dimensions: size.round().as_ivec2(),
});
} else {
let id = generate_uuid();
let id = NodeId(generate_uuid());
tool_data.selected_artboard = Some(LayerNodeIdentifier::new_unchecked(id));
tool_data.snap_manager.start_snap(document, input, document.bounding_boxes(), true, true);

View File

@@ -5,7 +5,7 @@ use crate::messages::portfolio::document::utility_types::document_metadata::Laye
use crate::messages::tool::common_functionality::color_selector::{ToolColorOptions, ToolColorType};
use graph_craft::document::value::TaggedValue;
use graph_craft::document::{DocumentNodeMetadata, NodeInput};
use graph_craft::document::{DocumentNodeMetadata, NodeId, NodeInput};
use graphene_core::raster::BlendMode;
use graphene_core::uuid::generate_uuid;
use graphene_core::vector::brush_stroke::{BrushInputSample, BrushStroke, BrushStyle};
@@ -422,12 +422,12 @@ fn new_brush_layer(document: &DocumentMessageHandler, responses: &mut VecDeque<M
.to_document_node_default_inputs([], DocumentNodeMetadata::position((-8, 0)));
let cull_node = resolve_document_node_type("Cull")
.expect("Cull node does not exist")
.to_document_node_default_inputs([Some(NodeInput::node(1, 0))], DocumentNodeMetadata::default());
.to_document_node_default_inputs([Some(NodeInput::node(NodeId(1), 0))], DocumentNodeMetadata::default());
let id = generate_uuid();
let id = NodeId(generate_uuid());
responses.add(GraphOperationMessage::NewCustomLayer {
id,
nodes: HashMap::from([(1, brush_node), (0, cull_node)]),
nodes: HashMap::from([(NodeId(1), brush_node), (NodeId(0), cull_node)]),
parent: document.new_layer_parent(),
insert_index: -1,
});

View File

@@ -3,6 +3,7 @@ use crate::messages::tool::common_functionality::color_selector::{ToolColorOptio
use crate::messages::tool::common_functionality::graph_modification_utils;
use crate::messages::tool::common_functionality::resize::Resize;
use graph_craft::document::NodeId;
use graphene_core::uuid::generate_uuid;
use graphene_core::vector::style::{Fill, Stroke};
use graphene_core::Color;
@@ -205,7 +206,7 @@ impl Fsm for EllipseToolFsmState {
// Create a new ellipse vector shape
let subpath = bezier_rs::Subpath::new_ellipse(DVec2::ZERO, DVec2::ONE);
let manipulator_groups = subpath.manipulator_groups().to_vec();
let layer = graph_modification_utils::new_vector_layer(vec![subpath], generate_uuid(), document.new_layer_parent(), responses);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], NodeId(generate_uuid()), document.new_layer_parent(), responses);
graph_modification_utils::set_manipulator_mirror_angle(&manipulator_groups, layer, true, responses);
shape_data.layer = Some(layer);

View File

@@ -4,6 +4,7 @@ use crate::messages::portfolio::document::utility_types::document_metadata::Laye
use crate::messages::tool::common_functionality::color_selector::{ToolColorOptions, ToolColorType};
use crate::messages::tool::common_functionality::graph_modification_utils;
use graph_craft::document::NodeId;
use graphene_core::uuid::generate_uuid;
use graphene_core::vector::style::{Fill, Stroke};
use graphene_core::Color;
@@ -211,7 +212,7 @@ impl Fsm for FreehandToolFsmState {
let subpath = bezier_rs::Subpath::from_anchors([pos], false);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], generate_uuid(), parent, responses);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], NodeId(generate_uuid()), parent, responses);
tool_data.layer = Some(layer);
responses.add(GraphOperationMessage::FillSet {

View File

@@ -120,7 +120,7 @@ impl Fsm for ImaginateToolFsmState {
(ImaginateToolFsmState::Ready, ImaginateToolMessage::DragStart) => {
shape_data.start(responses, document, input);
responses.add(DocumentMessage::StartTransaction);
shape_data.layer = Some(LayerNodeIdentifier::new(generate_uuid(), document.network()));
shape_data.layer = Some(LayerNodeIdentifier::new(NodeId(generate_uuid()), document.network()));
responses.add(DocumentMessage::DeselectAllLayers);
use graph_craft::document::*;
@@ -140,15 +140,17 @@ impl Fsm for ImaginateToolFsmState {
let imaginate_node_type = &*IMAGINATE_NODE;
// Give them a unique ID
let [transform_node_id, imaginate_node_id] = [100, 101];
let transform_node_id = NodeId(100);
let imaginate_node_id = NodeId(101);
// Create the network based on the Input -> Output passthrough default network
let mut network = node_graph::new_image_network(16, imaginate_node_id);
// Insert the nodes into the default network
network
.nodes
.insert(transform_node_id, transform_node_type.to_document_node_default_inputs([Some(NodeInput::node(0, 0))], next_pos()));
network.nodes.insert(
transform_node_id,
transform_node_type.to_document_node_default_inputs([Some(NodeInput::node(NodeId(0), 0))], next_pos()),
);
network.nodes.insert(
imaginate_node_id,
imaginate_node_type.to_document_node_default_inputs([Some(graph_craft::document::NodeInput::node(transform_node_id, 0))], next_pos()),

View File

@@ -5,6 +5,7 @@ use crate::messages::tool::common_functionality::color_selector::{ToolColorOptio
use crate::messages::tool::common_functionality::graph_modification_utils;
use crate::messages::tool::common_functionality::snapping::SnapManager;
use graph_craft::document::NodeId;
use graphene_core::uuid::generate_uuid;
use graphene_core::vector::style::Stroke;
use graphene_core::Color;
@@ -183,7 +184,7 @@ impl Fsm for LineToolFsmState {
responses.add(DocumentMessage::StartTransaction);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], generate_uuid(), document.new_layer_parent(), responses);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], NodeId(generate_uuid()), document.new_layer_parent(), responses);
responses.add(GraphOperationMessage::StrokeSet {
layer,
stroke: Stroke::new(tool_options.stroke.active_color(), tool_options.line_weight),

View File

@@ -9,6 +9,7 @@ use crate::messages::tool::common_functionality::graph_modification_utils;
use crate::messages::tool::common_functionality::graph_modification_utils::get_subpaths;
use crate::messages::tool::common_functionality::snapping::SnapManager;
use graph_craft::document::NodeId;
use graphene_core::uuid::{generate_uuid, ManipulatorGroupId};
use graphene_core::vector::style::{Fill, Stroke};
use graphene_core::vector::{ManipulatorPointId, SelectedType};
@@ -255,7 +256,7 @@ impl PenToolData {
// Create the initial shape with a `bez_path` (only contains a moveto initially)
let subpath = bezier_rs::Subpath::new(vec![bezier_rs::ManipulatorGroup::new(start_position, Some(start_position), Some(start_position))], false);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], generate_uuid(), parent, responses);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], NodeId(generate_uuid()), parent, responses);
self.layer = Some(layer);
responses.add(GraphOperationMessage::FillSet {

View File

@@ -3,6 +3,7 @@ use crate::messages::tool::common_functionality::color_selector::{ToolColorOptio
use crate::messages::tool::common_functionality::graph_modification_utils;
use crate::messages::tool::common_functionality::resize::Resize;
use graph_craft::document::NodeId;
use graphene_core::uuid::generate_uuid;
use graphene_core::vector::style::{Fill, Stroke};
use graphene_core::Color;
@@ -246,7 +247,7 @@ impl Fsm for PolygonToolFsmState {
PrimitiveShapeType::Polygon => bezier_rs::Subpath::new_regular_polygon(DVec2::ZERO, tool_options.vertices as u64, 1.),
PrimitiveShapeType::Star => bezier_rs::Subpath::new_star_polygon(DVec2::ZERO, tool_options.vertices as u64, 1., 0.5),
};
let layer = graph_modification_utils::new_vector_layer(vec![subpath], generate_uuid(), document.new_layer_parent(), responses);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], NodeId(generate_uuid()), document.new_layer_parent(), responses);
polygon_data.layer = Some(layer);
let fill_color = tool_options.fill.active_color();

View File

@@ -3,6 +3,7 @@ use crate::messages::tool::common_functionality::color_selector::{ToolColorOptio
use crate::messages::tool::common_functionality::graph_modification_utils;
use crate::messages::tool::common_functionality::resize::Resize;
use graph_craft::document::NodeId;
use graphene_core::uuid::generate_uuid;
use graphene_core::vector::style::{Fill, Stroke};
use graphene_core::Color;
@@ -215,7 +216,7 @@ impl Fsm for RectangleToolFsmState {
responses.add(DocumentMessage::StartTransaction);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], generate_uuid(), document.new_layer_parent(), responses);
let layer = graph_modification_utils::new_vector_layer(vec![subpath], NodeId(generate_uuid()), document.new_layer_parent(), responses);
shape_data.layer = Some(layer);
let fill_color = tool_options.fill.active_color();

View File

@@ -6,6 +6,7 @@ use crate::messages::tool::common_functionality::color_selector::{ToolColorOptio
use crate::messages::tool::common_functionality::graph_modification_utils;
use crate::messages::tool::common_functionality::snapping::SnapManager;
use graph_craft::document::NodeId;
use graphene_core::uuid::generate_uuid;
use graphene_core::vector::style::{Fill, Stroke};
use graphene_core::Color;
@@ -224,7 +225,7 @@ impl Fsm for SplineToolFsmState {
tool_data.weight = tool_options.line_weight;
let layer = graph_modification_utils::new_vector_layer(vec![], generate_uuid(), parent, responses);
let layer = graph_modification_utils::new_vector_layer(vec![], NodeId(generate_uuid()), parent, responses);
responses.add(GraphOperationMessage::FillSet {
layer,

View File

@@ -8,6 +8,7 @@ use crate::messages::tool::common_functionality::color_selector::{ToolColorOptio
use crate::messages::tool::common_functionality::graph_modification_utils::{self, is_layer_fed_by_node_of_name};
use graph_craft::document::value::TaggedValue;
use graph_craft::document::NodeId;
use graphene_core::renderer::Quad;
use graphene_core::text::{load_face, Font, FontCache};
use graphene_core::vector::style::Fill;
@@ -287,7 +288,7 @@ impl TextToolData {
else if let Some(editing_text) = self.editing_text.as_ref().filter(|_| state == TextToolFsmState::Ready) {
responses.add(DocumentMessage::StartTransaction);
self.layer = LayerNodeIdentifier::new_unchecked(generate_uuid());
self.layer = LayerNodeIdentifier::new_unchecked(NodeId(generate_uuid()));
responses.add(GraphOperationMessage::NewTextLayer {
id: self.layer.to_node(),

View File

@@ -278,7 +278,10 @@ impl NodeRuntime {
image_data.extend(render.image_data.into_iter().filter_map(|(_, image)| NodeGraphExecutor::to_frontend_image_data(image, resize).ok()))
}
if !image_data.is_empty() {
responses.add(FrontendMessage::UpdateImageData { document_id: 0, image_data });
responses.add(FrontendMessage::UpdateImageData {
document_id: DocumentId(0),
image_data,
});
}
}