mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 23:38:06 +08:00
Add layer node chains, import/export edge connectors, and refactor graph editing to go thru a NodeNetworkInterface (#1794)
* WIP: NodeNetworkInterface * Organize ModifyInputsContext to use network interface * Improve ClickTarget and Position state * Rework ClickTarget state * Continue fixing NodeGraphMessageHandler * Restructure network_metadata * Final(?) NodeNetworkInterface struct * Final(??) NodeNetworkInterface * Final(???) NodeNetworkInterface. Separated persistent and transient data * Final NodeNetworkInterface data structure. Implemented all basic getters * Continue migrating functionality to network interface * Migrate all NodeGraphMessage's to use network interface * Fix all helper functions in NodeGraphMessageHandler * Move document metadata to network interface, remove various cached fields * Move all editor only NodeNetwork implementations to NodeNetworkInterface * Fix all DocumentNodeDefinitions * Rework and migrate GraphOperationMessages to network interface * Continue migration to NodeNetworkInterface * Save point before merging master * Fix all errors in network_interface * 850 -> 160 errors * Fix all errors :D * Render default document * Visualize click targets * merge conflicts * Cache transient metadata separately, store entire interface in document history * Start migration to storing selected nodes for each network * Remove selected nodes from document message handler * Move outward wires and all nodes bounding box to transient metadata * Fix connecting/disconnecting nodes * Layer stack organization for disconnecting/connecting nodes * Basic chain locking * Improve chain positioning * Add copy/pasting * Move upstream nodes on shift+drag * merge conflict fixes * Improve Graph.svelte code quality * Final improvements to Graph.svelte * Fix layer panel * Performance optimizations * Bug fixes and derived PTZ * Chain organization improvement and bug fixes * Bug fixes, remove all warnings * Automatic file upgrade * Final code review * Fix editor tests * Fix compile errors * Remove select tool intersection check when panning * WIP: Import/Exports * Fix JS issues * Finish simplified import/export UI * Import/Export viewport edge UI * Remove minimum y bound on import/export ports * Improve performance while panning graph * cargo fmt * Fix CI code build * Format the demo artwork graph with chains * Code review --------- Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: dennis@kobert.dev <dennis@kobert.dev>
This commit is contained in:
@@ -472,15 +472,17 @@ impl NodeGraphExecutor {
|
||||
/// Evaluates a node graph, computing the entire graph
|
||||
pub fn submit_node_graph_evaluation(&mut self, document: &mut DocumentMessageHandler, viewport_resolution: UVec2, ignore_hash: bool) -> Result<(), String> {
|
||||
// Get the node graph layer
|
||||
let network_hash = document.network().current_hash();
|
||||
let network_hash = document.network_interface.network(&[]).unwrap().current_hash();
|
||||
if network_hash != self.node_graph_hash || ignore_hash {
|
||||
self.node_graph_hash = network_hash;
|
||||
self.sender.send(NodeRuntimeMessage::GraphUpdate(document.network.clone())).map_err(|e| e.to_string())?;
|
||||
self.sender
|
||||
.send(NodeRuntimeMessage::GraphUpdate(document.network_interface.network(&[]).unwrap().clone()))
|
||||
.map_err(|e| e.to_string())?;
|
||||
}
|
||||
|
||||
let render_config = RenderConfig {
|
||||
viewport: Footprint {
|
||||
transform: document.metadata.document_to_viewport,
|
||||
transform: document.metadata().document_to_viewport,
|
||||
resolution: viewport_resolution,
|
||||
..Default::default()
|
||||
},
|
||||
@@ -503,12 +505,12 @@ impl NodeGraphExecutor {
|
||||
|
||||
/// Evaluates a node graph for export
|
||||
pub fn submit_document_export(&mut self, document: &mut DocumentMessageHandler, mut export_config: ExportConfig) -> Result<(), String> {
|
||||
let network = document.network().clone();
|
||||
let network = document.network_interface.network(&[]).unwrap().clone();
|
||||
|
||||
// Calculate the bounding box of the region to be exported
|
||||
let bounds = match export_config.bounds {
|
||||
ExportBounds::AllArtwork => document.metadata().document_bounds_document_space(!export_config.transparent_background),
|
||||
ExportBounds::Selection => document.metadata().selected_bounds_document_space(!export_config.transparent_background, &document.selected_nodes),
|
||||
ExportBounds::AllArtwork => document.network_interface.document_bounds_document_space(!export_config.transparent_background),
|
||||
ExportBounds::Selection => document.network_interface.selected_bounds_document_space(!export_config.transparent_background, &[]),
|
||||
ExportBounds::Artboard(id) => document.metadata().bounding_box_document(id),
|
||||
}
|
||||
.ok_or_else(|| "No bounding box".to_string())?;
|
||||
@@ -587,15 +589,15 @@ impl NodeGraphExecutor {
|
||||
Ok(output) => output,
|
||||
Err(e) => {
|
||||
// Clear the click targets while the graph is in an un-renderable state
|
||||
document.metadata.update_from_monitor(HashMap::new(), HashMap::new());
|
||||
document.network_interface.document_metadata_mut().update_from_monitor(HashMap::new(), HashMap::new());
|
||||
|
||||
return Err(format!("Node graph evaluation failed:\n{e}"));
|
||||
}
|
||||
};
|
||||
|
||||
responses.extend(existing_responses.into_iter().map(Into::into));
|
||||
document.metadata.update_transforms(new_upstream_transforms);
|
||||
document.metadata.update_from_monitor(new_click_targets, new_vector_modify);
|
||||
document.network_interface.document_metadata_mut().update_transforms(new_upstream_transforms);
|
||||
document.network_interface.document_metadata_mut().update_from_monitor(new_click_targets, new_vector_modify);
|
||||
|
||||
let execution_context = self.futures.remove(&execution_id).ok_or_else(|| "Invalid generation ID".to_string())?;
|
||||
if let Some(export_config) = execution_context.export_config {
|
||||
@@ -613,14 +615,14 @@ impl NodeGraphExecutor {
|
||||
} = execution_response;
|
||||
if let Err(e) = result {
|
||||
// Clear the click targets while the graph is in an un-renderable state
|
||||
document.metadata.update_from_monitor(HashMap::new(), HashMap::new());
|
||||
document.network_interface.document_metadata_mut().update_from_monitor(HashMap::new(), HashMap::new());
|
||||
log::trace!("{e}");
|
||||
|
||||
return Err("Node graph evaluation failed".to_string());
|
||||
};
|
||||
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
responses.add(NodeGraphMessage::UpdateTypes { resolved_types, node_graph_errors });
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
}
|
||||
NodeGraphUpdate::NodeGraphUpdateMessage(NodeGraphUpdateMessage::ImaginateStatusUpdate) => {
|
||||
responses.add(DocumentMessage::PropertiesPanel(PropertiesPanelMessage::Refresh));
|
||||
|
||||
Reference in New Issue
Block a user