Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ impl MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessageHa
});
responses.add(NodeGraphMessage::SetDisplayNameImpl {
node_id,
network_path: Vec::new(),
alias: "Background".to_string(),
});
responses.add(NodeGraphMessage::SetLocked { node_id, locked: true });
responses.add(NodeGraphMessage::SetLocked {
node_id,
network_path: Vec::new(),
locked: true,
});
} else if self.dimensions.x > 0 && self.dimensions.y > 0 {
// Finite canvas: create an artboard with the specified dimensions
responses.add(GraphOperationMessage::NewArtboard {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ pub enum DataPanelMessage {
inspect_result: InspectResult,
},
ClearLayout,
/// Re-render the existing layout against the latest network interface state. Use this when node metadata
/// (display name, visibility, locked, etc.) changes but the introspected output value hasn't.
Refresh,

PushToElementPath {
step: PathStep,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
if let Some(name) = name {
responses.add(NodeGraphMessage::SetDisplayName {
node_id: layer.to_node(),
network_path: Vec::new(),
alias: name,
skip_adding_history_step: false,
});
Expand Down Expand Up @@ -756,6 +757,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
if let Some(name) = name {
responses.add(NodeGraphMessage::SetDisplayName {
node_id: layer.to_node(),
network_path: Vec::new(),
alias: name,
skip_adding_history_step: false,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ impl MessageHandler<GraphOperationMessage, GraphOperationMessageContext<'_>> for

responses.add(NodeGraphMessage::SetDisplayNameImpl {
node_id: id,
network_path: Vec::new(),
alias: layer_alias.to_string(),
});
responses.add(NodeGraphMessage::SetDisplayNameImpl {
node_id: control_path_id,
network_path: Vec::new(),
alias: path_alias.to_string(),
});
}
Expand Down Expand Up @@ -245,6 +247,7 @@ impl MessageHandler<GraphOperationMessage, GraphOperationMessageContext<'_>> for
network_interface.move_layer_to_stack(layer, parent, insert_index, &[]);
responses.add(NodeGraphMessage::SetDisplayNameImpl {
node_id: id,
network_path: Vec::new(),
alias: "Boolean Operation".to_string(),
});
responses.add(NodeGraphMessage::RunDocumentGraph);
Expand Down Expand Up @@ -343,6 +346,7 @@ impl MessageHandler<GraphOperationMessage, GraphOperationMessageContext<'_>> for

responses.add(NodeGraphMessage::SetDisplayName {
node_id,
network_path: Vec::new(),
alias: network_interface.display_name(&artboard.to_node(), &[]),
skip_adding_history_step: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
// Derive the parent layer's NodeId from the document path
DocumentNode {
inputs: vec![NodeInput::Reflection(graph_craft::document::DocumentNodeMetadata::DocumentNodePath)],
implementation: DocumentNodeImplementation::ProtoNode(graphic::parent_layer::IDENTIFIER),
implementation: DocumentNodeImplementation::ProtoNode(graphic::path_of_subgraph::IDENTIFIER),
..Default::default()
},
// Stamp each row of the content with the parent layer's NodeId via the `editor:layer` attribute,
Expand Down Expand Up @@ -299,7 +299,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
},
..Default::default()
},
// 2: parent_layer
// 2: path_of_subgraph
DocumentNodeMetadata {
persistent_metadata: DocumentNodePersistentMetadata {
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(-21, 1)),
Expand Down Expand Up @@ -371,7 +371,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
// Derive the parent layer's NodeId from the document path
DocumentNode {
inputs: vec![NodeInput::Reflection(graph_craft::document::DocumentNodeMetadata::DocumentNodePath)],
implementation: DocumentNodeImplementation::ProtoNode(graphic::parent_layer::IDENTIFIER),
implementation: DocumentNodeImplementation::ProtoNode(graphic::path_of_subgraph::IDENTIFIER),
..Default::default()
},
// Stamp each row of the content with the parent layer's NodeId via the `editor:layer` attribute,
Expand Down Expand Up @@ -461,7 +461,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
},
..Default::default()
},
// 1: parent_layer
// 1: path_of_subgraph
DocumentNodeMetadata {
persistent_metadata: DocumentNodePersistentMetadata {
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(-21, 3)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,15 @@ pub enum NodeGraphMessage {
},
SetDisplayName {
node_id: NodeId,
/// The path to the network containing `node_id`. Empty for nodes at the root document network.
/// Lets the rename target a node at any nesting depth, independent of the current selection network.
network_path: Vec<NodeId>,
alias: String,
skip_adding_history_step: bool,
},
SetDisplayNameImpl {
node_id: NodeId,
network_path: Vec<NodeId>,
alias: String,
},
SetToNodeOrLayer {
Expand Down Expand Up @@ -199,26 +203,35 @@ pub enum NodeGraphMessage {
ToggleSelectedLocked,
ToggleLocked {
node_id: NodeId,
/// The path to the network containing `node_id`. Empty for nodes at the root document network.
/// Lets the toggle target a node at any nesting depth, independent of the current selection network.
network_path: Vec<NodeId>,
},
SetLocked {
node_id: NodeId,
network_path: Vec<NodeId>,
locked: bool,
},
ToggleSelectedIsPinned,
ToggleSelectedVisibility,
ToggleVisibility {
node_id: NodeId,
/// The path to the network containing `node_id`. Empty for nodes at the root document network.
/// Lets the toggle target a node at any nesting depth, independent of the current selection network.
network_path: Vec<NodeId>,
},
SetPinned {
node_id: NodeId,
pinned: bool,
},
SetVisibility {
node_id: NodeId,
network_path: Vec<NodeId>,
visible: bool,
},
SetLockedOrVisibilitySideEffects {
node_ids: Vec<NodeId>,
network_path: Vec<NodeId>,
},
UpdateEdges,
UpdateBoxSelection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
});
responses.add(NodeGraphMessage::SetDisplayNameImpl {
node_id: encapsulating_node_id,
network_path: selection_network_path.to_vec(),
alias: "Untitled Node".to_string(),
});

Expand Down Expand Up @@ -909,13 +910,19 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG

// Toggle visibility of clicked node and return
if let Some(clicked_visibility) = network_interface.layer_click_target_from_click(click, network_interface::LayerClickTargetTypes::Visibility, selection_network_path) {
responses.add(NodeGraphMessage::ToggleVisibility { node_id: clicked_visibility });
responses.add(NodeGraphMessage::ToggleVisibility {
node_id: clicked_visibility,
network_path: selection_network_path.to_vec(),
});
return;
}

// Toggle lock of clicked node and return
if let Some(clicked_lock) = network_interface.layer_click_target_from_click(click, network_interface::LayerClickTargetTypes::Lock, selection_network_path) {
responses.add(NodeGraphMessage::ToggleLocked { node_id: clicked_lock });
responses.add(NodeGraphMessage::ToggleLocked {
node_id: clicked_lock,
network_path: selection_network_path.to_vec(),
});
return;
}

Expand Down Expand Up @@ -1816,13 +1823,14 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
}
NodeGraphMessage::SetDisplayName {
node_id,
network_path,
alias,
skip_adding_history_step,
} => {
if !skip_adding_history_step {
responses.add(DocumentMessage::StartTransaction);
}
responses.add(NodeGraphMessage::SetDisplayNameImpl { node_id, alias });
responses.add(NodeGraphMessage::SetDisplayNameImpl { node_id, network_path, alias });
if !skip_adding_history_step {
// Does not add a history step if the name was not changed
responses.add(DocumentMessage::EndTransaction);
Expand All @@ -1831,9 +1839,10 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
responses.add(DocumentMessage::RenderScrollbars);
responses.add(NodeGraphMessage::SendGraph);
responses.add(OverlaysMessage::Draw); // Redraw overlays to update artboard names
responses.add(DataPanelMessage::Refresh);
}
NodeGraphMessage::SetDisplayNameImpl { node_id, alias } => {
network_interface.set_display_name(&node_id, alias, selection_network_path);
NodeGraphMessage::SetDisplayNameImpl { node_id, network_path, alias } => {
network_interface.set_display_name(&node_id, alias, &network_path);
}
NodeGraphMessage::SetImportExportName { name, index } => {
responses.add(DocumentMessage::StartTransaction);
Expand Down Expand Up @@ -1872,25 +1881,34 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
responses.add(DocumentMessage::AddTransaction);

for node_id in &node_ids {
responses.add(NodeGraphMessage::SetLocked { node_id: *node_id, locked });
responses.add(NodeGraphMessage::SetLocked {
node_id: *node_id,
network_path: selection_network_path.to_vec(),
locked,
});
}

responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects { node_ids })
responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects {
node_ids,
network_path: selection_network_path.to_vec(),
})
}
NodeGraphMessage::ToggleLocked { node_id } => {
let Some(node_metadata) = network_interface.document_network_metadata().persistent_metadata.node_metadata.get(&node_id) else {
log::error!("Cannot get node {node_id:?} in NodeGraphMessage::ToggleLocked");
return;
};

let locked = !node_metadata.persistent_metadata.locked;
NodeGraphMessage::ToggleLocked { node_id, network_path } => {
let locked = !network_interface.is_locked(&node_id, &network_path);

responses.add(DocumentMessage::AddTransaction);
responses.add(NodeGraphMessage::SetLocked { node_id, locked });
responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects { node_ids: vec![node_id] })
responses.add(NodeGraphMessage::SetLocked {
node_id,
network_path: network_path.clone(),
locked,
});
responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects {
node_ids: vec![node_id],
network_path,
});
}
NodeGraphMessage::SetLocked { node_id, locked } => {
network_interface.set_locked(&node_id, selection_network_path, locked);
NodeGraphMessage::SetLocked { node_id, network_path, locked } => {
network_interface.set_locked(&node_id, &network_path, locked);
}
NodeGraphMessage::ToggleSelectedIsPinned => {
let Some(selected_nodes) = network_interface.selected_nodes_in_nested_network(selection_network_path) else {
Expand All @@ -1906,7 +1924,10 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
for node_id in &node_ids {
responses.add(NodeGraphMessage::SetPinned { node_id: *node_id, pinned });
}
responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects { node_ids });
responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects {
node_ids,
network_path: selection_network_path.to_vec(),
});
}
NodeGraphMessage::ToggleSelectedVisibility => {
let Some(selected_nodes) = network_interface.selected_nodes_in_nested_network(selection_network_path) else {
Expand All @@ -1920,31 +1941,46 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG

responses.add(DocumentMessage::AddTransaction);
for node_id in &node_ids {
responses.add(NodeGraphMessage::SetVisibility { node_id: *node_id, visible });
responses.add(NodeGraphMessage::SetVisibility {
node_id: *node_id,
network_path: selection_network_path.to_vec(),
visible,
});
}
responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects { node_ids });
responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects {
node_ids,
network_path: selection_network_path.to_vec(),
});
}
NodeGraphMessage::ToggleVisibility { node_id } => {
let visible = !network_interface.is_visible(&node_id, selection_network_path);
NodeGraphMessage::ToggleVisibility { node_id, network_path } => {
let visible = !network_interface.is_visible(&node_id, &network_path);

responses.add(DocumentMessage::AddTransaction);
responses.add(NodeGraphMessage::SetVisibility { node_id, visible });
responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects { node_ids: vec![node_id] });
responses.add(NodeGraphMessage::SetVisibility {
node_id,
network_path: network_path.clone(),
visible,
});
responses.add(NodeGraphMessage::SetLockedOrVisibilitySideEffects {
node_ids: vec![node_id],
network_path,
});
}
NodeGraphMessage::SetPinned { node_id, pinned } => {
network_interface.set_pinned(&node_id, selection_network_path, pinned);
}
NodeGraphMessage::SetVisibility { node_id, visible } => {
network_interface.set_visibility(&node_id, selection_network_path, visible);
NodeGraphMessage::SetVisibility { node_id, network_path, visible } => {
network_interface.set_visibility(&node_id, &network_path, visible);
}
NodeGraphMessage::SetLockedOrVisibilitySideEffects { node_ids } => {
if node_ids.iter().any(|node_id| network_interface.connected_to_output(node_id, selection_network_path)) {
NodeGraphMessage::SetLockedOrVisibilitySideEffects { node_ids, network_path } => {
if node_ids.iter().any(|node_id| network_interface.connected_to_output(node_id, &network_path)) {
responses.add(NodeGraphMessage::RunDocumentGraph);
}
responses.add(NodeGraphMessage::UpdateActionButtons);
responses.add(NodeGraphMessage::SendGraph);

responses.add(PropertiesPanelMessage::Refresh);
responses.add(DataPanelMessage::Refresh);
}
NodeGraphMessage::UpdateBoxSelection => {
if let Some((box_selection_start, _)) = self.box_selection_start {
Expand Down Expand Up @@ -2397,6 +2433,7 @@ impl NodeGraphMessageHandler {
let mut properties = Vec::new();

if let [node_id] = *nodes.as_slice() {
let network_path = context.selection_network_path.to_vec();
properties.push(LayoutGroup::row(vec![
Separator::new(SeparatorStyle::Related).widget_instance(),
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_instance(),
Expand All @@ -2406,6 +2443,7 @@ impl NodeGraphMessageHandler {
.on_update(move |text_input| {
NodeGraphMessage::SetDisplayName {
node_id,
network_path: network_path.clone(),
alias: text_input.value.clone(),
skip_adding_history_step: false,
}
Expand Down Expand Up @@ -2468,6 +2506,7 @@ impl NodeGraphMessageHandler {
return Vec::new();
}

let layer_network_path = context.selection_network_path.to_vec();
let mut layer_properties = vec![LayoutGroup::row(vec![
Separator::new(SeparatorStyle::Related).widget_instance(),
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_instance(),
Expand All @@ -2477,6 +2516,7 @@ impl NodeGraphMessageHandler {
.on_update(move |text_input| {
NodeGraphMessage::SetDisplayName {
node_id: layer,
network_path: layer_network_path.clone(),
alias: text_input.value.clone(),
skip_adding_history_step: false,
}
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/portfolio/document_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ pub fn document_migration_reset_node_definition(document_serialized_content: &st
return true;
}

// The `source_node_id` proto node was removed in favor of `parent_layer` + `write_attribute`.
// The `source_node_id` proto node was removed in favor of `path_of_subgraph` + `write_attribute`.
// Documents that still reference it inside their Merge or Artboard layer networks need those layer definitions
// reset to the current default so the new internal plumbing replaces the obsolete node.
if document_serialized_content.contains("graphic_nodes::graphic::SourceNodeIdNode")
Expand Down
Loading
Loading