Replace Table<Table<Graphic>> with Table<Artboard> where Artboard is a type boundary newtype (#4093)

Replace Table<Table<Graphic>> with Table<Artboard> with Artboard as a type boundary newtype
This commit is contained in:
Keavon Chambers 2026-05-01 21:57:50 -07:00 committed by GitHub
parent 9943af5248
commit a0d5f418d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 134 additions and 86 deletions

View File

@ -6,9 +6,6 @@ use crate::messages::prelude::*;
use crate::messages::tool::tool_messages::tool_prelude::*; use crate::messages::tool::tool_messages::tool_prelude::*;
use glam::{Affine2, DAffine2, Vec2}; use glam::{Affine2, DAffine2, Vec2};
use graph_craft::document::NodeId; use graph_craft::document::NodeId;
use graphene_std::Color;
use graphene_std::Context;
use graphene_std::Graphic;
use graphene_std::blending::BlendMode; use graphene_std::blending::BlendMode;
use graphene_std::gradient::GradientStops; use graphene_std::gradient::GradientStops;
use graphene_std::memo::IORecord; use graphene_std::memo::IORecord;
@ -16,6 +13,7 @@ use graphene_std::raster_types::{CPU, GPU, Raster};
use graphene_std::table::Table; use graphene_std::table::Table;
use graphene_std::vector::Vector; use graphene_std::vector::Vector;
use graphene_std::vector::style::{Fill, FillChoice}; use graphene_std::vector::style::{Fill, FillChoice};
use graphene_std::{Artboard, Color, Context, Graphic};
use std::any::Any; use std::any::Any;
use std::sync::Arc; use std::sync::Arc;
@ -183,7 +181,7 @@ fn generate_layout(introspected_data: &Arc<dyn std::any::Any + Send + Sync + 'st
return Some(table_node_id_path_layout_with_breadcrumb(&io.output, data)); return Some(table_node_id_path_layout_with_breadcrumb(&io.output, data));
} }
generate_layout_downcast!(introspected_data, data, [ generate_layout_downcast!(introspected_data, data, [
Table<Table<Graphic>>, Table<Artboard>,
Table<Graphic>, Table<Graphic>,
Table<Vector>, Table<Vector>,
Table<Raster<CPU>>, Table<Raster<CPU>>,
@ -301,6 +299,22 @@ impl<T: TableRowLayout> TableRowLayout for Table<T> {
} }
} }
impl TableRowLayout for Artboard {
fn type_name() -> &'static str {
"Artboard"
}
fn identifier(&self) -> String {
self.as_graphic_table().identifier()
}
// Don't put a breadcrumb for Artboard
fn layout_with_breadcrumb(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
self.value_page(data)
}
fn value_page(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
self.as_graphic_table().layout_with_breadcrumb(data)
}
}
impl TableRowLayout for Graphic { impl TableRowLayout for Graphic {
fn type_name() -> &'static str { fn type_name() -> &'static str {
"Graphic" "Graphic"
@ -871,7 +885,7 @@ impl TableRowLayout for NodeId {
macro_rules! known_table_row_types { macro_rules! known_table_row_types {
($apply:ident) => { ($apply:ident) => {
$apply!( $apply!(
Table<Table<Graphic>>, Table<Artboard>,
Table<Graphic>, Table<Graphic>,
Table<Vector>, Table<Vector>,
Table<Raster<CPU>>, Table<Raster<CPU>>,
@ -900,6 +914,7 @@ macro_rules! known_table_row_types {
Raster<CPU>, Raster<CPU>,
Raster<GPU>, Raster<GPU>,
Graphic, Graphic,
Artboard,
); );
}; };
} }

View File

@ -394,7 +394,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
}, },
DocumentNode { DocumentNode {
inputs: vec![ inputs: vec![
NodeInput::import(graphene_std::Type::Fn(Box::new(concrete!(Context)), Box::new(concrete!(Table<Table<Graphic>>))), 0), NodeInput::import(graphene_std::Type::Fn(Box::new(concrete!(Context)), Box::new(concrete!(Table<Artboard>))), 0),
NodeInput::node(NodeId(3), 0), NodeInput::node(NodeId(3), 0),
], ],
implementation: DocumentNodeImplementation::ProtoNode(graphic::extend::IDENTIFIER), implementation: DocumentNodeImplementation::ProtoNode(graphic::extend::IDENTIFIER),

View File

@ -611,18 +611,15 @@ impl Fsm for ArtboardToolFsmState {
#[cfg(test)] #[cfg(test)]
mod test_artboard { mod test_artboard {
pub use crate::test_utils::test_prelude::*; pub use crate::test_utils::test_prelude::*;
use graphene_std::Graphic; use graphene_std::Artboard;
use graphene_std::table::Table; use graphene_std::table::Table;
async fn get_artboards(editor: &mut EditorTestUtils) -> Table<Table<Graphic>> { async fn get_artboards(editor: &mut EditorTestUtils) -> Table<Artboard> {
let instrumented = match editor.eval_graph().await { let instrumented = match editor.eval_graph().await {
Ok(instrumented) => instrumented, Ok(instrumented) => instrumented,
Err(e) => panic!("Failed to evaluate graph: {e}"), Err(e) => panic!("Failed to evaluate graph: {e}"),
}; };
instrumented instrumented.grab_all_input::<graphene_std::graphic::extend::NewInput<Artboard>>(&editor.runtime).flatten().collect()
.grab_all_input::<graphene_std::graphic::extend::NewInput<Table<graphene_std::Graphic>>>(&editor.runtime)
.flatten()
.collect()
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]

View File

@ -20,7 +20,7 @@ use graphene_std::text::FontCache;
use graphene_std::transform::RenderQuality; use graphene_std::transform::RenderQuality;
use graphene_std::vector::Vector; use graphene_std::vector::Vector;
use graphene_std::vector::style::RenderMode; use graphene_std::vector::style::RenderMode;
use graphene_std::{Context, Graphic}; use graphene_std::{Artboard, Context, Graphic};
use interpreted_executor::dynamic_executor::{DynamicExecutor, IntrospectError, ResolvedDocumentNodeTypesDelta}; use interpreted_executor::dynamic_executor::{DynamicExecutor, IntrospectError, ResolvedDocumentNodeTypesDelta};
use interpreted_executor::util::wrap_network_in_scope; use interpreted_executor::util::wrap_network_in_scope;
use spin::Mutex; use spin::Mutex;
@ -441,7 +441,7 @@ impl NodeRuntime {
} }
// Artboard thumbnail bounds come from the clipping rectangles, not the content union, since the renderer // Artboard thumbnail bounds come from the clipping rectangles, not the content union, since the renderer
// clips content to those rectangles so anything outside isn't visible // clips content to those rectangles so anything outside isn't visible
else if let Some(io) = introspected_data.downcast_ref::<IORecord<Context, Table<Table<Graphic>>>>() { else if let Some(io) = introspected_data.downcast_ref::<IORecord<Context, Table<Artboard>>>() {
if update_thumbnails { if update_thumbnails {
let bounds = artboard_clip_bounds(&io.output); let bounds = artboard_clip_bounds(&io.output);
Self::render_thumbnail(&mut self.thumbnail_renders, parent_network_node_id, &io.output, bounds, responses) Self::render_thumbnail(&mut self.thumbnail_renders, parent_network_node_id, &io.output, bounds, responses)
@ -522,7 +522,7 @@ impl NodeRuntime {
/// Returns the union of the artboards' clipping rectangles, used as the thumbnail bounds for an artboard layer so the /// Returns the union of the artboards' clipping rectangles, used as the thumbnail bounds for an artboard layer so the
/// framing matches what's actually visible after clipping rather than the unclipped content extents. /// framing matches what's actually visible after clipping rather than the unclipped content extents.
fn artboard_clip_bounds(artboards: &Table<Table<Graphic>>) -> RenderBoundingBox { fn artboard_clip_bounds(artboards: &Table<Artboard>) -> RenderBoundingBox {
let mut combined: Option<[DVec2; 2]> = None; let mut combined: Option<[DVec2; 2]> = None;
for index in 0..artboards.len() { for index in 0..artboards.len() {
let location: DVec2 = artboards.attribute_cloned_or_default(graphene_std::ATTR_LOCATION, index); let location: DVec2 = artboards.attribute_cloned_or_default(graphene_std::ATTR_LOCATION, index);

View File

@ -14,7 +14,7 @@ pub use glam::{DAffine2, DVec2, IVec2, UVec2};
use graphic_types::raster_types::{CPU, Image, Raster}; use graphic_types::raster_types::{CPU, Image, Raster};
use graphic_types::vector_types::vector::style::{Fill, Gradient, GradientStops, Stroke}; use graphic_types::vector_types::vector::style::{Fill, Gradient, GradientStops, Stroke};
use graphic_types::vector_types::vector::{self, ReferencePoint}; use graphic_types::vector_types::vector::{self, ReferencePoint};
use graphic_types::{Graphic, Vector}; use graphic_types::{Artboard, Graphic, Vector};
use raster_nodes::curve::Curve; use raster_nodes::curve::Curve;
use rendering::RenderMetadata; use rendering::RenderMetadata;
use std::fmt::Display; use std::fmt::Display;
@ -184,7 +184,7 @@ tagged_value! {
Graphic(Table<Graphic>), Graphic(Table<Graphic>),
#[serde(deserialize_with = "graphic_types::artboard::migrate_artboard")] // TODO: Eventually remove this migration document upgrade code #[serde(deserialize_with = "graphic_types::artboard::migrate_artboard")] // TODO: Eventually remove this migration document upgrade code
#[serde(alias = "ArtboardGroup")] #[serde(alias = "ArtboardGroup")]
Artboard(Table<Table<Graphic>>), Artboard(Table<Artboard>),
#[serde(deserialize_with = "core_types::misc::migrate_color")] // TODO: Eventually remove this migration document upgrade code #[serde(deserialize_with = "core_types::misc::migrate_color")] // TODO: Eventually remove this migration document upgrade code
#[serde(alias = "ColorTable", alias = "OptionalColor", alias = "ColorNotInTable")] #[serde(alias = "ColorTable", alias = "OptionalColor", alias = "ColorNotInTable")]
Color(Table<Color>), Color(Table<Color>),

View File

@ -21,7 +21,7 @@ use graphene_std::table::Table;
use graphene_std::transform::Footprint; use graphene_std::transform::Footprint;
use graphene_std::uuid::NodeId; use graphene_std::uuid::NodeId;
use graphene_std::vector::Vector; use graphene_std::vector::Vector;
use graphene_std::{Context, Graphic, NodeIO, NodeIOTypes, ProtoNodeIdentifier, concrete, fn_type_fut, future}; use graphene_std::{Artboard, Context, Graphic, NodeIO, NodeIOTypes, ProtoNodeIdentifier, concrete, fn_type_fut, future};
use node_registry_macros::{async_node, convert_node, into_node}; use node_registry_macros::{async_node, convert_node, into_node};
use std::collections::HashMap; use std::collections::HashMap;
#[cfg(feature = "gpu")] #[cfg(feature = "gpu")]
@ -63,7 +63,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
// MONITOR NODES // MONITOR NODES
// ============= // =============
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ()]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ()]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Table<Graphic>>]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Artboard>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Graphic>]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Graphic>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Vector>]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Vector>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Raster<CPU>>]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Raster<CPU>>]),
@ -145,7 +145,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
// ========== // ==========
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => ()]), async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => ()]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => bool]), async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => bool]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Table<Graphic>>]), async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Artboard>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Graphic>]), async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Graphic>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Vector>]), async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Vector>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Raster<CPU>>]), async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Raster<CPU>>]),

View File

@ -1,25 +1,71 @@
use crate::graphic::Graphic; use crate::graphic::Graphic;
use core_types::blending::BlendMode; use core_types::blending::BlendMode;
use core_types::bounds::{BoundingBox, RenderBoundingBox};
use core_types::graphene_hash::CacheHash;
use core_types::render_complexity::RenderComplexity;
use core_types::table::{Table, TableRow}; use core_types::table::{Table, TableRow};
use core_types::uuid::NodeId; use core_types::uuid::NodeId;
use core_types::{ATTR_BACKGROUND, ATTR_CLIP, ATTR_DIMENSIONS, ATTR_LOCATION, Color}; use core_types::{ATTR_BACKGROUND, ATTR_CLIP, ATTR_DIMENSIONS, ATTR_LOCATION, Color};
use dyn_any::DynAny; use dyn_any::DynAny;
use glam::{DAffine2, IVec2}; use glam::{DAffine2, IVec2};
// An artboard table is `Table<Table<Graphic>>`: each row's element is the artboard's content /// Nominal wrapper around `Table<Graphic>` representing a single artboard's content.
// (a `Table<Graphic>`), with the artboard's metadata stored alongside on the row as attributes ///
// (see `ATTR_LOCATION`, `ATTR_DIMENSIONS`, `ATTR_BACKGROUND`, `ATTR_CLIP`). /// Per-artboard metadata (location, dimensions, background, clip) lives as row attributes on the
// /// enclosing `Table<Artboard>`, not as fields here. This keeps `Artboard` a pure type-system boundary
// The artboard's user-visible name is the parent layer's display name (resolved live from the /// that prevents arbitrary `Table<Table<...<Graphic>>>` nesting.
// network interface via the row's `ATTR_EDITOR_LAYER_PATH` attribute) — not stored here, so it #[derive(Clone, Debug, Default, CacheHash, PartialEq, DynAny)]
// can never go stale. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
// pub struct Artboard(Table<Graphic>);
// These metadata attributes are populated at runtime by the `Artboard` proto node from its
// inputs and therefore aren't persisted in document files; the proto node's input values are impl Artboard {
// what get serialized. pub fn new(content: Table<Graphic>) -> Self {
Self(content)
}
pub fn as_graphic_table(&self) -> &Table<Graphic> {
&self.0
}
pub fn as_graphic_table_mut(&mut self) -> &mut Table<Graphic> {
&mut self.0
}
pub fn into_graphic_table(self) -> Table<Graphic> {
self.0
}
}
impl From<Table<Graphic>> for Artboard {
fn from(content: Table<Graphic>) -> Self {
Self(content)
}
}
impl From<Artboard> for Table<Graphic> {
fn from(artboard: Artboard) -> Self {
artboard.0
}
}
impl BoundingBox for Artboard {
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> RenderBoundingBox {
self.0.bounding_box(transform, include_stroke)
}
fn thumbnail_bounding_box(&self, transform: DAffine2, include_stroke: bool) -> RenderBoundingBox {
self.0.thumbnail_bounding_box(transform, include_stroke)
}
}
impl RenderComplexity for Artboard {
fn render_complexity(&self) -> usize {
self.0.render_complexity()
}
}
// TODO: Eventually remove this migration document upgrade code // TODO: Eventually remove this migration document upgrade code
pub fn migrate_artboard<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<Table<Table<Graphic>>, D::Error> { pub fn migrate_artboard<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<Table<Artboard>, D::Error> {
use serde::Deserialize; use serde::Deserialize;
/// Mirrors the removed `AlphaBlending` struct for legacy document deserialization. /// Mirrors the removed `AlphaBlending` struct for legacy document deserialization.
@ -33,9 +79,7 @@ pub fn migrate_artboard<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Re
pub clip: bool, pub clip: bool,
} }
/// Pre-migration shape of the artboard's stored data: the struct that used to live as the element /// Legacy artboard struct shape, kept for deserializing old documents into `Table<Artboard>`.
/// of `Table<Artboard>`. Kept as a private type so we can deserialize legacy documents into the new
/// `Table<Table<Graphic>>` (element = `content`, other fields → row attributes).
#[derive(Clone, Debug, DynAny)] #[derive(Clone, Debug, DynAny)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LegacyArtboard { pub struct LegacyArtboard {
@ -68,14 +112,14 @@ pub fn migrate_artboard<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Re
ArtboardGroup(LegacyArtboardGroup), ArtboardGroup(LegacyArtboardGroup),
OldArtboardTable(OldTable<LegacyArtboard>), OldArtboardTable(OldTable<LegacyArtboard>),
LegacyArtboardTable(Table<LegacyArtboard>), LegacyArtboardTable(Table<LegacyArtboard>),
// Note: this variant must come last so older formats above are tried first; an empty // NOTE: Must come last so older tagged formats above are tried first.
// `Table<Table<Graphic>>` would otherwise match (since `Table<T>` has the same shell across `T`). // Also covers the intermediate `Table<Table<Graphic>>` shape since `Artboard` deserializes transparently.
ArtboardTable(Table<Table<Graphic>>), ArtboardTable(Table<Artboard>),
} }
fn legacy_to_row(legacy: LegacyArtboard) -> TableRow<Table<Graphic>> { fn legacy_to_row(legacy: LegacyArtboard) -> TableRow<Artboard> {
// Legacy `label` field is dropped — the artboard's name now comes from its parent layer's display name. // Legacy `label` field is dropped (the artboard's name comes from its parent layer's display name)
TableRow::new_from_element(legacy.content) TableRow::new_from_element(Artboard::new(legacy.content))
.with_attribute(ATTR_LOCATION, legacy.location.as_dvec2()) .with_attribute(ATTR_LOCATION, legacy.location.as_dvec2())
.with_attribute(ATTR_DIMENSIONS, legacy.dimensions.as_dvec2()) .with_attribute(ATTR_DIMENSIONS, legacy.dimensions.as_dvec2())
.with_attribute(ATTR_BACKGROUND, legacy.background) .with_attribute(ATTR_BACKGROUND, legacy.background)

View File

@ -7,6 +7,7 @@ pub use raster_types;
pub use vector_types; pub use vector_types;
// Re-export commonly used types at the crate root // Re-export commonly used types at the crate root
pub use artboard::Artboard;
pub use graphic::{Graphic, IntoGraphicTable, TryFromGraphic, Vector}; pub use graphic::{Graphic, IntoGraphicTable, TryFromGraphic, Vector};
pub mod migrations { pub mod migrations {

View File

@ -17,13 +17,12 @@ use core_types::{
use dyn_any::DynAny; use dyn_any::DynAny;
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphene_hash::CacheHashWrapper; use graphene_hash::CacheHashWrapper;
use graphic_types::Graphic;
use graphic_types::Vector;
use graphic_types::raster_types::{BitmapMut, CPU, GPU, Image, Raster}; use graphic_types::raster_types::{BitmapMut, CPU, GPU, Image, Raster};
use graphic_types::vector_types::gradient::{GradientStops, GradientType}; use graphic_types::vector_types::gradient::{GradientStops, GradientType};
use graphic_types::vector_types::subpath::Subpath; use graphic_types::vector_types::subpath::Subpath;
use graphic_types::vector_types::vector::click_target::{ClickTarget, FreePoint}; use graphic_types::vector_types::vector::click_target::{ClickTarget, FreePoint};
use graphic_types::vector_types::vector::style::{Fill, PaintOrder, RenderMode, Stroke, StrokeAlign}; use graphic_types::vector_types::vector::style::{Fill, PaintOrder, RenderMode, Stroke, StrokeAlign};
use graphic_types::{Artboard, Graphic, Vector};
use kurbo::{Affine, Cap, Join, Shape}; use kurbo::{Affine, Cap, Join, Shape};
use num_traits::Zero; use num_traits::Zero;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
@ -514,8 +513,8 @@ impl Render for Graphic {
} }
} }
/// Reads the artboard metadata for the row at `index` from a `Table<Table<Graphic>>` of artboards. /// Reads the artboard metadata for the row at `index` from a `Table<Artboard>`.
fn read_artboard_attributes(table: &Table<Table<Graphic>>, index: usize) -> (DVec2, DVec2, Color, bool) { fn read_artboard_attributes(table: &Table<Artboard>, index: usize) -> (DVec2, DVec2, Color, bool) {
let location: DVec2 = table.attribute_cloned_or_default(ATTR_LOCATION, index); let location: DVec2 = table.attribute_cloned_or_default(ATTR_LOCATION, index);
let dimensions: DVec2 = table.attribute_cloned_or_default(ATTR_DIMENSIONS, index); let dimensions: DVec2 = table.attribute_cloned_or_default(ATTR_DIMENSIONS, index);
let background: Color = table.attribute_cloned_or_default(ATTR_BACKGROUND, index); let background: Color = table.attribute_cloned_or_default(ATTR_BACKGROUND, index);
@ -523,10 +522,10 @@ fn read_artboard_attributes(table: &Table<Table<Graphic>>, index: usize) -> (DVe
(location, dimensions, background, clip) (location, dimensions, background, clip)
} }
impl Render for Table<Table<Graphic>> { impl Render for Table<Artboard> {
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) { fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
for index in 0..self.len() { for index in 0..self.len() {
let Some(content) = self.element(index) else { continue }; let Some(content) = self.element(index).map(Artboard::as_graphic_table) else { continue };
let (location, dimensions, background, clip) = read_artboard_attributes(self, index); let (location, dimensions, background, clip) = read_artboard_attributes(self, index);
let x = location.x.min(location.x + dimensions.x); let x = location.x.min(location.x + dimensions.x);
@ -584,7 +583,7 @@ impl Render for Table<Table<Graphic>> {
use vello::peniko; use vello::peniko;
for index in 0..self.len() { for index in 0..self.len() {
let Some(content) = self.element(index) else { continue }; let Some(content) = self.element(index).map(Artboard::as_graphic_table) else { continue };
let (location, dimensions, background, clip) = read_artboard_attributes(self, index); let (location, dimensions, background, clip) = read_artboard_attributes(self, index);
let [a, b] = [location, location + dimensions]; let [a, b] = [location, location + dimensions];
@ -614,7 +613,7 @@ impl Render for Table<Table<Graphic>> {
fn collect_metadata(&self, metadata: &mut RenderMetadata, footprint: Footprint, _element_id: Option<NodeId>) { fn collect_metadata(&self, metadata: &mut RenderMetadata, footprint: Footprint, _element_id: Option<NodeId>) {
for index in 0..self.len() { for index in 0..self.len() {
let Some(content) = self.element(index) else { continue }; let Some(content) = self.element(index).map(Artboard::as_graphic_table) else { continue };
let (location, dimensions, _background, clip) = read_artboard_attributes(self, index); let (location, dimensions, _background, clip) = read_artboard_attributes(self, index);
let layer_path: Table<NodeId> = self.attribute_cloned_or_default(ATTR_EDITOR_LAYER_PATH, index); let layer_path: Table<NodeId> = self.attribute_cloned_or_default(ATTR_EDITOR_LAYER_PATH, index);

View File

@ -3,7 +3,7 @@ use core_types::transform::Footprint;
use core_types::{CacheHash, CloneVarArgs, Color, Context, Ctx, ExtractAll, ExtractAnimationTime, ExtractPointerPosition, ExtractRealTime, OwnedContextImpl}; use core_types::{CacheHash, CloneVarArgs, Color, Context, Ctx, ExtractAll, ExtractAnimationTime, ExtractPointerPosition, ExtractRealTime, OwnedContextImpl};
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphic_types::vector_types::GradientStops; use graphic_types::vector_types::GradientStops;
use graphic_types::{Graphic, Vector}; use graphic_types::{Artboard, Graphic, Vector};
use raster_types::{CPU, GPU, Raster}; use raster_types::{CPU, GPU, Raster};
const DAY: f64 = 1000. * 3600. * 24.; const DAY: f64 = 1000. * 3600. * 24.;
@ -78,7 +78,7 @@ async fn quantize_real_time<T>(
Context -> Table<Raster<CPU>>, Context -> Table<Raster<CPU>>,
Context -> Table<Raster<GPU>>, Context -> Table<Raster<GPU>>,
Context -> Table<Color>, Context -> Table<Color>,
Context -> Table<Table<Graphic>>, Context -> Table<Artboard>,
Context -> Table<GradientStops>, Context -> Table<GradientStops>,
Context -> Table<String>, Context -> Table<String>,
Context -> Table<f64>, Context -> Table<f64>,
@ -118,7 +118,7 @@ async fn quantize_animation_time<T>(
Context -> Table<Raster<CPU>>, Context -> Table<Raster<CPU>>,
Context -> Table<Raster<GPU>>, Context -> Table<Raster<GPU>>,
Context -> Table<Color>, Context -> Table<Color>,
Context -> Table<Table<Graphic>>, Context -> Table<Artboard>,
Context -> Table<GradientStops>, Context -> Table<GradientStops>,
Context -> Table<String>, Context -> Table<String>,
Context -> Table<f64>, Context -> Table<f64>,

View File

@ -6,7 +6,7 @@ use core_types::uuid::NodeId;
use core_types::{Color, OwnedContextImpl}; use core_types::{Color, OwnedContextImpl};
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphic_types::vector_types::GradientStops; use graphic_types::vector_types::GradientStops;
use graphic_types::{Graphic, Vector}; use graphic_types::{Artboard, Graphic, Vector};
use raster_types::{CPU, GPU, Raster}; use raster_types::{CPU, GPU, Raster};
/// Filters out what should be unused components of the context based on the specified requirements. /// Filters out what should be unused components of the context based on the specified requirements.
@ -35,7 +35,7 @@ async fn context_modification<T>(
Context -> Table<Raster<CPU>>, Context -> Table<Raster<CPU>>,
Context -> Table<Raster<GPU>>, Context -> Table<Raster<GPU>>,
Context -> Table<Color>, Context -> Table<Color>,
Context -> Table<Table<Graphic>>, Context -> Table<Artboard>,
Context -> Table<GradientStops>, Context -> Table<GradientStops>,
)] )]
value: impl Node<Context<'static>, Output = T>, value: impl Node<Context<'static>, Output = T>,

View File

@ -1,19 +1,13 @@
use core_types::{ use core_types::table::{Table, TableRow};
ATTR_BACKGROUND, ATTR_CLIP, ATTR_DIMENSIONS, ATTR_LOCATION, CloneVarArgs, Color, Context, Ctx, ExtractAll, OwnedContextImpl, use core_types::transform::TransformMut;
table::{Table, TableRow}, use core_types::{ATTR_BACKGROUND, ATTR_CLIP, ATTR_DIMENSIONS, ATTR_LOCATION, CloneVarArgs, Color, Context, Ctx, ExtractAll, OwnedContextImpl};
transform::TransformMut,
};
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphic_types::{ use graphic_types::graphic::{Graphic, IntoGraphicTable};
Vector, use graphic_types::{Artboard, Vector};
graphic::{Graphic, IntoGraphicTable},
};
use raster_types::{CPU, GPU, Raster}; use raster_types::{CPU, GPU, Raster};
use vector_types::GradientStops; use vector_types::GradientStops;
/// Constructs a new single-item `Table<Table<Graphic>>` (an artboard table) where the row's element is /// Constructs a single-row `Table<Artboard>` with the given content and metadata stored as row attributes.
/// the artboard's content and the metadata (label, location, dimensions, background, clip) is stored as
/// per-row attributes.
#[node_macro::node(category(""))] #[node_macro::node(category(""))]
pub async fn create_artboard<T: IntoGraphicTable + 'n>( pub async fn create_artboard<T: IntoGraphicTable + 'n>(
ctx: impl ExtractAll + CloneVarArgs + Ctx, ctx: impl ExtractAll + CloneVarArgs + Ctx,
@ -37,7 +31,7 @@ pub async fn create_artboard<T: IntoGraphicTable + 'n>(
/// Whether to cut off the contained content that extends outside the artboard, or keep it visible. /// Whether to cut off the contained content that extends outside the artboard, or keep it visible.
#[default(true)] #[default(true)]
clip: bool, clip: bool,
) -> Table<Table<Graphic>> { ) -> Table<Artboard> {
let footprint = ctx.try_footprint().copied(); let footprint = ctx.try_footprint().copied();
let mut new_ctx = OwnedContextImpl::from(ctx); let mut new_ctx = OwnedContextImpl::from(ctx);
if let Some(mut footprint) = footprint { if let Some(mut footprint) = footprint {
@ -54,11 +48,9 @@ pub async fn create_artboard<T: IntoGraphicTable + 'n>(
let background = background.element(0).copied().unwrap_or(Color::WHITE); let background = background.element(0).copied().unwrap_or(Color::WHITE);
// The artboard's user-visible name is its parent layer's display name; not stored as an attribute here so // Name is not stored here, it's resolved live from the parent layer's display name
// it can't go stale. The data panel resolves it live from the row's `editor:layer_path` NodeId via the network
// interface, so renaming the layer reflects everywhere on the next refresh.
Table::new_from_row( Table::new_from_row(
TableRow::new_from_element(content) TableRow::new_from_element(Artboard::new(content))
.with_attribute(ATTR_LOCATION, normalized_location) .with_attribute(ATTR_LOCATION, normalized_location)
.with_attribute(ATTR_DIMENSIONS, normalized_dimensions) .with_attribute(ATTR_DIMENSIONS, normalized_dimensions)
.with_attribute(ATTR_BACKGROUND, background) .with_attribute(ATTR_BACKGROUND, background)

View File

@ -4,8 +4,8 @@ use core_types::table::{Table, TableRow};
use core_types::uuid::NodeId; use core_types::uuid::NodeId;
use core_types::{ATTR_EDITOR_LAYER_PATH, ATTR_TRANSFORM, AnyHash, CacheHash, CloneVarArgs, Color, Context, Ctx, ExtractAll, OwnedContextImpl}; use core_types::{ATTR_EDITOR_LAYER_PATH, ATTR_TRANSFORM, AnyHash, CacheHash, CloneVarArgs, Color, Context, Ctx, ExtractAll, OwnedContextImpl};
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphic_types::Vector;
use graphic_types::graphic::{Graphic, IntoGraphicTable}; use graphic_types::graphic::{Graphic, IntoGraphicTable};
use graphic_types::{Artboard, Vector};
use raster_types::{CPU, GPU, Raster}; use raster_types::{CPU, GPU, Raster};
use vector_types::{GradientStop, GradientStops, ReferencePoint}; use vector_types::{GradientStop, GradientStops, ReferencePoint};
@ -16,7 +16,7 @@ pub fn index_elements<T: graphic_types::graphic::AtIndex + Clone + Default>(
_: impl Ctx, _: impl Ctx,
/// The list of data. /// The list of data.
#[implementations( #[implementations(
Table<Table<Graphic>>, Table<Artboard>,
Table<Graphic>, Table<Graphic>,
Table<Vector>, Table<Vector>,
Table<Raster<CPU>>, Table<Raster<CPU>>,
@ -48,7 +48,7 @@ pub fn omit_element<T: graphic_types::graphic::OmitIndex + Clone + Default>(
/// The list of data. /// The list of data.
#[implementations( #[implementations(
Table<String>, Table<String>,
Table<Table<Graphic>>, Table<Artboard>,
Table<Graphic>, Table<Graphic>,
Table<Vector>, Table<Vector>,
Table<Raster<CPU>>, Table<Raster<CPU>>,
@ -86,7 +86,7 @@ pub fn extract_element<T: Clone + Default + Send + Sync + 'static>(
Table<Vector>, Table<Vector>,
Table<Raster<CPU>>, Table<Raster<CPU>>,
Table<Graphic>, Table<Graphic>,
Table<Table<Graphic>>, Table<Artboard>,
)] )]
table: Table<T>, table: Table<T>,
/// The index of the item to retrieve, starting from 0 for the first item. Negative indices count backwards from the end of the list, starting from -1 for the last item. /// The index of the item to retrieve, starting from 0 for the first item. Negative indices count backwards from the end of the list, starting from -1 for the last item.
@ -225,7 +225,7 @@ async fn write_attribute<T: AnyHash + Clone + Send + Sync + CacheHash, U: Clone
ctx: impl ExtractAll + CloneVarArgs + Ctx, ctx: impl ExtractAll + CloneVarArgs + Ctx,
/// The `Table` whose items will gain or have replaced the named attribute. /// The `Table` whose items will gain or have replaced the named attribute.
#[implementations( #[implementations(
Table<Table<Graphic>>, Table<Table<Graphic>>, Table<Table<Graphic>>, Table<Table<Graphic>>, Table<Table<Graphic>>, Table<Table<Graphic>>, Table<Table<Graphic>>, Table<Table<Graphic>>, Table<Table<Graphic>>, Table<Table<Graphic>>, Table<Artboard>, Table<Artboard>, Table<Artboard>, Table<Artboard>, Table<Artboard>, Table<Artboard>, Table<Artboard>, Table<Artboard>, Table<Artboard>, Table<Artboard>,
Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>, Table<Graphic>,
Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>, Table<Vector>,
Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>, Table<Raster<CPU>>,
@ -262,11 +262,11 @@ async fn write_attribute<T: AnyHash + Clone + Send + Sync + CacheHash, U: Clone
pub async fn extend<T: 'n + Send + Clone>( pub async fn extend<T: 'n + Send + Clone>(
_: impl Ctx, _: impl Ctx,
/// The `Table` whose items will appear at the start of the extended `Table`. /// The `Table` whose items will appear at the start of the extended `Table`.
#[implementations(Table<Table<Graphic>>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>, Table<GradientStops>)] #[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>, Table<GradientStops>)]
base: Table<T>, base: Table<T>,
/// The `Table` whose items will appear at the end of the extended `Table`. /// The `Table` whose items will appear at the end of the extended `Table`.
#[expose] #[expose]
#[implementations(Table<Table<Graphic>>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>, Table<GradientStops>)] #[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>, Table<GradientStops>)]
new: Table<T>, new: Table<T>,
) -> Table<T> { ) -> Table<T> {
let mut base = base; let mut base = base;
@ -281,9 +281,9 @@ pub async fn extend<T: 'n + Send + Clone>(
#[node_macro::node(category(""))] #[node_macro::node(category(""))]
pub async fn legacy_layer_extend<T: 'n + Send + Clone>( pub async fn legacy_layer_extend<T: 'n + Send + Clone>(
_: impl Ctx, _: impl Ctx,
#[implementations(Table<Table<Graphic>>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>, Table<GradientStops>)] base: Table<T>, #[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>, Table<GradientStops>)] base: Table<T>,
#[expose] #[expose]
#[implementations(Table<Table<Graphic>>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>, Table<GradientStops>)] #[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>, Table<GradientStops>)]
new: Table<T>, new: Table<T>,
nested_node_path: Table<NodeId>, nested_node_path: Table<NodeId>,
) -> Table<T> { ) -> Table<T> {

View File

@ -11,7 +11,7 @@ pub use graphene_application_io as application_io;
pub use graphene_core; pub use graphene_core;
pub use graphene_core::debug; pub use graphene_core::debug;
pub use graphic_nodes; pub use graphic_nodes;
pub use graphic_types::{Graphic, Vector}; pub use graphic_types::{Artboard, Graphic, Vector};
pub use math_nodes; pub use math_nodes;
pub use path_bool_nodes; pub use path_bool_nodes;
pub use raster_nodes; pub use raster_nodes;

View File

@ -8,7 +8,7 @@ use graph_craft::document::value::RenderOutput;
pub use graph_craft::document::value::RenderOutputType; pub use graph_craft::document::value::RenderOutputType;
use graphene_application_io::{ApplicationIo, ExportFormat, RenderConfig}; use graphene_application_io::{ApplicationIo, ExportFormat, RenderConfig};
use graphic_types::raster_types::{CPU, Raster}; use graphic_types::raster_types::{CPU, Raster};
use graphic_types::{Graphic, Vector}; use graphic_types::{Artboard, Graphic, Vector};
use rendering::{Render, RenderMetadata, RenderOutputType as RenderOutputTypeRequest, RenderParams, SvgRender, SvgRenderOutput}; use rendering::{Render, RenderMetadata, RenderOutputType as RenderOutputTypeRequest, RenderParams, SvgRender, SvgRenderOutput};
use std::fmt::Write; use std::fmt::Write;
use std::sync::Arc; use std::sync::Arc;
@ -33,7 +33,7 @@ pub struct RenderIntermediate {
async fn render_intermediate<'a: 'n, T: 'static + Render + WasmNotSend + Send + Sync>( async fn render_intermediate<'a: 'n, T: 'static + Render + WasmNotSend + Send + Sync>(
ctx: impl Ctx + ExtractVarArgs + ExtractAll + CloneVarArgs, ctx: impl Ctx + ExtractVarArgs + ExtractAll + CloneVarArgs,
#[implementations( #[implementations(
Context -> Table<Table<Graphic>>, Context -> Table<Artboard>,
Context -> Table<Graphic>, Context -> Table<Graphic>,
Context -> Table<Vector>, Context -> Table<Vector>,
Context -> Table<Raster<CPU>>, Context -> Table<Raster<CPU>>,

View File

@ -5,7 +5,7 @@ use core_types::transform::Footprint;
use core_types::{Color, Ctx, num_traits}; use core_types::{Color, Ctx, num_traits};
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphic_types::raster_types::{CPU, GPU, Raster}; use graphic_types::raster_types::{CPU, GPU, Raster};
use graphic_types::{Graphic, Vector}; use graphic_types::{Artboard, Graphic, Vector};
use log::warn; use log::warn;
use math_parser::ast; use math_parser::ast;
use math_parser::context::{EvalContext, NothingMap, ValueProvider}; use math_parser::context::{EvalContext, NothingMap, ValueProvider};
@ -753,7 +753,7 @@ async fn switch<T, C: Send + 'n + Clone>(
Context -> u64, Context -> u64,
Context -> DVec2, Context -> DVec2,
Context -> DAffine2, Context -> DAffine2,
Context -> Table<Table<Graphic>>, Context -> Table<Artboard>,
Context -> Table<Graphic>, Context -> Table<Graphic>,
Context -> Table<Vector>, Context -> Table<Vector>,
Context -> Table<Raster<CPU>>, Context -> Table<Raster<CPU>>,
@ -772,7 +772,7 @@ async fn switch<T, C: Send + 'n + Clone>(
Context -> u64, Context -> u64,
Context -> DVec2, Context -> DVec2,
Context -> DAffine2, Context -> DAffine2,
Context -> Table<Table<Graphic>>, Context -> Table<Artboard>,
Context -> Table<Graphic>, Context -> Table<Graphic>,
Context -> Table<Vector>, Context -> Table<Vector>,
Context -> Table<Raster<CPU>>, Context -> Table<Raster<CPU>>,