mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 10:28:12 +08:00
Migrate node graph UI interaction from frontend to backend (#1768)
* Click node using click targets based * Display graph transform based on state stored in Rust, fix zoom and pan. * Migrate node selection logic * Move click targets and transform to NodeNetwork * Keep click targets in sync with changes to node shape * Click targets for import/export, add dragging * Basic wire dragging * complete wire dragging * Add node selection box when dragging * Fix zoom operations and dragging nodes * Remove click targets from serialized data, fix EnterNestedNetwork * WIP: Auto connect node when dragged on wire * Finish auto connect node when dragged on wire * Add context menus * Improve layer width calculations and state * Improve context menu state, various other improvements * Close menu on escape * Cleanup Graph.svelte * Fix lock/hide tool tip shortcuts * Clean up editor_api.rs, fix lock/hide layers * Start transferring network and node metadata from NodeNetwork to the editor * Transfer click targets to NodeGraphMessageHandler * Fix infinite canvas * Fix undo/redo, scrollbars, and fix warnings * Unicode-3.0 license and code cleanup * License fix * formatting issue * Enable DomRect * Fix layer move crash * Remove tests * Ignore test * formatting * remove white dot --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
cf01f522a8
commit
02360c7bc8
@@ -1,10 +1,8 @@
|
||||
use super::tool_prelude::*;
|
||||
use crate::messages::portfolio::document::node_graph::document_node_types::resolve_document_node_type;
|
||||
use crate::messages::portfolio::document::node_graph::document_node_types::{new_image_network, IMAGINATE_NODE};
|
||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||
use crate::messages::tool::common_functionality::resize::Resize;
|
||||
|
||||
use graph_craft::document::{generate_uuid, DocumentNodeMetadata, NodeId, NodeInput};
|
||||
use graph_craft::document::{generate_uuid, NodeId};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ImaginateTool {
|
||||
@@ -106,36 +104,36 @@ impl Fsm for ImaginateToolFsmState {
|
||||
shape_data.layer = Some(LayerNodeIdentifier::new(NodeId(generate_uuid()), document.network()));
|
||||
responses.add(DocumentMessage::DeselectAllLayers);
|
||||
|
||||
// Utility function to offset the position of each consecutive node
|
||||
let mut pos = 8;
|
||||
let mut next_pos = || {
|
||||
pos += 8;
|
||||
DocumentNodeMetadata::position((pos, 4))
|
||||
};
|
||||
// // Utility function to offset the position of each consecutive node
|
||||
// let mut pos = 8;
|
||||
// let mut next_pos = || {
|
||||
// pos += 8;
|
||||
// DocumentNodeMetadata::position((pos, 4))
|
||||
// };
|
||||
|
||||
// Get the node type for the Transform and Imaginate nodes
|
||||
let Some(transform_node_type) = resolve_document_node_type("Transform") else {
|
||||
warn!("Transform node should be in registry");
|
||||
return ImaginateToolFsmState::Drawing;
|
||||
};
|
||||
let imaginate_node_type = &*IMAGINATE_NODE;
|
||||
// // Get the node type for the Transform and Imaginate nodes
|
||||
// let Some(transform_node_type) = resolve_document_node_type("Transform") else {
|
||||
// warn!("Transform node should be in registry");
|
||||
// return ImaginateToolFsmState::Drawing;
|
||||
// };
|
||||
// let imaginate_node_type = &*IMAGINATE_NODE;
|
||||
|
||||
// Give them a unique ID
|
||||
let transform_node_id = NodeId(100);
|
||||
// // Give them a unique ID
|
||||
// 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 = new_image_network(16, imaginate_node_id);
|
||||
// let mut network = 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(NodeId(0), 0))], next_pos()),
|
||||
);
|
||||
network.nodes.insert(
|
||||
imaginate_node_id,
|
||||
imaginate_node_type.to_document_node_default_inputs([Some(NodeInput::node(transform_node_id, 0))], next_pos()),
|
||||
);
|
||||
// // Insert the nodes into the default network
|
||||
// network.insert_node(
|
||||
// transform_node_id,
|
||||
// transform_node_type.to_document_node_default_inputs([Some(NodeInput::node(NodeId(0), 0))], next_pos()),
|
||||
// );
|
||||
// network.insert_node(
|
||||
// imaginate_node_id,
|
||||
// imaginate_node_type.to_document_node_default_inputs([Some(NodeInput::node(transform_node_id, 0))], next_pos()),
|
||||
// );
|
||||
responses.add(NodeGraphMessage::ShiftNode { node_id: imaginate_node_id });
|
||||
|
||||
// // Add a layer with a frame to the document
|
||||
|
||||
Reference in New Issue
Block a user