mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
Improve the Data panel with type-specific detail pages and nested-layer support (#4070)
* Improve the Data panel with more type-specific detail pages * Add network_path to SetDisplayName so renames target any network depth * Track nested layers via full editor:layer paths and rename parent_layer to path_of_subgraph * Polish the data panel NodeId leaf page with an editable name field * Make lock and visibility toggles work for layers in nested subgraphs * Fix formatting * Fix connected_to_output running in the wrong network for nested-layer toggles
This commit is contained in:
@@ -15,13 +15,14 @@ async fn path_modify(_ctx: impl Ctx, mut vector: Table<Vector>, modification: Bo
|
||||
}
|
||||
modification.apply(vector.element_mut(0).expect("push should give one item"));
|
||||
|
||||
// Update the source node id (penultimate element in the path, identifying the user-facing layer node)
|
||||
let this_node_path = {
|
||||
let index = node_path.len().wrapping_sub(2);
|
||||
node_path.element(index).copied()
|
||||
// Set the path to the encapsulating subgraph (drop our own trailing entry from `node_path`),
|
||||
// matching the `path_of_subgraph` proto so editor tools can route data back to the parent layer.
|
||||
let subgraph_path: Table<NodeId> = {
|
||||
let len = node_path.len();
|
||||
node_path.into_iter().take(len.saturating_sub(1)).collect()
|
||||
};
|
||||
let existing: Option<NodeId> = vector.attribute_cloned_or_default("editor:layer", 0);
|
||||
vector.set_attribute("editor:layer", 0, existing.or(this_node_path));
|
||||
let existing: Table<NodeId> = vector.attribute_cloned_or_default("editor:layer", 0);
|
||||
vector.set_attribute("editor:layer", 0, if existing.is_empty() { subgraph_path } else { existing });
|
||||
|
||||
if vector.len() > 1 {
|
||||
warn!("The path modify ran on {} vector rows. Only the first can be modified.", vector.len());
|
||||
|
||||
@@ -1296,8 +1296,8 @@ pub async fn flatten_path<T: IntoGraphicTable + 'n + Send>(_: impl Ctx, #[implem
|
||||
// Concatenate every vector element's subpaths into the single output compound path
|
||||
for index in 0..flattened.len() {
|
||||
let Some(element) = flattened.element(index) else { continue };
|
||||
let node_id: Option<NodeId> = flattened.attribute_cloned_or_default("editor:layer", index);
|
||||
let node_id = node_id.map(|node_id| node_id.0).unwrap_or_default();
|
||||
let layer_path: Table<NodeId> = flattened.attribute_cloned_or_default("editor:layer", index);
|
||||
let node_id = layer_path.iter_element_values().next_back().map(|node_id| node_id.0).unwrap_or_default();
|
||||
|
||||
let mut hasher = DefaultHasher::new();
|
||||
(index, node_id).hash(&mut hasher);
|
||||
@@ -1318,8 +1318,8 @@ pub async fn flatten_path<T: IntoGraphicTable + 'n + Send>(_: impl Ctx, #[implem
|
||||
// Adopt the last input row's layer so the editor can also bucket clicks under a contributing child layer
|
||||
if !flattened.is_empty() {
|
||||
let primary = flattened.len() - 1;
|
||||
let layer: Option<NodeId> = flattened.attribute_cloned_or_default("editor:layer", primary);
|
||||
output_table.set_attribute("editor:layer", 0, layer);
|
||||
let layer_path: Table<NodeId> = flattened.attribute_cloned_or_default("editor:layer", primary);
|
||||
output_table.set_attribute("editor:layer", 0, layer_path);
|
||||
}
|
||||
|
||||
output_table
|
||||
@@ -2529,13 +2529,13 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
|
||||
// The result is a synthesis of source and target, so adopt whichever endpoint the result is closer to as
|
||||
// the click-target identity (so the editor can route clicks back to one of the contributing layers)
|
||||
let primary_index = if time < 0.5 { source_index } else { target_index };
|
||||
let layer: Option<NodeId> = content.attribute_cloned_or_default("editor:layer", primary_index);
|
||||
let layer_path: Table<NodeId> = content.attribute_cloned_or_default("editor:layer", primary_index);
|
||||
|
||||
Table::new_from_row(
|
||||
TableRow::new_from_element(vector)
|
||||
.with_attribute("transform", lerped_transform)
|
||||
.with_attribute("alpha_blending", vector_alpha_blending)
|
||||
.with_attribute("editor:layer", layer)
|
||||
.with_attribute("editor:layer", layer_path)
|
||||
.with_attribute("editor:merged_layers", graphic_table_content),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user