mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 14:38:12 +08:00
Re-home the layer-path stamp and switch the node path to its plain value form
This commit is contained in:
@@ -180,6 +180,11 @@ fn generate_layout(introspected_data: &Arc<dyn std::any::Any + Send + Sync + 'st
|
|||||||
if let Some(list) = introspected_data.downcast_ref::<List<NodeId>>() {
|
if let Some(list) = introspected_data.downcast_ref::<List<NodeId>>() {
|
||||||
return Some(table_node_id_path_layout_with_breadcrumb(list, data));
|
return Some(table_node_id_path_layout_with_breadcrumb(list, data));
|
||||||
}
|
}
|
||||||
|
// The path's plain value form, produced by `path_of_subgraph` on leveled wires.
|
||||||
|
if let Some(path) = introspected_data.downcast_ref::<Vec<NodeId>>() {
|
||||||
|
let list: List<NodeId> = path.iter().copied().map(graphene_std::list::Item::new_from_element).collect();
|
||||||
|
return Some(table_node_id_path_layout_with_breadcrumb(&list, data));
|
||||||
|
}
|
||||||
generate_layout_downcast!(introspected_data, data, [
|
generate_layout_downcast!(introspected_data, data, [
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
@@ -1011,6 +1016,11 @@ fn drilldown_attribute_layout(any: &dyn Any, data: &mut LayoutData) -> Option<Ve
|
|||||||
if let Some(path) = any.downcast_ref::<List<NodeId>>() {
|
if let Some(path) = any.downcast_ref::<List<NodeId>>() {
|
||||||
return Some(table_node_id_path_layout_with_breadcrumb(path, data));
|
return Some(table_node_id_path_layout_with_breadcrumb(path, data));
|
||||||
}
|
}
|
||||||
|
// The path's plain value form, the layer-path marker's owned shape.
|
||||||
|
if let Some(path) = any.downcast_ref::<Vec<NodeId>>() {
|
||||||
|
let list: List<NodeId> = path.iter().copied().map(graphene_std::list::Item::new_from_element).collect();
|
||||||
|
return Some(table_node_id_path_layout_with_breadcrumb(&list, data));
|
||||||
|
}
|
||||||
macro_rules! check {
|
macro_rules! check {
|
||||||
( $($ty:ty),* $(,)? ) => {
|
( $($ty:ty),* $(,)? ) => {
|
||||||
$(
|
$(
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ pub enum DocumentNodeMetadata {
|
|||||||
impl DocumentNodeMetadata {
|
impl DocumentNodeMetadata {
|
||||||
pub fn ty(&self) -> Type {
|
pub fn ty(&self) -> Type {
|
||||||
match self {
|
match self {
|
||||||
DocumentNodeMetadata::DocumentNodePath => concrete!(core_types::list::List<NodeId>),
|
DocumentNodeMetadata::DocumentNodePath => concrete!(Vec<NodeId>),
|
||||||
DocumentNodeMetadata::SourceId => concrete!(u64),
|
DocumentNodeMetadata::SourceId => concrete!(u64),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,10 +174,7 @@ macro_rules! tagged_value {
|
|||||||
// NON-SERIALIZED VARIANTS
|
// NON-SERIALIZED VARIANTS
|
||||||
// =======================
|
// =======================
|
||||||
Self::RenderOutput(x) => Box::new(x),
|
Self::RenderOutput(x) => Box::new(x),
|
||||||
Self::NodeIdPath(path) => {
|
Self::NodeIdPath(path) => Box::new(path),
|
||||||
let list: List<NodeId> = path.into_iter().map(core_types::list::Item::new_from_element).collect();
|
|
||||||
Box::new(list)
|
|
||||||
}
|
|
||||||
Self::DocumentNode(node) => Box::new(node),
|
Self::DocumentNode(node) => Box::new(node),
|
||||||
Self::ContextModification(modification) => Box::new(modification),
|
Self::ContextModification(modification) => Box::new(modification),
|
||||||
Self::EditorApi(x) => Box::new(x),
|
Self::EditorApi(x) => Box::new(x),
|
||||||
@@ -224,10 +221,7 @@ macro_rules! tagged_value {
|
|||||||
// NON-SERIALIZED VARIANTS
|
// NON-SERIALIZED VARIANTS
|
||||||
// =======================
|
// =======================
|
||||||
Self::RenderOutput(x) => Arc::new(x),
|
Self::RenderOutput(x) => Arc::new(x),
|
||||||
Self::NodeIdPath(path) => {
|
Self::NodeIdPath(path) => Arc::new(path),
|
||||||
let list: List<NodeId> = path.into_iter().map(core_types::list::Item::new_from_element).collect();
|
|
||||||
Arc::new(list)
|
|
||||||
}
|
|
||||||
Self::DocumentNode(node) => Arc::new(node),
|
Self::DocumentNode(node) => Arc::new(node),
|
||||||
Self::ContextModification(modification) => Arc::new(modification),
|
Self::ContextModification(modification) => Arc::new(modification),
|
||||||
Self::EditorApi(x) => Arc::new(x),
|
Self::EditorApi(x) => Arc::new(x),
|
||||||
@@ -255,7 +249,7 @@ macro_rules! tagged_value {
|
|||||||
// NON-SERIALIZED VARIANTS
|
// NON-SERIALIZED VARIANTS
|
||||||
// =======================
|
// =======================
|
||||||
Self::RenderOutput(_) => concrete!(RenderOutput),
|
Self::RenderOutput(_) => concrete!(RenderOutput),
|
||||||
Self::NodeIdPath(_) => concrete!(List<NodeId>),
|
Self::NodeIdPath(_) => concrete!(Vec<NodeId>),
|
||||||
Self::DocumentNode(_) => concrete!(DocumentNode),
|
Self::DocumentNode(_) => concrete!(DocumentNode),
|
||||||
Self::ContextModification(_) => concrete!(ContextModification),
|
Self::ContextModification(_) => concrete!(ContextModification),
|
||||||
Self::EditorApi(_) => concrete!(Arc<PlatformEditorApi>),
|
Self::EditorApi(_) => concrete!(Arc<PlatformEditorApi>),
|
||||||
@@ -283,7 +277,7 @@ macro_rules! tagged_value {
|
|||||||
Self::BrushStrokes(_) => core_types::record::element_write::<List<BrushStroke>>(),
|
Self::BrushStrokes(_) => core_types::record::element_write::<List<BrushStroke>>(),
|
||||||
$( Self::$identifier(_) => core_types::record::element_write::<$ty>(), )*
|
$( Self::$identifier(_) => core_types::record::element_write::<$ty>(), )*
|
||||||
Self::RenderOutput(_) => core_types::record::element_write::<RenderOutput>(),
|
Self::RenderOutput(_) => core_types::record::element_write::<RenderOutput>(),
|
||||||
Self::NodeIdPath(_) => core_types::record::element_write::<List<NodeId>>(),
|
Self::NodeIdPath(_) => core_types::record::element_write::<Vec<NodeId>>(),
|
||||||
Self::DocumentNode(_) => core_types::record::element_write::<DocumentNode>(),
|
Self::DocumentNode(_) => core_types::record::element_write::<DocumentNode>(),
|
||||||
Self::ContextModification(_) => core_types::record::element_write::<ContextModification>(),
|
Self::ContextModification(_) => core_types::record::element_write::<ContextModification>(),
|
||||||
Self::EditorApi(_) => core_types::record::element_write::<Arc<PlatformEditorApi>>(),
|
Self::EditorApi(_) => core_types::record::element_write::<Arc<PlatformEditorApi>>(),
|
||||||
@@ -330,10 +324,7 @@ macro_rules! tagged_value {
|
|||||||
// NON-SERIALIZED VARIANTS
|
// NON-SERIALIZED VARIANTS
|
||||||
// =======================
|
// =======================
|
||||||
Self::RenderOutput(x) => Ok(record_value_edge(x)),
|
Self::RenderOutput(x) => Ok(record_value_edge(x)),
|
||||||
Self::NodeIdPath(path) => {
|
Self::NodeIdPath(path) => Ok(record_value_edge(path)),
|
||||||
let list: List<NodeId> = path.into_iter().map(core_types::list::Item::new_from_element).collect();
|
|
||||||
Ok(record_value_edge(list))
|
|
||||||
}
|
|
||||||
Self::DocumentNode(node) => Ok(record_value_edge(node)),
|
Self::DocumentNode(node) => Ok(record_value_edge(node)),
|
||||||
Self::ContextModification(modification) => Ok(record_value_edge(modification)),
|
Self::ContextModification(modification) => Ok(record_value_edge(modification)),
|
||||||
Self::EditorApi(x) => Ok(record_value_edge(x)),
|
Self::EditorApi(x) => Ok(record_value_edge(x)),
|
||||||
@@ -623,7 +614,6 @@ impl TaggedValue {
|
|||||||
Self::Color(color) => Ok(leveled_record_value_edge(color.into_iter().collect::<Vec<_>>())),
|
Self::Color(color) => Ok(leveled_record_value_edge(color.into_iter().collect::<Vec<_>>())),
|
||||||
Self::Gradient(stops) => Ok(leveled_record_value_edge(vec![stops])),
|
Self::Gradient(stops) => Ok(leveled_record_value_edge(vec![stops])),
|
||||||
Self::BrushStrokes(strokes) => Ok(leveled_record_value_edge(strokes)),
|
Self::BrushStrokes(strokes) => Ok(leveled_record_value_edge(strokes)),
|
||||||
Self::NodeIdPath(path) => Ok(leveled_record_value_edge(path)),
|
|
||||||
other => other.to_edge(),
|
other => other.to_edge(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use core_types::attribute::{Attr, Transform as TransformAttr};
|
use core_types::attribute::{Attr, EditorLayerPath, Transform as TransformAttr};
|
||||||
use core_types::bounds::{BoundingBox, RenderBoundingBox};
|
use core_types::bounds::{BoundingBox, RenderBoundingBox};
|
||||||
use core_types::extent::{ExtentIn, LevelIn, ListIn, ValueIn};
|
use core_types::extent::{ExtentIn, LevelIn, ListIn, ValueIn};
|
||||||
use core_types::gpoll::{Extent, GPoll, GraphError, Interrupt, Level};
|
use core_types::gpoll::{Extent, GPoll, GraphError, Interrupt, Level};
|
||||||
@@ -204,11 +204,22 @@ where
|
|||||||
/// editor tools (e.g. selection, click target routing) trace data back to its owning layer regardless of whether
|
/// editor tools (e.g. selection, click target routing) trace data back to its owning layer regardless of whether
|
||||||
/// the layer is at the root document network or nested inside a custom subgraph.
|
/// the layer is at the root document network or nested inside a custom subgraph.
|
||||||
#[node_macro::node(name("Path of Subgraph"), category(""))]
|
#[node_macro::node(name("Path of Subgraph"), category(""))]
|
||||||
pub fn path_of_subgraph(_: impl Ctx, node_path: List<NodeId>) -> List<NodeId> {
|
pub fn path_of_subgraph(_: impl Ctx, node_path: Vec<NodeId>) -> Vec<NodeId> {
|
||||||
let len = node_path.len();
|
let len = node_path.len();
|
||||||
node_path.into_iter().take(len.saturating_sub(1)).collect()
|
node_path.into_iter().take(len.saturating_sub(1)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The layer-path stamp: writes the owning layer's document node path on
|
||||||
|
/// each lane, which lets editor tools trace data back to its layer.
|
||||||
|
#[node_macro::node(category(""))]
|
||||||
|
pub fn stamp_layer_path<'e, T>(ctx: impl Ctx + ExtractArena<'e>, element: T, path: Vec<NodeId>) -> Result<(T, Attr<'e, EditorLayerPath>), Interrupt> {
|
||||||
|
let (parked, _) = ctx.arena().alloc(path).ok_or(GraphError {
|
||||||
|
kind: core_types::gpoll::ErrorKind::ArenaExhausted,
|
||||||
|
trace: Vec::new(),
|
||||||
|
})?;
|
||||||
|
Ok((element, Attr(parked.as_slice())))
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets a named attribute on the input `List`, computing one value per item via the value-producing input. That input
|
/// Sets a named attribute on the input `List`, computing one value per item via the value-producing input. That input
|
||||||
/// is evaluated once per item, with the item's index and the item itself (as a `List` containing only that item,
|
/// is evaluated once per item, with the item's index and the item itself (as a `List` containing only that item,
|
||||||
/// passed as a vararg) provided via context, so the upstream pipeline can return a different value per item that may
|
/// passed as a vararg) provided via context, so the upstream pipeline can return a different value per item that may
|
||||||
|
|||||||
Reference in New Issue
Block a user