mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 02:48:12 +08:00
Add artboard displayed names in the viewport (#1795)
* possible location of the change is decided. * fix for issue #1774 * possible location of the change is decided. * fix for issue #1774 * fix for #1706 * fix for #1706, code reformatted * fix for #1706, Label input removed from Properties * fix for #1706 * deleted the comment
This commit is contained in:
@@ -1110,14 +1110,14 @@ impl NodeNetwork {
|
||||
}
|
||||
|
||||
/// Remove all nodes that contain [`DocumentNodeImplementation::Network`] by moving the nested nodes into the parent network.
|
||||
pub fn flatten(&mut self, node: NodeId) {
|
||||
self.flatten_with_fns(node, merge_ids, || NodeId(generate_uuid()))
|
||||
pub fn flatten(&mut self, node_id: NodeId) {
|
||||
self.flatten_with_fns(node_id, merge_ids, || NodeId(generate_uuid()))
|
||||
}
|
||||
|
||||
/// Remove all nodes that contain [`DocumentNodeImplementation::Network`] by moving the nested nodes into the parent network.
|
||||
pub fn flatten_with_fns(&mut self, node: NodeId, map_ids: impl Fn(NodeId, NodeId) -> NodeId + Copy, gen_id: impl Fn() -> NodeId + Copy) {
|
||||
let Some((id, mut node)) = self.nodes.remove_entry(&node) else {
|
||||
warn!("The node which was supposed to be flattened does not exist in the network, id {node} network {self:#?}");
|
||||
pub fn flatten_with_fns(&mut self, node_id: NodeId, map_ids: impl Fn(NodeId, NodeId) -> NodeId + Copy, gen_id: impl Fn() -> NodeId + Copy) {
|
||||
let Some((id, mut node)) = self.nodes.remove_entry(&node_id) else {
|
||||
warn!("The node which was supposed to be flattened does not exist in the network, id {node_id} network {self:#?}");
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -1166,6 +1166,7 @@ impl NodeNetwork {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replace value inputs with value nodes, added to flattened network
|
||||
for input in node.inputs.iter_mut() {
|
||||
let previous_input = std::mem::replace(input, NodeInput::network(concrete!(()), 0));
|
||||
@@ -1201,8 +1202,16 @@ impl NodeNetwork {
|
||||
// Connect all network inputs to either the parent network nodes, or newly created value nodes for the parent node.
|
||||
inner_network.map_ids(|inner_id| map_ids(id, inner_id));
|
||||
let new_nodes = inner_network.nodes.keys().cloned().collect::<Vec<_>>();
|
||||
|
||||
// Match the document node input and the inputs of the inner network
|
||||
for (nested_node_id, mut nested_node) in inner_network.nodes.into_iter() {
|
||||
if nested_node.name == "To Artboard" {
|
||||
let label_index = 1;
|
||||
let label = if !node.alias.is_empty() { node.alias.clone() } else { node.name.clone() };
|
||||
let label_input = NodeInput::value(TaggedValue::String(label), false);
|
||||
nested_node.inputs[label_index] = label_input;
|
||||
}
|
||||
|
||||
for (nested_input_index, nested_input) in nested_node.clone().inputs.iter().enumerate() {
|
||||
if let NodeInput::Network { import_index, .. } = nested_input {
|
||||
let parent_input = node.inputs.get(*import_index).expect("Import index should always exist");
|
||||
|
||||
@@ -238,6 +238,17 @@ impl<'a> TaggedValue {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_string(&self) -> String {
|
||||
match self {
|
||||
TaggedValue::String(x) => x.to_string(),
|
||||
TaggedValue::U32(x) => x.to_string(),
|
||||
TaggedValue::U64(x) => x.to_string(),
|
||||
TaggedValue::F64(x) => x.to_string(),
|
||||
TaggedValue::Bool(x) => x.to_string(),
|
||||
_ => panic!("Cannot convert to string"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_primitive_string(&self) -> String {
|
||||
match self {
|
||||
TaggedValue::None => "()".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user