mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-26 07:28:11 +08:00
Layer-based nodes redesign, just the basics so far (#1362)
* Redesign the nodes * Basic vertical stacking syntax sugar * Fix node connections * Primary output and line thickness --------- Co-authored-by: 0hypercube <0hypercube@gmail.com>
This commit is contained in:
co-authored by
0hypercube
parent
94a0f8282e
commit
3450d638a6
+2
-2
@@ -307,9 +307,9 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
let [mut old_bounds_min, mut old_bounds_max] = [DVec2::ZERO, DVec2::ONE];
|
||||
let [mut new_bounds_min, mut new_bounds_max] = [DVec2::ZERO, DVec2::ONE];
|
||||
|
||||
self.modify_inputs("Path Generator", false, |inputs| {
|
||||
self.modify_inputs("Shape", false, |inputs| {
|
||||
let [subpaths, mirror_angle_groups] = inputs.as_mut_slice() else {
|
||||
panic!("Path generator does not have subpath and mirror angle inputs");
|
||||
panic!("Shape does not have subpath and mirror angle inputs");
|
||||
};
|
||||
|
||||
let NodeInput::Value {
|
||||
|
||||
@@ -80,7 +80,10 @@ pub struct FrontendNode {
|
||||
pub primary_input: Option<FrontendGraphDataType>,
|
||||
#[serde(rename = "exposedInputs")]
|
||||
pub exposed_inputs: Vec<NodeGraphInput>,
|
||||
pub outputs: Vec<NodeGraphOutput>, // TODO: Break this apart into `primary_output` and `exposed_outputs`
|
||||
#[serde(rename = "primaryOutput")]
|
||||
pub primary_output: Option<NodeGraphOutput>,
|
||||
#[serde(rename = "exposedOutputs")]
|
||||
pub exposed_outputs: Vec<NodeGraphOutput>,
|
||||
pub position: (i32, i32),
|
||||
pub disabled: bool,
|
||||
pub previewed: bool,
|
||||
@@ -336,14 +339,11 @@ impl NodeGraphMessageHandler {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let outputs = node_type
|
||||
.outputs
|
||||
.iter()
|
||||
.map(|output_type| NodeGraphOutput {
|
||||
data_type: output_type.data_type,
|
||||
name: output_type.name.to_string(),
|
||||
})
|
||||
.collect();
|
||||
let mut outputs = node_type.outputs.iter().map(|output_type| NodeGraphOutput {
|
||||
data_type: output_type.data_type,
|
||||
name: output_type.name.to_string(),
|
||||
});
|
||||
let primary_output = outputs.next();
|
||||
|
||||
let graph_identifier = GraphIdentifier::new(layer_id);
|
||||
let thumbnail_svg = executor.thumbnails.get(&graph_identifier).and_then(|thumbnails| thumbnails.get(id)).map(|svg| svg.to_string());
|
||||
@@ -353,7 +353,8 @@ impl NodeGraphMessageHandler {
|
||||
display_name: node.name.clone(),
|
||||
primary_input,
|
||||
exposed_inputs,
|
||||
outputs,
|
||||
primary_output,
|
||||
exposed_outputs: outputs.collect::<Vec<_>>(),
|
||||
position: node.metadata.position.into(),
|
||||
previewed: network.outputs_contain(*id),
|
||||
disabled: network.disabled.contains(id),
|
||||
|
||||
+2
-2
@@ -1662,7 +1662,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Path Generator",
|
||||
name: "Shape",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_core::vector::generator_nodes::PathGenerator<_>"),
|
||||
inputs: vec![
|
||||
@@ -1998,7 +1998,7 @@ pub fn new_image_network(output_offset: i32, output_node_id: NodeId) -> NodeNetw
|
||||
}
|
||||
|
||||
pub fn new_vector_network(subpaths: Vec<bezier_rs::Subpath<uuid::ManipulatorGroupId>>) -> NodeNetwork {
|
||||
let path_generator = resolve_document_node_type("Path Generator").expect("Path Generator node does not exist");
|
||||
let path_generator = resolve_document_node_type("Shape").expect("Shape node does not exist");
|
||||
let transform = resolve_document_node_type("Transform").expect("Transform node does not exist");
|
||||
let fill = resolve_document_node_type("Fill").expect("Fill node does not exist");
|
||||
let stroke = resolve_document_node_type("Stroke").expect("Stroke node does not exist");
|
||||
|
||||
@@ -790,7 +790,7 @@ fn get_subpaths<'a>(layer_path: &[LayerId], document: &'a DocumentMessageHandler
|
||||
let layer = document.document_legacy.layer(layer_path).ok().and_then(|layer| layer.as_layer().ok())?;
|
||||
let network = &layer.network;
|
||||
for (node, _node_id) in network.primary_flow() {
|
||||
if node.name == "Path Generator" {
|
||||
if node.name == "Shape" {
|
||||
let subpaths_input = node.inputs.get(0)?;
|
||||
let NodeInput::Value {
|
||||
tagged_value: TaggedValue::Subpaths(subpaths),
|
||||
|
||||
Reference in New Issue
Block a user