diff --git a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs index f3662b6bd9..8ca2521009 100644 --- a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs +++ b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs @@ -297,7 +297,7 @@ fn document_node_definitions() -> HashMap HashMap HashMap(ctx: impl Ctx + DeriveCtx + ModifyFootprint, content: impl Node, Output = T>, offset: DVec2) -> Result { + let translated = ctx.modify_footprint(|footprint| footprint.translate(offset)); + content.eval(&translated.ctx()) +} + +fn translate_footprint_extent(content: ExtentIn<'_>, _offset: ValueIn<'_, DVec2>, level: LevelIn) -> GPoll { + content.at(level) +} + +/// Constructs an artboard element with the given content and metadata stored as attributes. #[node_macro::node(category(""))] -pub fn create_artboard( - ctx: impl Ctx + DeriveCtx + ModifyFootprint, +pub fn create_artboard( + _: impl Ctx + ExtractIndex + InjectIndex + Copy, /// Graphics to include within the artboard. - #[implementations( - Context -> List, - Context -> List, - Context -> List, - Context -> List>, - Context -> List>, - Context -> List, - Context -> List, - Context -> DAffine2, - )] - content: impl Node, Output = T>, + content: IList, /// Coordinate of the top-left corner of the artboard within the document. location: DVec2, /// Width and height of the artboard within the document. dimensions: DVec2, /// Color of the artboard background. - background: List, + background: IList, /// Whether to cut off the contained content that extends outside the artboard, or keep it visible. #[default(true)] clip: bool, -) -> Result, Interrupt> { - let translated = ctx.modify_footprint(|footprint| footprint.translate(location)); - let content = content.eval(&translated.ctx())?.into_graphic_list(); +) -> (Artboard, Attr, Attr, Attr, Attr) { + // SAFETY: a materialized input's frames are arena-resident. + let item = unsafe { core_types::record::GroupItem::from_resident(content.batch()) }; + let content = graphic_types::graphic::group_to_legacy_list(&core_types::record::Group { + row: None, + content: core_types::record::GroupContent::Run(item), + }); // Normalize so `location` is the top-left corner and `dimensions` are positive (allowing negative input // dimensions to represent dragging from the opposite corner). Compute the corner using the raw signed @@ -43,14 +48,11 @@ pub fn create_artboard( let normalized_location = location.min(location + dimensions); let normalized_dimensions = dimensions.abs().max(DVec2::ONE); - let background = background.element(0).copied().unwrap_or(Color::WHITE); + let background = match background.len() { + 0 => Color::WHITE, + _ => background.get(0), + }; // Name is not stored here, it's resolved live from the parent layer's display name - Ok(List::new_from_item( - Item::new_from_element(Artboard::new(content)) - .with_attribute(ATTR_LOCATION, normalized_location) - .with_attribute(ATTR_DIMENSIONS, normalized_dimensions) - .with_attribute(ATTR_BACKGROUND, background) - .with_attribute(ATTR_CLIP, clip), - )) + (Artboard::new(content), Attr(normalized_location), Attr(normalized_dimensions), Attr(background), Attr(clip)) }