Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish user-created subgraph nodes: imports in the Properties panel; reorder/delete/rename imports/exports #2105

Merged
merged 38 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0fbbffd
Remove imports/exports
adamgerhant Nov 10, 2024
303db62
WIP: Autogenerated properties
adamgerhant Nov 16, 2024
1db7728
WIP: Input based properties
adamgerhant Nov 18, 2024
228dedd
WIP: Hashmap based input overrides
adamgerhant Nov 23, 2024
f1fbccb
Migrate noise pattern node to input properties
adamgerhant Nov 24, 2024
2e40f5f
Reorder exports
adamgerhant Nov 28, 2024
ac8e215
Continue migrating properties
adamgerhant Dec 2, 2024
3a3b1d2
WIP: Improve reorder exports
adamgerhant Dec 4, 2024
6d894ee
Automatically populate all input properties for sub networks
adamgerhant Dec 4, 2024
b6f8b85
Complete reorder import and export
adamgerhant Dec 4, 2024
be4b2dc
Add widget override to node macro
adamgerhant Dec 6, 2024
9f73908
Migrate assign colors to input based properties
adamgerhant Dec 9, 2024
885843f
WIP: Full node property override
adamgerhant Dec 18, 2024
04db166
Node based properties override for proto nodes
adamgerhant Dec 19, 2024
e1d435e
Migrate all node properties to be input based
adamgerhant Dec 23, 2024
3f8700d
Rename imports/exports
adamgerhant Dec 26, 2024
c62fbd3
Merge branch 'master' into modify-import-export
adamgerhant Dec 26, 2024
1aab000
improve UI
adamgerhant Dec 27, 2024
41c9185
Protonode input valid implementations
adamgerhant Dec 28, 2024
b4203a8
Valid type list
adamgerhant Dec 30, 2024
ceb83b2
Merge branch 'master' into modify-import-export
adamgerhant Jan 9, 2025
202a8e5
Small formatting fixes
adamgerhant Jan 9, 2025
79ab7a3
Polishing small issues
adamgerhant Jan 13, 2025
987b36c
Document upgrade
adamgerhant Jan 14, 2025
fc6193e
fix tests
adamgerhant Jan 15, 2025
3594d79
Merge branch 'master' into modify-import-export
adamgerhant Jan 15, 2025
c1fc86e
Merge branch 'master' into modify-import-export
Keavon Jan 15, 2025
cffa490
Upgrade noise pattern node
adamgerhant Jan 17, 2025
07b0448
remove console log
adamgerhant Jan 17, 2025
577d197
Merge branch 'master' into modify-import-export
Keavon Jan 19, 2025
8dfa753
Fix upgrade script for Noise Pattern
Keavon Jan 20, 2025
769cba2
Improve the Properties panel representation for graphical data
Keavon Jan 20, 2025
b402c36
Re-export demo art
Keavon Jan 20, 2025
a8f7b11
Code review
Keavon Jan 20, 2025
1ceb85e
code review improvements
adamgerhant Jan 20, 2025
fc5e5cd
Cleanup for node properties overrides
Keavon Jan 20, 2025
e5cc11b
Reexport demo art
Keavon Jan 21, 2025
07ef5c9
Fix clippy lints
Keavon Jan 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
350 changes: 172 additions & 178 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo-artwork/changing-seasons.graphite

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo-artwork/isometric-fountain.graphite

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo-artwork/marbled-mandelbrot.graphite

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo-artwork/painted-dreams.graphite

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo-artwork/procedural-string-lights.graphite

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo-artwork/red-dress.graphite

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo-artwork/valley-of-spires.graphite

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions editor/src/messages/frontend/frontend_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ pub enum FrontendMessage {
UpdateGraphViewOverlay {
open: bool,
},
UpdateImportReorderIndex {
#[serde(rename = "importIndex")]
index: Option<usize>,
},
UpdateExportReorderIndex {
#[serde(rename = "exportIndex")]
index: Option<usize>,
},
UpdateLayerWidths {
#[serde(rename = "layerWidths")]
layer_widths: HashMap<NodeId, u32>,
Expand Down
56 changes: 23 additions & 33 deletions editor/src/messages/portfolio/document/document_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
}
DocumentMessage::PropertiesPanel(message) => {
let properties_panel_message_handler_data = PropertiesPanelMessageHandlerData {
network_interface: &self.network_interface,
network_interface: &mut self.network_interface,
selection_network_path: &self.selection_network_path,
document_name: self.name.as_str(),
executor,
Expand Down Expand Up @@ -391,6 +391,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
self.selection_network_path.clone_from(&self.breadcrumb_network_path);
responses.add(NodeGraphMessage::SendGraph);
responses.add(DocumentMessage::ZoomCanvasToFitAll);
responses.add(NodeGraphMessage::SetGridAlignedEdges);
}
DocumentMessage::Escape => {
if self.node_graph_handler.drag_start.is_some() {
Expand Down Expand Up @@ -1007,7 +1008,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
}
responses.add(PropertiesPanelMessage::Refresh);
responses.add(NodeGraphMessage::UpdateLayerPanel);
responses.add(NodeGraphMessage::UpdateInSelectedNetwork)
responses.add(NodeGraphMessage::UpdateInSelectedNetwork);
}
DocumentMessage::SetBlendModeForSelectedLayers { blend_mode } => {
for layer in self.network_interface.selected_nodes(&[]).unwrap().selected_layers_except_artboards(&self.network_interface) {
Expand All @@ -1018,6 +1019,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
self.graph_fade_artwork_percentage = percentage;
responses.add(FrontendMessage::UpdateGraphFadeArtwork { percentage });
}

DocumentMessage::SetNodePinned { node_id, pinned } => {
responses.add(DocumentMessage::StartTransaction);
responses.add(NodeGraphMessage::SetPinned { node_id, pinned });
Expand Down Expand Up @@ -1224,21 +1226,13 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
.navigation_handler
.calculate_offset_transform(ipp.viewport_bounds.center(), &network_metadata.persistent_metadata.navigation_metadata.node_graph_ptz);
self.network_interface.set_transform(transform, &self.breadcrumb_network_path);
let imports = self.network_interface.frontend_imports(&self.breadcrumb_network_path).unwrap_or_default();
let exports = self.network_interface.frontend_exports(&self.breadcrumb_network_path).unwrap_or_default();
let add_import = self.network_interface.frontend_import_modify(&self.breadcrumb_network_path);
let add_export = self.network_interface.frontend_export_modify(&self.breadcrumb_network_path);

responses.add(DocumentMessage::RenderRulers);
responses.add(DocumentMessage::RenderScrollbars);
responses.add(NodeGraphMessage::UpdateEdges);
responses.add(NodeGraphMessage::UpdateBoxSelection);
responses.add(FrontendMessage::UpdateImportsExports {
imports,
exports,
add_import,
add_export,
});
responses.add(NodeGraphMessage::UpdateImportsExports);

responses.add(FrontendMessage::UpdateNodeGraphTransform {
transform: Transform {
scale: transform.matrix2.x_axis.x,
Expand Down Expand Up @@ -1465,26 +1459,22 @@ impl DocumentMessageHandler {
}

pub fn deserialize_document(serialized_content: &str) -> Result<Self, EditorError> {
let document_message_handler = serde_json::from_str::<OldDocumentMessageHandler>(serialized_content)
.map_or_else(
|_| serde_json::from_str::<DocumentMessageHandler>(serialized_content),
|old_message_handler| {
let default_document_message_handler = DocumentMessageHandler {
network_interface: NodeNetworkInterface::from_old_network(old_message_handler.network),
collapsed: old_message_handler.collapsed,
commit_hash: old_message_handler.commit_hash,
document_ptz: old_message_handler.document_ptz,
document_mode: old_message_handler.document_mode,
view_mode: old_message_handler.view_mode,
overlays_visible: old_message_handler.overlays_visible,
rulers_visible: old_message_handler.rulers_visible,
graph_view_overlay_open: old_message_handler.graph_view_overlay_open,
snapping_state: old_message_handler.snapping_state,
..Default::default()
};
Ok(default_document_message_handler)
},
)
let document_message_handler = serde_json::from_str::<DocumentMessageHandler>(serialized_content)
.or_else(|_| {
serde_json::from_str::<OldDocumentMessageHandler>(serialized_content).map(|old_message_handler| DocumentMessageHandler {
network_interface: NodeNetworkInterface::from_old_network(old_message_handler.network),
collapsed: old_message_handler.collapsed,
commit_hash: old_message_handler.commit_hash,
document_ptz: old_message_handler.document_ptz,
document_mode: old_message_handler.document_mode,
view_mode: old_message_handler.view_mode,
overlays_visible: old_message_handler.overlays_visible,
rulers_visible: old_message_handler.rulers_visible,
graph_view_overlay_open: old_message_handler.graph_view_overlay_open,
snapping_state: old_message_handler.snapping_state,
..Default::default()
})
})
.map_err(|e| EditorError::DocumentDeserialization(e.to_string()))?;
Ok(document_message_handler)
}
Expand Down Expand Up @@ -2089,7 +2079,7 @@ impl DocumentMessageHandler {
/// Create a network interface with a single export
fn default_document_network_interface() -> NodeNetworkInterface {
let mut network_interface = NodeNetworkInterface::default();
network_interface.add_export(TaggedValue::ArtboardGroup(graphene_core::ArtboardGroup::EMPTY), -1, "".to_string(), &[]);
network_interface.add_export(TaggedValue::ArtboardGroup(graphene_core::ArtboardGroup::EMPTY), -1, "", &[]);
network_interface
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl<'a> ModifyInputsContext<'a> {
let transform = resolve_document_node_type("Transform").expect("Transform node does not exist").default_node_template();
let image = resolve_document_node_type("Image")
.expect("Image node does not exist")
.node_template_input_override([Some(NodeInput::value(TaggedValue::ImageFrame(image_frame), false))]);
.node_template_input_override([Some(NodeInput::value(TaggedValue::None, false)), Some(NodeInput::value(TaggedValue::ImageFrame(image_frame), false))]);

let image_id = NodeId::new();
self.network_interface.insert_node(image_id, image, &[]);
Expand Down Expand Up @@ -256,7 +256,11 @@ impl<'a> ModifyInputsContext<'a> {
let mut existing_node_id = None;
for upstream_node in upstream.collect::<Vec<_>>() {
// Check if this is the node we have been searching for.
if self.network_interface.reference(&upstream_node, &[]).is_some_and(|node_reference| node_reference == reference) {
if self
.network_interface
.reference(&upstream_node, &[])
.is_some_and(|node_reference| *node_reference == Some(reference.to_string()))
{
existing_node_id = Some(upstream_node);
break;
}
Expand Down
Loading
Loading