Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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,6 +35,7 @@ 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 });
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
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 @@ -1816,13 +1817,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 +1833,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 @@ -1945,6 +1948,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
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 +2401,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 +2411,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 +2474,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 +2484,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
1 change: 1 addition & 0 deletions frontend/wrapper/src/editor_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ impl EditorWrapper {
let layer = LayerNodeIdentifier::new_unchecked(NodeId(id));
let message = NodeGraphMessage::SetDisplayName {
node_id: layer.to_node(),
network_path: Vec::new(),
alias: name,
skip_adding_history_step: false,
};
Expand Down
2 changes: 0 additions & 2 deletions node-graph/interpreted-executor/src/node_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_std::vector::misc::CentroidType]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_std::vector::misc::PointSpacingType]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Option<f64>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Option<NodeId>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<String>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<NodeId>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<f64>]),
Expand Down Expand Up @@ -173,7 +172,6 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Raster<GPU>>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Option<f64>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Option<Color>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Option<NodeId>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Graphic]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => glam::f32::Vec2]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => glam::f32::Affine2]),
Expand Down
4 changes: 2 additions & 2 deletions node-graph/libraries/graphic-types/src/graphic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn flatten_graphic_table<T>(content: Table<Graphic>, extract_variant: fn(Graphic

fn flatten_recursive<T>(output: &mut Table<T>, current_graphic_table: Table<Graphic>, extract_variant: fn(Graphic) -> Option<Table<T>>) {
for current_graphic_row in current_graphic_table.into_iter() {
let layer: Option<NodeId> = current_graphic_row.attribute_cloned_or_default("editor:layer");
let layer_path: Table<NodeId> = current_graphic_row.attribute_cloned_or_default("editor:layer");
let current_transform: DAffine2 = current_graphic_row.attribute_cloned_or_default("transform");
let current_alpha_blending: AlphaBlending = current_graphic_row.attribute_cloned_or_default("alpha_blending");

Expand All @@ -168,7 +168,7 @@ fn flatten_graphic_table<T>(content: Table<Graphic>, extract_variant: fn(Graphic

attributes.insert("transform", current_transform * row_transform);
attributes.insert("alpha_blending", compose_alpha_blending(current_alpha_blending, row_alpha_blending));
attributes.insert("editor:layer", layer);
attributes.insert("editor:layer", layer_path.clone());

output.push(TableRow::from_parts(element, attributes));
}
Expand Down
16 changes: 10 additions & 6 deletions node-graph/libraries/rendering/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ impl Render for Graphic {
metadata.upstream_footprints.insert(element_id, footprint);
// TODO: Find a way to handle more than the first row
if !table.is_empty() {
let layer: Option<NodeId> = table.attribute_cloned_or_default("editor:layer", 0);
let layer_path: Table<NodeId> = table.attribute_cloned_or_default("editor:layer", 0);
let layer = layer_path.iter_element_values().next_back().copied();
let transform: DAffine2 = table.attribute_cloned_or_default("transform", 0);

metadata.first_element_source_id.insert(element_id, layer);
Expand Down Expand Up @@ -655,7 +656,8 @@ impl Render for Table<Artboard> {

fn collect_metadata(&self, metadata: &mut RenderMetadata, footprint: Footprint, _element_id: Option<NodeId>) {
for index in 0..self.len() {
let layer: Option<NodeId> = self.attribute_cloned_or_default("editor:layer", index);
let layer_path: Table<NodeId> = self.attribute_cloned_or_default("editor:layer", index);
let layer = layer_path.iter_element_values().next_back().copied();
self.element(index).unwrap().collect_metadata(metadata, footprint, layer);
}
}
Expand Down Expand Up @@ -805,7 +807,8 @@ impl Render for Table<Graphic> {
fn collect_metadata(&self, metadata: &mut RenderMetadata, footprint: Footprint, element_id: Option<NodeId>) {
for index in 0..self.len() {
let row_transform: DAffine2 = self.attribute_cloned_or_default("transform", index);
let layer: Option<NodeId> = self.attribute_cloned_or_default("editor:layer", index);
let layer_path: Table<NodeId> = self.attribute_cloned_or_default("editor:layer", index);
let layer = layer_path.iter_element_values().next_back().copied();
let element = self.element(index).unwrap();

let mut footprint = footprint;
Expand Down Expand Up @@ -860,9 +863,9 @@ impl Render for Table<Graphic> {
}

fn new_ids_from_hash(&mut self, _reference: Option<NodeId>) {
let (elements, layers) = self.element_and_attribute_slices_mut::<Option<NodeId>>("editor:layer");
let (elements, layers) = self.element_and_attribute_slices_mut::<Table<NodeId>>("editor:layer");
for (element, layer) in elements.iter_mut().zip(layers.iter()) {
element.new_ids_from_hash(*layer);
element.new_ids_from_hash(layer.iter_element_values().next_back().copied());
}
}
}
Expand Down Expand Up @@ -1327,7 +1330,8 @@ impl Render for Table<Vector> {
for index in 0..self.len() {
let Some(vector) = self.element(index) else { continue };
let transform: DAffine2 = self.attribute_cloned_or_default("transform", index);
let layer: Option<NodeId> = self.attribute_cloned_or_default("editor:layer", index);
let layer_path: Table<NodeId> = self.attribute_cloned_or_default("editor:layer", index);
let layer = layer_path.iter_element_values().next_back().copied();

if let Some(element_id) = caller_element_id.or(layer) {
// When recovering element_id from the row's editor:layer tag (because the caller
Expand Down
2 changes: 1 addition & 1 deletion node-graph/nodes/brush/src/brush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async fn brush(

let transform: DAffine2 = actual_image.attribute_cloned_or_default("transform");
let alpha_blending: AlphaBlending = actual_image.attribute_cloned_or_default("alpha_blending");
let layer: Option<NodeId> = actual_image.attribute_cloned_or_default("editor:layer");
let layer: Table<NodeId> = actual_image.attribute_cloned_or_default("editor:layer");

*image.element_mut(0).unwrap() = actual_image.into_element();
image.set_attribute("transform", 0, transform);
Expand Down
1 change: 0 additions & 1 deletion node-graph/nodes/gcore/src/context_modification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ async fn context_modification<T>(
Context -> DAffine2,
Context -> Footprint,
Context -> DVec2,
Context -> Option<NodeId>,
Context -> Table<String>,
Context -> Table<NodeId>,
Context -> Table<f64>,
Expand Down
Loading
Loading