Rename the Table type's "rows" -> "items" and "columns" -> "attributes" everywhere (#4130)
* Rename TableRow -> Item * Rename row -> item and column -> attribute throughout * Fix a few missed ones * Format
This commit is contained in:
parent
cb21e5960b
commit
6b3e4757de
|
|
@ -220,7 +220,7 @@ fn label(x: impl Into<String>) -> Vec<LayoutGroup> {
|
|||
vec![LayoutGroup::row(error)]
|
||||
}
|
||||
|
||||
trait TableRowLayout {
|
||||
trait TableItemLayout {
|
||||
fn type_name() -> &'static str;
|
||||
fn identifier(&self) -> String;
|
||||
fn layout_with_breadcrumb(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
|
|
@ -245,7 +245,7 @@ trait TableRowLayout {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: TableRowLayout> TableRowLayout for Table<T> {
|
||||
impl<T: TableItemLayout> TableItemLayout for Table<T> {
|
||||
fn type_name() -> &'static str {
|
||||
"Table"
|
||||
}
|
||||
|
|
@ -307,7 +307,7 @@ impl<T: TableRowLayout> TableRowLayout for Table<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for Artboard {
|
||||
impl TableItemLayout for Artboard {
|
||||
fn type_name() -> &'static str {
|
||||
"Artboard"
|
||||
}
|
||||
|
|
@ -323,7 +323,7 @@ impl TableRowLayout for Artboard {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for Graphic {
|
||||
impl TableItemLayout for Graphic {
|
||||
fn type_name() -> &'static str {
|
||||
"Graphic"
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ impl TableRowLayout for Graphic {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for Vector {
|
||||
impl TableItemLayout for Vector {
|
||||
fn type_name() -> &'static str {
|
||||
"Vector"
|
||||
}
|
||||
|
|
@ -512,7 +512,7 @@ impl TableRowLayout for Vector {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for Raster<CPU> {
|
||||
impl TableItemLayout for Raster<CPU> {
|
||||
fn type_name() -> &'static str {
|
||||
"Raster"
|
||||
}
|
||||
|
|
@ -543,7 +543,7 @@ impl TableRowLayout for Raster<CPU> {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for Raster<GPU> {
|
||||
impl TableItemLayout for Raster<GPU> {
|
||||
fn type_name() -> &'static str {
|
||||
"Raster"
|
||||
}
|
||||
|
|
@ -556,7 +556,7 @@ impl TableRowLayout for Raster<GPU> {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for Color {
|
||||
impl TableItemLayout for Color {
|
||||
fn type_name() -> &'static str {
|
||||
"Color"
|
||||
}
|
||||
|
|
@ -576,7 +576,7 @@ impl TableRowLayout for Color {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for GradientStops {
|
||||
impl TableItemLayout for GradientStops {
|
||||
fn type_name() -> &'static str {
|
||||
"Gradient"
|
||||
}
|
||||
|
|
@ -596,7 +596,7 @@ impl TableRowLayout for GradientStops {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for f64 {
|
||||
impl TableItemLayout for f64 {
|
||||
fn type_name() -> &'static str {
|
||||
"Number (f64)"
|
||||
}
|
||||
|
|
@ -611,7 +611,7 @@ impl TableRowLayout for f64 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for u8 {
|
||||
impl TableItemLayout for u8 {
|
||||
fn type_name() -> &'static str {
|
||||
"Byte"
|
||||
}
|
||||
|
|
@ -624,7 +624,7 @@ impl TableRowLayout for u8 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for u32 {
|
||||
impl TableItemLayout for u32 {
|
||||
fn type_name() -> &'static str {
|
||||
"Number (u32)"
|
||||
}
|
||||
|
|
@ -639,7 +639,7 @@ impl TableRowLayout for u32 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for u64 {
|
||||
impl TableItemLayout for u64 {
|
||||
fn type_name() -> &'static str {
|
||||
"Number (u64)"
|
||||
}
|
||||
|
|
@ -655,7 +655,7 @@ impl TableRowLayout for u64 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for bool {
|
||||
impl TableItemLayout for bool {
|
||||
fn type_name() -> &'static str {
|
||||
"Bool"
|
||||
}
|
||||
|
|
@ -670,7 +670,7 @@ impl TableRowLayout for bool {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for String {
|
||||
impl TableItemLayout for String {
|
||||
fn type_name() -> &'static str {
|
||||
"String"
|
||||
}
|
||||
|
|
@ -689,7 +689,7 @@ impl TableRowLayout for String {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for Option<f64> {
|
||||
impl TableItemLayout for Option<f64> {
|
||||
fn type_name() -> &'static str {
|
||||
"Option<f64>"
|
||||
}
|
||||
|
|
@ -704,7 +704,7 @@ impl TableRowLayout for Option<f64> {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for DVec2 {
|
||||
impl TableItemLayout for DVec2 {
|
||||
fn type_name() -> &'static str {
|
||||
"Vec2"
|
||||
}
|
||||
|
|
@ -719,7 +719,7 @@ impl TableRowLayout for DVec2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for Vec2 {
|
||||
impl TableItemLayout for Vec2 {
|
||||
fn type_name() -> &'static str {
|
||||
"Vec2"
|
||||
}
|
||||
|
|
@ -734,7 +734,7 @@ impl TableRowLayout for Vec2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for DAffine2 {
|
||||
impl TableItemLayout for DAffine2 {
|
||||
fn type_name() -> &'static str {
|
||||
"Transform"
|
||||
}
|
||||
|
|
@ -749,7 +749,7 @@ impl TableRowLayout for DAffine2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for Affine2 {
|
||||
impl TableItemLayout for Affine2 {
|
||||
fn type_name() -> &'static str {
|
||||
"Transform"
|
||||
}
|
||||
|
|
@ -765,7 +765,7 @@ impl TableRowLayout for Affine2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for BlendMode {
|
||||
impl TableItemLayout for BlendMode {
|
||||
fn type_name() -> &'static str {
|
||||
"BlendMode"
|
||||
}
|
||||
|
|
@ -780,7 +780,7 @@ impl TableRowLayout for BlendMode {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for GradientType {
|
||||
impl TableItemLayout for GradientType {
|
||||
fn type_name() -> &'static str {
|
||||
"GradientType"
|
||||
}
|
||||
|
|
@ -795,7 +795,7 @@ impl TableRowLayout for GradientType {
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for GradientSpreadMethod {
|
||||
impl TableItemLayout for GradientSpreadMethod {
|
||||
fn type_name() -> &'static str {
|
||||
"GradientSpreadMethod"
|
||||
}
|
||||
|
|
@ -820,7 +820,7 @@ fn node_id_display_label(node_id: NodeId, network_interface: &NodeNetworkInterfa
|
|||
}
|
||||
}
|
||||
|
||||
impl TableRowLayout for NodeId {
|
||||
impl TableItemLayout for NodeId {
|
||||
fn type_name() -> &'static str {
|
||||
"NodeId"
|
||||
}
|
||||
|
|
@ -932,7 +932,7 @@ impl TableRowLayout for NodeId {
|
|||
}
|
||||
}
|
||||
|
||||
/// Invokes another macro with the full list of `TableRowLayout`-implementing types whose values may appear
|
||||
/// Invokes another macro with the full list of `TableItemLayout`-implementing types whose values may appear
|
||||
/// as attribute values. Both the value-rendering and drilldown-navigation dispatchers iterate this list,
|
||||
/// so adding a new attribute-displayable type is a single edit here.
|
||||
macro_rules! known_table_row_types {
|
||||
|
|
@ -984,9 +984,9 @@ fn display_value_override(any: &dyn Any) -> Option<String> {
|
|||
}
|
||||
|
||||
/// Type-dispatched widget for displaying an attribute value in a `Table<T>` item.
|
||||
/// Delegates to [`TableRowLayout::value_widget`] so the same widget code is shared between
|
||||
/// element-column rendering and attribute-column rendering. Returns `None` for unrecognized types so the
|
||||
/// caller can fall back to a debug-formatted [`TextLabel`].
|
||||
/// Delegates to [`TableItemLayout::value_widget`] so the same widget code is shared between
|
||||
/// element-column rendering and attribute-column rendering. Returns `None` for unrecognized
|
||||
/// types so the caller can fall back to a debug-formatted [`TextLabel`].
|
||||
fn dispatch_value_widget(any: &dyn Any, target: PathStep, data: &LayoutData) -> Option<WidgetInstance> {
|
||||
macro_rules! check {
|
||||
( $($ty:ty),* $(,)? ) => {
|
||||
|
|
@ -1041,7 +1041,7 @@ fn table_node_id_path_layout_with_breadcrumb(path: &Table<NodeId>, data: &mut La
|
|||
}
|
||||
|
||||
/// Type-dispatched recursion into an attribute value for the Data panel breadcrumb navigation.
|
||||
/// Mirrors [`dispatch_value_widget`] but routes to [`TableRowLayout::layout_with_breadcrumb`].
|
||||
/// Mirrors [`dispatch_value_widget`] but routes to [`TableItemLayout::layout_with_breadcrumb`].
|
||||
/// Returns `None` for unrecognized types.
|
||||
fn drilldown_attribute_layout(any: &dyn Any, data: &mut LayoutData) -> Option<Vec<LayoutGroup>> {
|
||||
// `Table<NodeId>` is interpreted as a path (e.g. the `editor:layer_path` attribute), so each item's NodeId value
|
||||
|
|
|
|||
|
|
@ -142,16 +142,16 @@ macro_rules! tagged_value {
|
|||
Self::from_type_or_none(&Type::Concrete(td)).to_dynany()
|
||||
}
|
||||
Self::F64Array(values) => {
|
||||
let table: Table<f64> = values.into_iter().map(core_types::table::TableRow::new_from_element).collect();
|
||||
let table: Table<f64> = values.into_iter().map(core_types::table::Item::new_from_element).collect();
|
||||
Box::new(table)
|
||||
}
|
||||
Self::Color(color) => {
|
||||
let table: Table<Color> = color.into_iter().map(core_types::table::TableRow::new_from_element).collect();
|
||||
let table: Table<Color> = color.into_iter().map(core_types::table::Item::new_from_element).collect();
|
||||
Box::new(table)
|
||||
}
|
||||
Self::Gradient(stops) => Box::new(Table::<GradientStops>::new_from_element(stops)),
|
||||
Self::BrushStrokes(strokes) => {
|
||||
let table: Table<BrushStroke> = strokes.into_iter().map(core_types::table::TableRow::new_from_element).collect();
|
||||
let table: Table<BrushStroke> = strokes.into_iter().map(core_types::table::Item::new_from_element).collect();
|
||||
Box::new(table)
|
||||
}
|
||||
// =======================
|
||||
|
|
@ -163,7 +163,7 @@ macro_rules! tagged_value {
|
|||
// =======================
|
||||
Self::RenderOutput(x) => Box::new(x),
|
||||
Self::NodeIdPath(path) => {
|
||||
let table: Table<NodeId> = path.into_iter().map(core_types::table::TableRow::new_from_element).collect();
|
||||
let table: Table<NodeId> = path.into_iter().map(core_types::table::Item::new_from_element).collect();
|
||||
Box::new(table)
|
||||
}
|
||||
Self::DocumentNode(node) => Box::new(node),
|
||||
|
|
@ -191,16 +191,16 @@ macro_rules! tagged_value {
|
|||
Self::from_type_or_none(&Type::Concrete(td)).to_any()
|
||||
}
|
||||
Self::F64Array(values) => {
|
||||
let table: Table<f64> = values.into_iter().map(core_types::table::TableRow::new_from_element).collect();
|
||||
let table: Table<f64> = values.into_iter().map(core_types::table::Item::new_from_element).collect();
|
||||
Arc::new(table)
|
||||
}
|
||||
Self::Color(color) => {
|
||||
let table: Table<Color> = color.into_iter().map(core_types::table::TableRow::new_from_element).collect();
|
||||
let table: Table<Color> = color.into_iter().map(core_types::table::Item::new_from_element).collect();
|
||||
Arc::new(table)
|
||||
}
|
||||
Self::Gradient(stops) => Arc::new(Table::<GradientStops>::new_from_element(stops)),
|
||||
Self::BrushStrokes(strokes) => {
|
||||
let table: Table<BrushStroke> = strokes.into_iter().map(core_types::table::TableRow::new_from_element).collect();
|
||||
let table: Table<BrushStroke> = strokes.into_iter().map(core_types::table::Item::new_from_element).collect();
|
||||
Arc::new(table)
|
||||
}
|
||||
// =======================
|
||||
|
|
@ -212,7 +212,7 @@ macro_rules! tagged_value {
|
|||
// =======================
|
||||
Self::RenderOutput(x) => Arc::new(x),
|
||||
Self::NodeIdPath(path) => {
|
||||
let table: Table<NodeId> = path.into_iter().map(core_types::table::TableRow::new_from_element).collect();
|
||||
let table: Table<NodeId> = path.into_iter().map(core_types::table::Item::new_from_element).collect();
|
||||
Arc::new(table)
|
||||
}
|
||||
Self::DocumentNode(node) => Arc::new(node),
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use graphene_std::raster::color::Color;
|
|||
use graphene_std::raster::*;
|
||||
use graphene_std::raster::{CPU, Raster};
|
||||
use graphene_std::render_node::RenderIntermediate;
|
||||
use graphene_std::table::{AttributeColumnDyn, AttributeValueDyn, Table, TableDyn};
|
||||
use graphene_std::table::{AttributeDyn, AttributeValueDyn, Table, TableDyn};
|
||||
use graphene_std::transform::Footprint;
|
||||
use graphene_std::uuid::NodeId;
|
||||
use graphene_std::vector::Vector;
|
||||
|
|
@ -42,19 +42,19 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||
#[cfg(feature = "gpu")]
|
||||
convert_node!(from: Table<Raster<GPU>>, to: Table<Graphic>),
|
||||
// Type-erased attribute column conversions for the `Attach Attribute` node, so it monomorphizes only over the destination table type.
|
||||
convert_node!(from: Table<Artboard>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<Graphic>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<Vector>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<Raster<CPU>>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<Color>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<GradientStops>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<f64>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<bool>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<String>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<DAffine2>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<BlendMode>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<graphene_std::vector::style::GradientType>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<graphene_std::vector::style::GradientSpreadMethod>, to: AttributeColumnDyn),
|
||||
convert_node!(from: Table<Artboard>, to: AttributeDyn),
|
||||
convert_node!(from: Table<Graphic>, to: AttributeDyn),
|
||||
convert_node!(from: Table<Vector>, to: AttributeDyn),
|
||||
convert_node!(from: Table<Raster<CPU>>, to: AttributeDyn),
|
||||
convert_node!(from: Table<Color>, to: AttributeDyn),
|
||||
convert_node!(from: Table<GradientStops>, to: AttributeDyn),
|
||||
convert_node!(from: Table<f64>, to: AttributeDyn),
|
||||
convert_node!(from: Table<bool>, to: AttributeDyn),
|
||||
convert_node!(from: Table<String>, to: AttributeDyn),
|
||||
convert_node!(from: Table<DAffine2>, to: AttributeDyn),
|
||||
convert_node!(from: Table<BlendMode>, to: AttributeDyn),
|
||||
convert_node!(from: Table<graphene_std::vector::style::GradientType>, to: AttributeDyn),
|
||||
convert_node!(from: Table<graphene_std::vector::style::GradientSpreadMethod>, to: AttributeDyn),
|
||||
convert_node!(from: Table<Artboard>, to: TableDyn),
|
||||
convert_node!(from: Table<Graphic>, to: TableDyn),
|
||||
convert_node!(from: Table<Vector>, to: TableDyn),
|
||||
|
|
@ -151,7 +151,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<BlendMode>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<graphene_std::vector::style::GradientType>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<graphene_std::vector::style::GradientSpreadMethod>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => AttributeColumnDyn]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => AttributeDyn]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => AttributeValueDyn]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => TableDyn]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Graphic]),
|
||||
|
|
@ -190,7 +190,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||
async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => &PlatformEditorApi, Context => graphene_std::ContextFeatures]),
|
||||
async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => RenderIntermediate, Context => graphene_std::ContextFeatures]),
|
||||
async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => RenderOutput, Context => graphene_std::ContextFeatures]),
|
||||
async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => AttributeColumnDyn, Context => graphene_std::ContextFeatures]),
|
||||
async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => AttributeDyn, Context => graphene_std::ContextFeatures]),
|
||||
async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => AttributeValueDyn, Context => graphene_std::ContextFeatures]),
|
||||
async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => TableDyn, Context => graphene_std::ContextFeatures]),
|
||||
#[cfg(target_family = "wasm")]
|
||||
|
|
@ -216,7 +216,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||
async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => Table<BlendMode>]),
|
||||
async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => Table<graphene_std::vector::style::GradientType>]),
|
||||
async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => Table<graphene_std::vector::style::GradientSpreadMethod>]),
|
||||
async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => AttributeColumnDyn]),
|
||||
async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => AttributeDyn]),
|
||||
async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => AttributeValueDyn]),
|
||||
async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => TableDyn]),
|
||||
#[cfg(target_family = "wasm")]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::Node;
|
||||
use crate::table::{AttributeColumnDyn, AttributeValueDyn, Column, Table, TableDyn, TableRow};
|
||||
use crate::table::{Attribute, AttributeDyn, AttributeValueDyn, Item, Table, TableDyn};
|
||||
use crate::transform::Footprint;
|
||||
use glam::DVec2;
|
||||
use graphene_hash::CacheHash;
|
||||
|
|
@ -65,7 +65,7 @@ impl<U, T: TableConvert<U> + Send> Convert<Table<U>, ()> for Table<T> {
|
|||
.into_iter()
|
||||
.map(|row| {
|
||||
let (element, attributes) = row.into_parts();
|
||||
TableRow::from_parts(element.convert_row(), attributes)
|
||||
Item::from_parts(element.convert_row(), attributes)
|
||||
})
|
||||
.collect();
|
||||
table
|
||||
|
|
@ -75,10 +75,10 @@ impl<U, T: TableConvert<U> + Send> Convert<Table<U>, ()> for Table<T> {
|
|||
/// Wraps each row's element into a type-erased column. Lets nodes that accept a source attribute
|
||||
/// from any `Table<U>` express their signature as `AttributeColumnDyn` and avoid monomorphizing
|
||||
/// over `U`; the compiler inserts this convert to bridge concrete-typed graph wires to the dyn input.
|
||||
impl<T: Clone + Send + Sync + Default + std::fmt::Debug + PartialEq + CacheHash + 'static> Convert<AttributeColumnDyn, ()> for Table<T> {
|
||||
async fn convert(self, _: Footprint, _: ()) -> AttributeColumnDyn {
|
||||
impl<T: Clone + Send + Sync + Default + std::fmt::Debug + PartialEq + CacheHash + 'static> Convert<AttributeDyn, ()> for Table<T> {
|
||||
async fn convert(self, _: Footprint, _: ()) -> AttributeDyn {
|
||||
let values: Vec<T> = self.into_iter().map(|row| row.into_element()).collect();
|
||||
AttributeColumnDyn(Box::new(Column(values)))
|
||||
AttributeDyn(Box::new(Attribute(values)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -436,7 +436,7 @@ impl<T: Clone> AtIndex for Table<T> {
|
|||
type Output = Table<T>;
|
||||
|
||||
fn at_index(&self, index: usize) -> Option<Self::Output> {
|
||||
self.clone_row(index).map(|row| {
|
||||
self.clone_item(index).map(|row| {
|
||||
let mut result_table = Self::default();
|
||||
result_table.push(row);
|
||||
result_table
|
||||
|
|
@ -469,7 +469,7 @@ impl<T: Clone> OmitIndex for Table<T> {
|
|||
let mut result = Self::default();
|
||||
for i in 0..self.len() {
|
||||
if i != index
|
||||
&& let Some(row) = self.clone_row(i)
|
||||
&& let Some(row) = self.clone_item(i)
|
||||
{
|
||||
result.push(row);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use core_types::bounds::RenderBoundingBox;
|
|||
use core_types::color::Color;
|
||||
use core_types::math::quad::Quad;
|
||||
use core_types::render_complexity::RenderComplexity;
|
||||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::transform::Footprint;
|
||||
use core_types::uuid::{NodeId, generate_uuid};
|
||||
use core_types::{
|
||||
|
|
@ -987,7 +987,7 @@ impl Render for Table<Vector> {
|
|||
|
||||
// The mask must draw at full alpha so the SVG `<mask>`/`<clipPath>` fully zeroes the path interior.
|
||||
// The wrapping SVG group (above) handles the user-set opacity.
|
||||
let vector_item = Table::new_from_row(TableRow::new_from_element(cloned_vector).with_attribute(ATTR_TRANSFORM, multiplied_transform));
|
||||
let vector_item = Table::new_from_item(Item::new_from_element(cloned_vector).with_attribute(ATTR_TRANSFORM, multiplied_transform));
|
||||
|
||||
(id, mask_type, vector_item)
|
||||
});
|
||||
|
|
@ -1312,7 +1312,7 @@ impl Render for Table<Vector> {
|
|||
|
||||
// The mask must draw at full alpha so `SrcOut` fully zeroes the path interior.
|
||||
// The outer opacity/blend layer (above) handles the user-set opacity.
|
||||
let vector_table = Table::new_from_row(TableRow::new_from_element(cloned_element).with_attribute(ATTR_TRANSFORM, item_transform));
|
||||
let vector_table = Table::new_from_item(Item::new_from_element(cloned_element).with_attribute(ATTR_TRANSFORM, item_transform));
|
||||
|
||||
let bounds = element.bounding_box_with_transform(multiplied_transform).unwrap_or(layer_bounds);
|
||||
// This branch is gated on `can_draw_aligned_stroke`, which already requires every subpath is closed
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::WgpuContext;
|
||||
use crate::shader_runtime::{FULLSCREEN_VERTEX_SHADER_NAME, ShaderRuntime};
|
||||
use core_types::shaders::buffer_struct::BufferStruct;
|
||||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use futures::lock::Mutex;
|
||||
use raster_types::{GPU, Raster};
|
||||
use std::borrow::Cow;
|
||||
|
|
@ -233,8 +233,8 @@ impl PerPixelAdjustGraphicsPipeline {
|
|||
rp.set_bind_group(0, Some(&bind_group), &[]);
|
||||
rp.draw(0..3, 0..1);
|
||||
|
||||
let attributes = textures.clone_row_attributes(index);
|
||||
TableRow::from_parts(Raster::new(GPU { texture: tex_out }), attributes)
|
||||
let attributes = textures.clone_item_attributes(index);
|
||||
Item::from_parts(Raster::new(GPU { texture: tex_out }), attributes)
|
||||
})
|
||||
.collect::<Table<_>>();
|
||||
context.queue.submit([cmd.finish()]);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use core_types::Color;
|
|||
use core_types::Ctx;
|
||||
use core_types::color::SRGBA8;
|
||||
use core_types::ops::Convert;
|
||||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::transform::Footprint;
|
||||
use raster_types::Image;
|
||||
use raster_types::{CPU, GPU, Raster};
|
||||
|
|
@ -155,7 +155,7 @@ impl<'i> Convert<Table<Raster<GPU>>, &'i WgpuExecutor> for Table<Raster<CPU>> {
|
|||
let (image, attributes) = row.into_parts();
|
||||
let texture = upload_to_texture(device, queue, &image);
|
||||
|
||||
TableRow::from_parts(Raster::new_gpu(texture), attributes)
|
||||
Item::from_parts(Raster::new_gpu(texture), attributes)
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ impl<'i> Convert<Table<Raster<CPU>>, &'i WgpuExecutor> for Table<Raster<GPU>> {
|
|||
for row in self {
|
||||
let (element, attributes) = row.into_parts();
|
||||
converters.push(RasterGpuToRasterCpuConverter::new(device, &mut encoder, element));
|
||||
rows_meta.push(TableRow::from_parts((), attributes));
|
||||
rows_meta.push(Item::from_parts((), attributes));
|
||||
}
|
||||
|
||||
queue.submit([encoder.finish()]);
|
||||
|
|
@ -219,7 +219,7 @@ impl<'i> Convert<Table<Raster<CPU>>, &'i WgpuExecutor> for Table<Raster<GPU>> {
|
|||
.zip(rows_meta)
|
||||
.map(|(element, row)| {
|
||||
let (_, attributes) = row.into_parts();
|
||||
TableRow::from_parts(element, attributes)
|
||||
Item::from_parts(element, attributes)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ fn blend_mode<T: SetBlendMode>(
|
|||
/// The choice of equation that controls how brightness and color blends between overlapping pixels.
|
||||
blend_mode: BlendMode,
|
||||
) -> T {
|
||||
// TODO: Find a way to make this apply once to the table's parent (i.e. its item in its parent table or TableRow<T>) rather than applying to each item in its own table, which produces the undesired result
|
||||
// TODO: Find a way to make this apply once to the table's parent (i.e. its item in its parent table or Item<T>) rather than applying to each item in its own table, which produces the undesired result
|
||||
content.set_blend_mode(blend_mode);
|
||||
content
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ fn opacity<T: MultiplyAlpha + MultiplyFill>(
|
|||
#[default(100.)]
|
||||
fill: Percentage,
|
||||
) -> T {
|
||||
// TODO: Find a way to make this apply once to the table's parent (i.e. its item in its parent table or TableRow<T>) rather than applying to each item in its own table, which produces the undesired result
|
||||
// TODO: Find a way to make this apply once to the table's parent (i.e. its item in its parent table or Item<T>) rather than applying to each item in its own table, which produces the undesired result
|
||||
if has_opacity {
|
||||
content.multiply_alpha(opacity / 100.);
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ fn clipping_mask<T: SetClip>(
|
|||
/// Whether the content inherits the alpha of the content beneath it.
|
||||
clip: bool,
|
||||
) -> T {
|
||||
// TODO: Find a way to make this apply once to the table's parent (i.e. its item in its parent table or TableRow<T>) rather than applying to each item in its own table, which produces the undesired result
|
||||
// TODO: Find a way to make this apply once to the table's parent (i.e. its item in its parent table or Item<T>) rather than applying to each item in its own table, which produces the undesired result
|
||||
content.set_clip(clip);
|
||||
content
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use core_types::color::{Alpha, Color, Pixel, Sample};
|
|||
use core_types::generic::FnNode;
|
||||
use core_types::math::bbox::{AxisAlignedBbox, Bbox};
|
||||
use core_types::registry::FutureWrapperNode;
|
||||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::transform::Transform;
|
||||
use core_types::uuid::NodeId;
|
||||
use core_types::value::ClonedNode;
|
||||
|
|
@ -143,7 +143,7 @@ pub async fn create_brush_texture(brush_style: &BrushStyle) -> Raster<CPU> {
|
|||
image.into_element()
|
||||
}
|
||||
|
||||
pub fn blend_with_mode(background: TableRow<Raster<CPU>>, foreground: TableRow<Raster<CPU>>, blend_mode: BlendMode, opacity: f64) -> TableRow<Raster<CPU>> {
|
||||
pub fn blend_with_mode(background: Item<Raster<CPU>>, foreground: Item<Raster<CPU>>, blend_mode: BlendMode, opacity: f64) -> Item<Raster<CPU>> {
|
||||
let opacity = opacity as f32 / 100.;
|
||||
match std::hint::black_box(blend_mode) {
|
||||
// Normal group
|
||||
|
|
@ -199,12 +199,12 @@ async fn brush(
|
|||
cache: BrushCache,
|
||||
) -> Table<Raster<CPU>> {
|
||||
if background.is_empty() {
|
||||
background.push(TableRow::default());
|
||||
background.push(Item::default());
|
||||
}
|
||||
// TODO: Find a way to handle more than one item
|
||||
let table_row = background.clone_row(0).expect("Expected the one item we just pushed");
|
||||
let table_row = background.clone_item(0).expect("Expected the one item we just pushed");
|
||||
|
||||
let bounds = Table::new_from_row(table_row.clone()).bounding_box(DAffine2::IDENTITY, false);
|
||||
let bounds = Table::new_from_item(table_row.clone()).bounding_box(DAffine2::IDENTITY, false);
|
||||
let [start, end] = if let RenderBoundingBox::Rectangle(rect) = bounds { rect } else { [DVec2::ZERO, DVec2::ZERO] };
|
||||
let background_bbox = AxisAlignedBbox { start, end };
|
||||
let stroke_bbox = trace.iter_element_values().map(|s| s.bounding_box()).reduce(|a, b| a.union(&b)).unwrap_or(AxisAlignedBbox::ZERO);
|
||||
|
|
@ -224,7 +224,7 @@ async fn brush(
|
|||
let mut brush_plan = cache.compute_brush_plan(table_row, &draw_strokes);
|
||||
|
||||
// TODO: Find a way to handle more than one item
|
||||
let Some(mut actual_image) = extend_image_to_bounds((), Table::new_from_row(brush_plan.background), background_bounds).into_iter().next() else {
|
||||
let Some(mut actual_image) = extend_image_to_bounds((), Table::new_from_item(brush_plan.background), background_bounds).into_iter().next() else {
|
||||
return Table::new();
|
||||
};
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ async fn brush(
|
|||
);
|
||||
let blit_target = if idx == 0 {
|
||||
let target = core::mem::take(&mut brush_plan.first_stroke_texture);
|
||||
extend_image_to_bounds((), Table::new_from_row(target), stroke_to_layer)
|
||||
extend_image_to_bounds((), Table::new_from_item(target), stroke_to_layer)
|
||||
} else {
|
||||
empty_image((), stroke_to_layer, Table::new_from_element(Color::TRANSPARENT))
|
||||
// EmptyImageNode::new(CopiedNode::new(stroke_to_layer), CopiedNode::new(Color::TRANSPARENT)).eval(())
|
||||
|
|
@ -286,7 +286,7 @@ async fn brush(
|
|||
let has_erase_or_restore_strokes = trace.iter_element_values().any(|s| matches!(s.style.blend_mode, BlendMode::Erase | BlendMode::Restore));
|
||||
if has_erase_or_restore_strokes {
|
||||
let opaque_image = Image::new(bbox.size().x as u32, bbox.size().y as u32, Color::WHITE);
|
||||
let mut erase_restore_mask = TableRow::new_from_element(Raster::new_cpu(opaque_image)).with_attribute(ATTR_TRANSFORM, background_bounds);
|
||||
let mut erase_restore_mask = Item::new_from_element(Raster::new_cpu(opaque_image)).with_attribute(ATTR_TRANSFORM, background_bounds);
|
||||
|
||||
for stroke in trace.into_iter().map(|row| row.into_element()) {
|
||||
let mut brush_texture = cache.get_cached_brush(&stroke.style);
|
||||
|
|
@ -311,7 +311,7 @@ async fn brush(
|
|||
FutureWrapperNode::new(ClonedNode::new(positions)),
|
||||
FutureWrapperNode::new(ClonedNode::new(blend_params)),
|
||||
);
|
||||
erase_restore_mask = blit_node.eval(Table::new_from_row(erase_restore_mask)).await.into_iter().next().unwrap_or_default();
|
||||
erase_restore_mask = blit_node.eval(Table::new_from_item(erase_restore_mask)).await.into_iter().next().unwrap_or_default();
|
||||
}
|
||||
|
||||
let blend_params = FnNode::new(|(a, b)| blend_colors(a, b, BlendMode::MultiplyAlpha, 1.));
|
||||
|
|
@ -336,7 +336,7 @@ async fn brush(
|
|||
background
|
||||
}
|
||||
|
||||
pub fn blend_image_closure(foreground: TableRow<Raster<CPU>>, mut background: TableRow<Raster<CPU>>, map_fn: impl Fn(Color, Color) -> Color) -> TableRow<Raster<CPU>> {
|
||||
pub fn blend_image_closure(foreground: Item<Raster<CPU>>, mut background: Item<Raster<CPU>>, map_fn: impl Fn(Color, Color) -> Color) -> Item<Raster<CPU>> {
|
||||
let foreground_size = DVec2::new(foreground.element().width as f64, foreground.element().height as f64);
|
||||
let background_size = DVec2::new(background.element().width as f64, background.element().height as f64);
|
||||
|
||||
|
|
@ -369,7 +369,7 @@ pub fn blend_image_closure(foreground: TableRow<Raster<CPU>>, mut background: Ta
|
|||
background
|
||||
}
|
||||
|
||||
pub fn blend_stamp_closure(foreground: BrushStampGenerator<Color>, mut background: TableRow<Raster<CPU>>, map_fn: impl Fn(Color, Color) -> Color) -> TableRow<Raster<CPU>> {
|
||||
pub fn blend_stamp_closure(foreground: BrushStampGenerator<Color>, mut background: Item<Raster<CPU>>, map_fn: impl Fn(Color, Color) -> Color) -> Item<Raster<CPU>> {
|
||||
let background_size = DVec2::new(background.element().width as f64, background.element().height as f64);
|
||||
|
||||
// Transforms a point from the background image to the foreground image
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::brush_stroke::BrushStroke;
|
|||
use crate::brush_stroke::BrushStyle;
|
||||
use core_types::ATTR_TRANSFORM;
|
||||
use core_types::graphene_hash::CacheHashWrapper;
|
||||
use core_types::table::TableRow;
|
||||
use core_types::table::Item;
|
||||
use raster_types::CPU;
|
||||
use raster_types::Raster;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -14,16 +14,16 @@ struct BrushCacheImpl {
|
|||
prev_input: Vec<BrushStroke>,
|
||||
|
||||
// The strokes that have been fully processed and blended into the background.
|
||||
background: TableRow<Raster<CPU>>,
|
||||
blended_image: TableRow<Raster<CPU>>,
|
||||
last_stroke_texture: TableRow<Raster<CPU>>,
|
||||
background: Item<Raster<CPU>>,
|
||||
blended_image: Item<Raster<CPU>>,
|
||||
last_stroke_texture: Item<Raster<CPU>>,
|
||||
|
||||
// A cache for brush textures.
|
||||
brush_texture_cache: HashMap<CacheHashWrapper<BrushStyle>, Raster<CPU>>,
|
||||
}
|
||||
|
||||
impl BrushCacheImpl {
|
||||
fn compute_brush_plan(&mut self, mut background: TableRow<Raster<CPU>>, input: &[BrushStroke]) -> BrushPlan {
|
||||
fn compute_brush_plan(&mut self, mut background: Item<Raster<CPU>>, input: &[BrushStroke]) -> BrushPlan {
|
||||
// Do background invalidation.
|
||||
if background != self.background {
|
||||
self.background = background.clone();
|
||||
|
|
@ -51,7 +51,7 @@ impl BrushCacheImpl {
|
|||
|
||||
// Check if the first non-blended stroke is an extension of the last one.
|
||||
// Transform is set to ZERO (not the default IDENTITY) as a sentinel to mark this item as uninitialized.
|
||||
let mut first_stroke_texture = TableRow::new_from_element(Raster::<CPU>::default()).with_attribute(ATTR_TRANSFORM, glam::DAffine2::ZERO);
|
||||
let mut first_stroke_texture = Item::new_from_element(Raster::<CPU>::default()).with_attribute(ATTR_TRANSFORM, glam::DAffine2::ZERO);
|
||||
let mut first_stroke_point_skip = 0;
|
||||
let strokes = input[num_blended_strokes..].to_vec();
|
||||
if !strokes.is_empty() && self.prev_input.len() > num_blended_strokes {
|
||||
|
|
@ -75,7 +75,7 @@ impl BrushCacheImpl {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn cache_results(&mut self, input: Vec<BrushStroke>, blended_image: TableRow<Raster<CPU>>, last_stroke_texture: TableRow<Raster<CPU>>) {
|
||||
pub fn cache_results(&mut self, input: Vec<BrushStroke>, blended_image: Item<Raster<CPU>>, last_stroke_texture: Item<Raster<CPU>>) {
|
||||
self.prev_input = input;
|
||||
self.blended_image = blended_image;
|
||||
self.last_stroke_texture = last_stroke_texture;
|
||||
|
|
@ -85,8 +85,8 @@ impl BrushCacheImpl {
|
|||
#[derive(Clone, Debug, Default)]
|
||||
pub struct BrushPlan {
|
||||
pub strokes: Vec<BrushStroke>,
|
||||
pub background: TableRow<Raster<CPU>>,
|
||||
pub first_stroke_texture: TableRow<Raster<CPU>>,
|
||||
pub background: Item<Raster<CPU>>,
|
||||
pub first_stroke_texture: Item<Raster<CPU>>,
|
||||
pub first_stroke_point_skip: usize,
|
||||
}
|
||||
|
||||
|
|
@ -94,12 +94,12 @@ pub struct BrushPlan {
|
|||
pub struct BrushCache(Arc<Mutex<BrushCacheImpl>>);
|
||||
|
||||
impl BrushCache {
|
||||
pub fn compute_brush_plan(&self, background: TableRow<Raster<CPU>>, input: &[BrushStroke]) -> BrushPlan {
|
||||
pub fn compute_brush_plan(&self, background: Item<Raster<CPU>>, input: &[BrushStroke]) -> BrushPlan {
|
||||
let mut inner = self.0.lock().unwrap();
|
||||
inner.compute_brush_plan(background, input)
|
||||
}
|
||||
|
||||
pub fn cache_results(&self, input: Vec<BrushStroke>, blended_image: TableRow<Raster<CPU>>, last_stroke_texture: TableRow<Raster<CPU>>) {
|
||||
pub fn cache_results(&self, input: Vec<BrushStroke>, blended_image: Item<Raster<CPU>>, last_stroke_texture: Item<Raster<CPU>>) {
|
||||
let mut inner = self.0.lock().unwrap();
|
||||
inner.cache_results(input, blended_image, last_stroke_texture)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use core::f64;
|
||||
use core_types::context::{CloneVarArgs, Context, ContextFeatures, Ctx, ExtractAll};
|
||||
use core_types::table::{AttributeColumnDyn, AttributeValueDyn, Table, TableDyn};
|
||||
use core_types::table::{AttributeDyn, AttributeValueDyn, Table, TableDyn};
|
||||
use core_types::transform::Footprint;
|
||||
use core_types::uuid::NodeId;
|
||||
use core_types::{Color, OwnedContextImpl};
|
||||
|
|
@ -37,7 +37,7 @@ async fn context_modification<T>(
|
|||
Context -> Table<Color>,
|
||||
Context -> Table<Artboard>,
|
||||
Context -> Table<GradientStops>,
|
||||
Context -> AttributeColumnDyn,
|
||||
Context -> AttributeDyn,
|
||||
Context -> AttributeValueDyn,
|
||||
Context -> TableDyn,
|
||||
)]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::transform::TransformMut;
|
||||
use core_types::{ATTR_BACKGROUND, ATTR_CLIP, ATTR_DIMENSIONS, ATTR_LOCATION, CloneVarArgs, Color, Context, Ctx, ExtractAll, OwnedContextImpl};
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
|
@ -49,8 +49,8 @@ pub async fn create_artboard<T: IntoGraphicTable + 'n>(
|
|||
let background = background.element(0).copied().unwrap_or(Color::WHITE);
|
||||
|
||||
// Name is not stored here, it's resolved live from the parent layer's display name
|
||||
Table::new_from_row(
|
||||
TableRow::new_from_element(Artboard::new(content))
|
||||
Table::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)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use core_types::bounds::{BoundingBox, RenderBoundingBox};
|
||||
use core_types::registry::types::{Angle, SignedInteger};
|
||||
use core_types::table::{AttributeColumnDyn, AttributeValueDyn, Table, TableDyn, TableRow};
|
||||
use core_types::table::{AttributeDyn, AttributeValueDyn, Item, Table, TableDyn};
|
||||
use core_types::uuid::NodeId;
|
||||
use core_types::{ATTR_EDITOR_LAYER_PATH, ATTR_EDITOR_MERGED_LAYERS, ATTR_TRANSFORM, AnyHash, BlendMode, CacheHash, CloneVarArgs, Color, Context, Ctx, ExtractAll, OwnedContextImpl};
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
|
@ -131,7 +131,7 @@ async fn map<Item: AnyHash + Send + Sync + CacheHash>(
|
|||
|
||||
for (i, row) in content.into_iter().enumerate() {
|
||||
let owned_ctx = OwnedContextImpl::from(ctx.clone());
|
||||
let owned_ctx = owned_ctx.with_vararg(Box::new(Table::new_from_row(row))).with_index(i);
|
||||
let owned_ctx = owned_ctx.with_vararg(Box::new(Table::new_from_item(row))).with_index(i);
|
||||
let table = mapped.eval(owned_ctx.into_context()).await;
|
||||
|
||||
rows.extend(table);
|
||||
|
|
@ -250,16 +250,16 @@ async fn write_attribute<T: AnyHash + Clone + Send + Sync + CacheHash>(
|
|||
value: impl Node<'n, Context<'static>, Output = AttributeValueDyn>,
|
||||
) -> Table<T> {
|
||||
for index in 0..content.len() {
|
||||
let row = content.clone_row(index).expect("index is within bounds");
|
||||
let owned_ctx = OwnedContextImpl::from(ctx.clone()).with_vararg(Box::new(Table::new_from_row(row))).with_index(index);
|
||||
let row = content.clone_item(index).expect("index is within bounds");
|
||||
let owned_ctx = OwnedContextImpl::from(ctx.clone()).with_vararg(Box::new(Table::new_from_item(row))).with_index(index);
|
||||
let v = value.eval(owned_ctx.into_context()).await;
|
||||
content.set_attribute_dyn(&name, index, v);
|
||||
content.set_attribute_value_dyn(&name, index, v);
|
||||
}
|
||||
content
|
||||
}
|
||||
|
||||
/// Sets a named attribute on the primary table, with each value taken from the corresponding item's element in the source table (paired by index, wrapping if the source has fewer items).
|
||||
/// The source is type-erased into an `AttributeColumnDyn` by an auto-inserted convert node, so this node only monomorphizes over `T` instead of the cartesian product `(T, U)`.
|
||||
/// The source is type-erased into an `AttributeDyn` by an auto-inserted convert node, so this node only monomorphizes over `T` instead of the cartesian product `(T, U)`.
|
||||
#[node_macro::node(category("Attributes: Write"))]
|
||||
fn attach_attribute<T: AnyHash + Clone + Send + Sync + CacheHash>(
|
||||
_: impl Ctx,
|
||||
|
|
@ -282,14 +282,14 @@ fn attach_attribute<T: AnyHash + Clone + Send + Sync + CacheHash>(
|
|||
mut content: Table<T>,
|
||||
/// The source values to attach. Any `Table<U>` wired here is type-erased via an auto-inserted convert.
|
||||
#[expose]
|
||||
source: AttributeColumnDyn,
|
||||
source: AttributeDyn,
|
||||
/// The name to assign to the new destination attribute.
|
||||
name: String,
|
||||
) -> Table<T> {
|
||||
if source.is_empty() {
|
||||
return content;
|
||||
}
|
||||
content.set_column_dyn(name, source);
|
||||
content.set_attribute_dyn(name, source);
|
||||
content
|
||||
}
|
||||
|
||||
|
|
@ -304,7 +304,7 @@ fn read_attribute_vector(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<Vector>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(value.clone()));
|
||||
result.push(Item::new_from_element(value.clone()));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -325,7 +325,7 @@ fn read_attribute_number(
|
|||
.or_else(|| content.attribute::<u64>(&name, index).map(|v| *v as f64))
|
||||
.or_else(|| content.attribute::<u32>(&name, index).map(|v| *v as f64));
|
||||
let Some(value) = value else { continue };
|
||||
result.push(TableRow::new_from_element(value));
|
||||
result.push(Item::new_from_element(value));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -341,7 +341,7 @@ fn read_attribute_bool(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<bool>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(*value));
|
||||
result.push(Item::new_from_element(*value));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ fn read_attribute_string(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<String>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(value.clone()));
|
||||
result.push(Item::new_from_element(value.clone()));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ fn read_attribute_transform(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<DAffine2>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(*value));
|
||||
result.push(Item::new_from_element(*value));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -389,7 +389,7 @@ fn read_attribute_color(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<Color>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(*value));
|
||||
result.push(Item::new_from_element(*value));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -405,7 +405,7 @@ fn read_attribute_blend_mode(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<BlendMode>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(*value));
|
||||
result.push(Item::new_from_element(*value));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -421,7 +421,7 @@ fn read_attribute_gradient_type(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<GradientType>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(*value));
|
||||
result.push(Item::new_from_element(*value));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -437,7 +437,7 @@ fn read_attribute_spread_method(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<GradientSpreadMethod>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(*value));
|
||||
result.push(Item::new_from_element(*value));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -453,7 +453,7 @@ fn read_attribute_gradient_stops(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<GradientStops>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(value.clone()));
|
||||
result.push(Item::new_from_element(value.clone()));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -469,7 +469,7 @@ fn read_attribute_artboard(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<Artboard>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(value.clone()));
|
||||
result.push(Item::new_from_element(value.clone()));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -485,7 +485,7 @@ fn read_attribute_raster(
|
|||
let mut result = Table::with_capacity(content.len());
|
||||
for index in 0..content.len() {
|
||||
let Some(value) = content.attribute::<Raster<CPU>>(&name, index) else { continue };
|
||||
result.push(TableRow::new_from_element(value.clone()));
|
||||
result.push(Item::new_from_element(value.clone()));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
@ -597,8 +597,8 @@ pub async fn flatten_graphic(_: impl Ctx, content: Table<Graphic>, fully_flatten
|
|||
}
|
||||
// Push any leaf elements we encounter: either `Graphic::Graphic(...)` values beyond the recursion depth, or non-`Graphic::Graphic` variants (e.g. `Graphic::Vector`, `Graphic::Raster*`, `Graphic::Color`, `Graphic::Gradient`)
|
||||
_ => {
|
||||
let attributes = current_graphic_table.clone_row_attributes(index);
|
||||
output_graphic_table.push(TableRow::from_parts(current_element, attributes));
|
||||
let attributes = current_graphic_table.clone_item_attributes(index);
|
||||
output_graphic_table.push(Item::from_parts(current_element, attributes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use base64::Engine;
|
|||
use canvas_utils::{Canvas, CanvasHandle};
|
||||
#[cfg(target_family = "wasm")]
|
||||
use core_types::math::bbox::Bbox;
|
||||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
#[cfg(target_family = "wasm")]
|
||||
use core_types::transform::Footprint;
|
||||
#[cfg(target_family = "wasm")]
|
||||
|
|
@ -116,14 +116,14 @@ async fn post_request(
|
|||
/// Converts a text string to raw binary data. Useful for transmission over HTTP or writing to files.
|
||||
#[node_macro::node(category("Web Request"), name("String to Bytes"))]
|
||||
fn string_to_bytes(_: impl Ctx, string: String) -> Table<u8> {
|
||||
string.into_bytes().into_iter().map(TableRow::new_from_element).collect()
|
||||
string.into_bytes().into_iter().map(Item::new_from_element).collect()
|
||||
}
|
||||
|
||||
/// Converts extracted raw RGBA pixel data from an input image. Each pixel becomes 4 sequential bytes. Useful for transmission over HTTP or writing to files.
|
||||
#[node_macro::node(category("Web Request"), name("Image to Bytes"))]
|
||||
fn image_to_bytes(_: impl Ctx, image: Table<Raster<CPU>>) -> Table<u8> {
|
||||
let Some(image) = image.element(0) else { return Table::new() };
|
||||
image.data.iter().flat_map(|color| color.to_rgba8_srgb()).map(TableRow::new_from_element).collect()
|
||||
image.data.iter().flat_map(|color| color.to_rgba8_srgb()).map(Item::new_from_element).collect()
|
||||
}
|
||||
|
||||
/// Loads binary from URLs and local asset paths. Returns a transparent placeholder if the resource fails to load, allowing rendering to continue.
|
||||
|
|
@ -235,8 +235,8 @@ where
|
|||
let rasterized = context.get_image_data(0., 0., resolution.x as f64, resolution.y as f64).unwrap();
|
||||
|
||||
let image = Image::from_image_data(&rasterized.data().0, resolution.x as u32, resolution.y as u32);
|
||||
Table::new_from_row(
|
||||
TableRow::new_from_element(Raster::new_cpu(image))
|
||||
Table::new_from_item(
|
||||
Item::new_from_element(Raster::new_cpu(image))
|
||||
.with_attribute(ATTR_TRANSFORM, footprint.transform)
|
||||
.with_attribute(ATTR_EDITOR_MERGED_LAYERS, upstream_graphic_table),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::uuid::NodeId;
|
||||
use core_types::{ATTR_BLEND_MODE, ATTR_CLIPPING_MASK, ATTR_EDITOR_LAYER_PATH, ATTR_EDITOR_MERGED_LAYERS, ATTR_OPACITY, ATTR_OPACITY_FILL, ATTR_TRANSFORM, BlendMode, Color, Ctx};
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
|
@ -124,7 +124,7 @@ fn boolean_operation_on_vector_table(vector: &Table<Vector>, boolean_operation:
|
|||
if !vector.is_empty() { Some(vector.len() - 1) } else { None }
|
||||
};
|
||||
let mut row = if let Some(index) = copy_from_index {
|
||||
let mut attributes = vector.clone_row_attributes(index);
|
||||
let mut attributes = vector.clone_item_attributes(index);
|
||||
// The boolean op bakes input transforms into the output geometry, so the result item carries no transform of its own
|
||||
attributes.insert(ATTR_TRANSFORM, DAffine2::IDENTITY);
|
||||
let copy_from = vector.element(index).unwrap();
|
||||
|
|
@ -132,9 +132,9 @@ fn boolean_operation_on_vector_table(vector: &Table<Vector>, boolean_operation:
|
|||
style: copy_from.style.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
TableRow::from_parts(element, attributes)
|
||||
Item::from_parts(element, attributes)
|
||||
} else {
|
||||
TableRow::<Vector>::default()
|
||||
Item::<Vector>::default()
|
||||
};
|
||||
|
||||
for index in 0..vector.len() {
|
||||
|
|
@ -188,7 +188,7 @@ fn flatten_vector(graphic_table: &Table<Graphic>) -> Table<Vector> {
|
|||
let mut element = Vector::from_subpath(subpath);
|
||||
element.style.set_fill(Fill::Solid(Color::BLACK));
|
||||
|
||||
TableRow::new_from_element(element)
|
||||
Item::new_from_element(element)
|
||||
.with_attribute(ATTR_BLEND_MODE, blend_mode)
|
||||
.with_attribute(ATTR_OPACITY, opacity)
|
||||
.with_attribute(ATTR_OPACITY_FILL, fill)
|
||||
|
|
@ -220,7 +220,7 @@ fn flatten_vector(graphic_table: &Table<Graphic>) -> Table<Vector> {
|
|||
let mut element = Vector::from_subpath(subpath);
|
||||
element.style.set_fill(Fill::Solid(Color::BLACK));
|
||||
|
||||
TableRow::new_from_element(element)
|
||||
Item::new_from_element(element)
|
||||
.with_attribute(ATTR_BLEND_MODE, blend_mode)
|
||||
.with_attribute(ATTR_OPACITY, opacity)
|
||||
.with_attribute(ATTR_OPACITY_FILL, fill)
|
||||
|
|
@ -264,7 +264,7 @@ fn flatten_vector(graphic_table: &Table<Graphic>) -> Table<Vector> {
|
|||
element.style.set_fill(Fill::Solid(color));
|
||||
element.style.set_stroke_transform(DAffine2::IDENTITY);
|
||||
|
||||
TableRow::from_parts(element, attributes)
|
||||
Item::from_parts(element, attributes)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
Graphic::Gradient(gradient) => gradient
|
||||
|
|
@ -275,7 +275,7 @@ fn flatten_vector(graphic_table: &Table<Graphic>) -> Table<Vector> {
|
|||
element.style.set_fill(Fill::Gradient(graphic_types::vector_types::gradient::Gradient { stops, ..Default::default() }));
|
||||
element.style.set_stroke_transform(DAffine2::IDENTITY);
|
||||
|
||||
TableRow::from_parts(element, attributes)
|
||||
Item::from_parts(element, attributes)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use core_types::color::Color;
|
||||
use core_types::context::Ctx;
|
||||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use raster_types::{CPU, Raster};
|
||||
|
||||
#[node_macro::node(category("Color"))]
|
||||
|
|
@ -56,7 +56,7 @@ async fn image_color_palette(
|
|||
b /= list.len() as f32;
|
||||
a /= list.len() as f32;
|
||||
|
||||
Color::from_rgbaf32(r, g, b, a).map(TableRow::new_from_element).into_iter()
|
||||
Color::from_rgbaf32(r, g, b, a).map(Item::new_from_element).into_iter()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use core_types::color::Color;
|
|||
use core_types::color::{Alpha, AlphaMut, Channel, LinearChannel, Luminance, RGBMut};
|
||||
use core_types::context::{Ctx, ExtractFootprint};
|
||||
use core_types::math::bbox::Bbox;
|
||||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::transform::Transform;
|
||||
use dyn_any::DynAny;
|
||||
use fastnoise_lite;
|
||||
|
|
@ -88,7 +88,7 @@ pub fn sample_image(ctx: impl ExtractFootprint + Clone + Send, image_frame: Tabl
|
|||
let new_transform = image_frame_transform * DAffine2::from_translation(offset) * DAffine2::from_scale(size);
|
||||
attributes.insert(ATTR_TRANSFORM, new_transform);
|
||||
|
||||
Some(TableRow::from_parts(Raster::new_cpu(image), attributes))
|
||||
Some(Item::from_parts(Raster::new_cpu(image), attributes))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ pub fn combine_channels(
|
|||
}
|
||||
}
|
||||
|
||||
Some(TableRow::from_parts(Raster::new_cpu(image), attributes))
|
||||
Some(Item::from_parts(Raster::new_cpu(image), attributes))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -392,7 +392,7 @@ pub fn noise_pattern(
|
|||
}
|
||||
}
|
||||
|
||||
return Table::new_from_row(TableRow::new_from_element(Raster::new_cpu(image)).with_attribute(ATTR_TRANSFORM, transform));
|
||||
return Table::new_from_item(Item::new_from_element(Raster::new_cpu(image)).with_attribute(ATTR_TRANSFORM, transform));
|
||||
}
|
||||
};
|
||||
noise.set_noise_type(Some(noise_type));
|
||||
|
|
@ -450,7 +450,7 @@ pub fn noise_pattern(
|
|||
}
|
||||
}
|
||||
|
||||
Table::new_from_row(TableRow::new_from_element(Raster::new_cpu(image)).with_attribute(ATTR_TRANSFORM, transform))
|
||||
Table::new_from_item(Item::new_from_element(Raster::new_cpu(image)).with_attribute(ATTR_TRANSFORM, transform))
|
||||
}
|
||||
|
||||
#[node_macro::node(category("Raster: Pattern"))]
|
||||
|
|
@ -488,8 +488,8 @@ pub fn mandelbrot(ctx: impl ExtractFootprint + Send) -> Table<Raster<CPU>> {
|
|||
}
|
||||
}
|
||||
|
||||
Table::new_from_row(
|
||||
TableRow::new_from_element(Raster::new_cpu(Image {
|
||||
Table::new_from_item(
|
||||
Item::new_from_element(Raster::new_cpu(Image {
|
||||
width,
|
||||
height,
|
||||
data,
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ pub async fn repeat_array<T: Into<Graphic> + Default + Send + Clone + 'static>(
|
|||
let generated_content = content.eval(new_ctx.into_context()).await;
|
||||
|
||||
for row_index in 0..generated_content.len() {
|
||||
let Some(mut row) = generated_content.clone_row(row_index) else { continue };
|
||||
let Some(mut row) = generated_content.clone_item(row_index) else { continue };
|
||||
|
||||
let local_transform: DAffine2 = row.attribute_cloned_or_default(ATTR_TRANSFORM);
|
||||
let local_translation = DAffine2::from_translation(local_transform.translation);
|
||||
|
|
@ -124,7 +124,7 @@ async fn repeat_radial<T: Into<Graphic> + Default + Send + Clone + 'static>(
|
|||
let generated_content = content.eval(new_ctx.into_context()).await;
|
||||
|
||||
for row_index in 0..generated_content.len() {
|
||||
let Some(mut row) = generated_content.clone_row(row_index) else { continue };
|
||||
let Some(mut row) = generated_content.clone_item(row_index) else { continue };
|
||||
|
||||
let local_transform: DAffine2 = row.attribute_cloned_or_default(ATTR_TRANSFORM);
|
||||
let local_translation = DAffine2::from_translation(local_transform.translation);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::{ATTR_TYPE, Ctx};
|
||||
use serde_json::Value;
|
||||
|
||||
|
|
@ -248,10 +248,7 @@ fn query_json_all(
|
|||
let mut results = Vec::new();
|
||||
resolve_all(&value, &segments, !unquote_strings, &mut results);
|
||||
|
||||
results
|
||||
.into_iter()
|
||||
.map(|(text, ty)| TableRow::new_from_element(text).with_attribute(ATTR_TYPE, ty.to_string()))
|
||||
.collect()
|
||||
results.into_iter().map(|(text, ty)| Item::new_from_element(text).with_attribute(ATTR_TYPE, ty.to_string())).collect()
|
||||
}
|
||||
|
||||
/// A parsed segment of a JSON access path.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ mod to_path;
|
|||
use convert_case::{Boundary, Converter, pattern};
|
||||
use core_types::graphene_hash::CacheHash;
|
||||
use core_types::registry::types::{SignedInteger, TextArea};
|
||||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::{CloneVarArgs, Context, Ctx, ExtractAll, ExtractVarArgs, OwnedContextImpl};
|
||||
use dyn_any::DynAny;
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
|
@ -30,10 +30,13 @@ pub use vector_types;
|
|||
pub enum TextAlign {
|
||||
#[default]
|
||||
#[icon("TextAlignLeft")]
|
||||
#[cfg_attr(feature = "serde", serde(alias = "Left"))]
|
||||
AlignLeft,
|
||||
#[icon("TextAlignCenter")]
|
||||
#[cfg_attr(feature = "serde", serde(alias = "Center"))]
|
||||
AlignCenter,
|
||||
#[icon("TextAlignRight")]
|
||||
#[cfg_attr(feature = "serde", serde(alias = "Right"))]
|
||||
AlignRight,
|
||||
#[icon("TextJustifyLeft")]
|
||||
JustifyLeft,
|
||||
|
|
@ -737,7 +740,7 @@ fn string_split(
|
|||
) -> Table<String> {
|
||||
let delimiter = if delimiter_escaping { unescape_string(delimiter) } else { delimiter };
|
||||
|
||||
string.split(&delimiter).map(str::to_string).map(TableRow::new_from_element).collect()
|
||||
string.split(&delimiter).map(str::to_string).map(Item::new_from_element).collect()
|
||||
}
|
||||
|
||||
/// Joins a list of strings together with a separator between each pair. This is the inverse of the **String Split** node.
|
||||
|
|
@ -778,7 +781,7 @@ async fn map_string(
|
|||
let owned_ctx = owned_ctx.with_vararg(Box::new(string)).with_index(i);
|
||||
let mapped_string = mapped.eval(owned_ctx.into_context()).await;
|
||||
|
||||
result.push(TableRow::new_from_element(mapped_string));
|
||||
result.push(Item::new_from_element(mapped_string));
|
||||
}
|
||||
|
||||
result
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::{ATTR_EDITOR_CLICK_TARGET, ATTR_EDITOR_TEXT_FRAME, ATTR_TRANSFORM};
|
||||
use glam::{DAffine2, DVec2};
|
||||
use parley::GlyphRun;
|
||||
|
|
@ -84,7 +84,7 @@ impl PathBuilder {
|
|||
// back to the layer-local frame origin, regardless of which glyph survived
|
||||
let frame_in_item_local = DAffine2::from_scale_angle_translation(self.text_frame_size, 0., -glyph_offset);
|
||||
|
||||
let item = TableRow::new_from_element(Vector::from_subpaths(core::mem::take(&mut self.glyph_subpaths), false))
|
||||
let item = Item::new_from_element(Vector::from_subpaths(core::mem::take(&mut self.glyph_subpaths), false))
|
||||
.with_attribute(ATTR_TRANSFORM, DAffine2::from_translation(glyph_offset))
|
||||
.with_attribute(ATTR_EDITOR_TEXT_FRAME, frame_in_item_local);
|
||||
self.vector_table.push(item);
|
||||
|
|
@ -169,7 +169,7 @@ impl PathBuilder {
|
|||
// TODO: Remove this hack and move the attribute up to the parent return value when <https://github.com/GraphiteEditor/Graphite/issues/3779> is done.
|
||||
if self.vector_table.is_empty() {
|
||||
let frame_in_item_local = DAffine2::from_scale_angle_translation(self.text_frame_size, 0., -self.first_glyph_offset);
|
||||
let item = TableRow::new_from_element(Vector::default())
|
||||
let item = Item::new_from_element(Vector::default())
|
||||
.with_attribute(ATTR_TRANSFORM, DAffine2::from_translation(self.first_glyph_offset))
|
||||
.with_attribute(ATTR_EDITOR_TEXT_FRAME, frame_in_item_local);
|
||||
self.vector_table.push(item);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use core_types::registry::types::SignedInteger;
|
||||
use core_types::table::{Table, TableRow};
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::{ATTR_END, ATTR_NAME, ATTR_START, Ctx};
|
||||
|
||||
/// Checks whether the string contains a match for the given regular expression pattern. Optionally restricts the match to only the start and/or end of the string.
|
||||
|
|
@ -143,7 +143,7 @@ fn regex_find(
|
|||
let start = captured.map_or(0_u64, |m| m.start() as u64);
|
||||
let end = captured.map_or(0_u64, |m| m.end() as u64);
|
||||
let name = capture_names.get(i).cloned().flatten().unwrap_or_default();
|
||||
TableRow::new_from_element(text)
|
||||
Item::new_from_element(text)
|
||||
.with_attribute(ATTR_START, start)
|
||||
.with_attribute(ATTR_END, end)
|
||||
.with_attribute(ATTR_NAME, name)
|
||||
|
|
@ -187,7 +187,7 @@ fn regex_find_all(
|
|||
.find_iter(&string)
|
||||
.filter_map(|m| m.ok())
|
||||
.map(|m| {
|
||||
TableRow::new_from_element(m.as_str().to_string())
|
||||
Item::new_from_element(m.as_str().to_string())
|
||||
.with_attribute(ATTR_START, m.start() as u64)
|
||||
.with_attribute(ATTR_END, m.end() as u64)
|
||||
})
|
||||
|
|
@ -226,5 +226,5 @@ fn regex_split(
|
|||
return Table::new_from_element(string);
|
||||
};
|
||||
|
||||
regex.split(&string).filter_map(|s| s.ok()).map(|s| s.to_string()).map(TableRow::new_from_element).collect()
|
||||
regex.split(&string).filter_map(|s| s.ok()).map(|s| s.to_string()).map(Item::new_from_element).collect()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ use vector_types::vector::VectorModification;
|
|||
/// Applies a differential modification to a vector path, associating changes made by the Pen and Path tools to indices of edited points and segments.
|
||||
#[node_macro::node(category(""))]
|
||||
async fn path_modify(_ctx: impl Ctx, mut vector: Table<Vector>, modification: Box<VectorModification>, node_path: Table<NodeId>) -> Table<Vector> {
|
||||
use core_types::table::TableRow;
|
||||
use core_types::table::Item;
|
||||
|
||||
if vector.is_empty() {
|
||||
vector.push(TableRow::default());
|
||||
vector.push(Item::default());
|
||||
}
|
||||
modification.apply(vector.element_mut(0).expect("push should give one item"));
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use core::hash::{Hash, Hasher};
|
|||
use core_types::blending::BlendMode;
|
||||
use core_types::bounds::{BoundingBox, RenderBoundingBox};
|
||||
use core_types::registry::types::{Angle, Length, Multiplier, Percentage, PixelLength, Progression, SeedValue};
|
||||
use core_types::table::{Table, TableDyn, TableRow};
|
||||
use core_types::table::{Item, Table, TableDyn};
|
||||
use core_types::transform::{Footprint, Transform};
|
||||
use core_types::uuid::NodeId;
|
||||
use core_types::{
|
||||
|
|
@ -321,7 +321,7 @@ async fn copy_to_points<I: 'n + Send + Clone>(
|
|||
let transform = DAffine2::from_scale_angle_translation(DVec2::splat(scale), rotation, translation);
|
||||
|
||||
for row_index in 0..content.len() {
|
||||
let Some(mut row) = content.clone_row(row_index) else { continue };
|
||||
let Some(mut row) = content.clone_item(row_index) else { continue };
|
||||
let row_transform: DAffine2 = row.attribute_cloned_or_default(ATTR_TRANSFORM);
|
||||
row.set_attribute(ATTR_TRANSFORM, transform * row_transform);
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ async fn round_corners(
|
|||
.map(|index| {
|
||||
let source_transform: DAffine2 = source.attribute_cloned_or_default(ATTR_TRANSFORM, index);
|
||||
let source_transform_inverse = source_transform.inverse();
|
||||
let attributes = source.clone_row_attributes(index);
|
||||
let attributes = source.clone_item_attributes(index);
|
||||
let source = source.element(index).unwrap();
|
||||
|
||||
// Flip the roundness to help with user intuition
|
||||
|
|
@ -442,7 +442,7 @@ async fn round_corners(
|
|||
result.append_bezpath(rounded_subpath);
|
||||
}
|
||||
|
||||
TableRow::from_parts(result, attributes)
|
||||
Item::from_parts(result, attributes)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -799,11 +799,11 @@ where
|
|||
}
|
||||
|
||||
// Prepare the items to be sorted
|
||||
let mut items: Vec<(f64, f64, DVec2, TableRow<T>)> = elements
|
||||
let mut items: Vec<(f64, f64, DVec2, Item<T>)> = elements
|
||||
.into_iter()
|
||||
.map(|row| {
|
||||
// Single-item `Table` to query its bounding box
|
||||
let single = Table::new_from_row(row.clone());
|
||||
let single = Table::new_from_item(row.clone());
|
||||
let (w, h, top_left) = match single.bounding_box(DAffine2::IDENTITY, false) {
|
||||
RenderBoundingBox::Rectangle([min, max]) => {
|
||||
let size = max - min;
|
||||
|
|
@ -902,7 +902,7 @@ async fn auto_tangents(
|
|||
(0..source.len())
|
||||
.map(|index| {
|
||||
let transform: DAffine2 = source.attribute_cloned_or_default(ATTR_TRANSFORM, index);
|
||||
let attributes = source.clone_row_attributes(index);
|
||||
let attributes = source.clone_item_attributes(index);
|
||||
let source = source.element(index).unwrap();
|
||||
|
||||
let mut result = Vector {
|
||||
|
|
@ -1035,7 +1035,7 @@ async fn auto_tangents(
|
|||
}
|
||||
}
|
||||
|
||||
TableRow::from_parts(result, attributes)
|
||||
Item::from_parts(result, attributes)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -1083,7 +1083,7 @@ async fn vec2_to_point(_: impl Ctx, vec2: DVec2) -> Table<Vector> {
|
|||
let mut point_domain = PointDomain::new();
|
||||
point_domain.push(PointId::generate(), vec2);
|
||||
|
||||
Table::new_from_row(TableRow::new_from_element(Vector { point_domain, ..Default::default() }))
|
||||
Table::new_from_item(Item::new_from_element(Vector { point_domain, ..Default::default() }))
|
||||
}
|
||||
|
||||
/// Creates a polyline from a series of vector points, replacing any existing segments and regions that may already exist.
|
||||
|
|
@ -1222,10 +1222,10 @@ async fn solidify_stroke<T: IntoGraphicTable + 'n + Send + Clone>(_: impl Ctx, #
|
|||
let has_fill = !vector.style.fill().is_none();
|
||||
let fill_row = has_fill.then(|| {
|
||||
vector.style.clear_stroke();
|
||||
TableRow::from_parts(vector, attributes.clone())
|
||||
Item::from_parts(vector, attributes.clone())
|
||||
});
|
||||
|
||||
let stroke_row = TableRow::from_parts(solidified_stroke, attributes);
|
||||
let stroke_row = Item::from_parts(solidified_stroke, attributes);
|
||||
|
||||
// Ordering based on the paint order. The first item in the `Table` is rendered below the second.
|
||||
match paint_order {
|
||||
|
|
@ -1271,9 +1271,9 @@ async fn separate_subpaths(_: impl Ctx, content: Table<Vector>) -> Table<Vector>
|
|||
vector.append_bezpath(bezpath);
|
||||
vector.style = style.clone();
|
||||
|
||||
TableRow::from_parts(vector, attributes.clone())
|
||||
Item::from_parts(vector, attributes.clone())
|
||||
})
|
||||
.collect::<Vec<TableRow<Vector>>>()
|
||||
.collect::<Vec<Item<Vector>>>()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -2409,11 +2409,11 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
|
|||
let endpoint_index = if time == 0. { source_index } else { target_index };
|
||||
let endpoint_element = content.element(endpoint_index).unwrap();
|
||||
|
||||
let mut attributes = content.clone_row_attributes(endpoint_index);
|
||||
let mut attributes = content.clone_item_attributes(endpoint_index);
|
||||
attributes.insert(ATTR_TRANSFORM, lerped_transform);
|
||||
attributes.insert(ATTR_EDITOR_MERGED_LAYERS, graphic_table_content);
|
||||
|
||||
return Table::new_from_row(TableRow::from_parts(endpoint_element.clone(), attributes));
|
||||
return Table::new_from_item(Item::from_parts(endpoint_element.clone(), attributes));
|
||||
}
|
||||
|
||||
let mut vector = Vector {
|
||||
|
|
@ -2569,8 +2569,8 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
|
|||
let primary_index = if time < 0.5 { source_index } else { target_index };
|
||||
let layer_path: Table<NodeId> = content.attribute_cloned_or_default(ATTR_EDITOR_LAYER_PATH, primary_index);
|
||||
|
||||
Table::new_from_row(
|
||||
TableRow::new_from_element(vector)
|
||||
Table::new_from_item(
|
||||
Item::new_from_element(vector)
|
||||
.with_attribute(ATTR_TRANSFORM, lerped_transform)
|
||||
.with_attribute(ATTR_BLEND_MODE, lerped_blend_mode)
|
||||
.with_attribute(ATTR_OPACITY, lerped_opacity)
|
||||
|
|
@ -2859,7 +2859,7 @@ fn bevel(_: impl Ctx, source: Table<Vector>, #[default(10.)] distance: Length) -
|
|||
let transform: DAffine2 = row.attribute_cloned_or_default(ATTR_TRANSFORM);
|
||||
let (element, attributes) = row.into_parts();
|
||||
|
||||
TableRow::from_parts(bevel_algorithm(element, transform, distance), attributes)
|
||||
Item::from_parts(bevel_algorithm(element, transform, distance), attributes)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -3046,10 +3046,10 @@ mod test {
|
|||
Table::new_from_element(Vector::from_bezpath(bezpath))
|
||||
}
|
||||
|
||||
fn create_vector_row(bezpath: BezPath, transform: DAffine2) -> TableRow<Vector> {
|
||||
fn create_vector_item(bezpath: BezPath, transform: DAffine2) -> Item<Vector> {
|
||||
let mut row = Vector::default();
|
||||
row.append_bezpath(bezpath);
|
||||
TableRow::new_from_element(row).with_attribute(ATTR_TRANSFORM, transform)
|
||||
Item::new_from_element(row).with_attribute(ATTR_TRANSFORM, transform)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
@ -3155,7 +3155,7 @@ mod test {
|
|||
async fn path_length() {
|
||||
let bezpath = Rect::new(100., 100., 201., 201.).to_path(DEFAULT_ACCURACY);
|
||||
let transform = DAffine2::from_scale(DVec2::new(2., 2.));
|
||||
let row = create_vector_row(bezpath, transform);
|
||||
let row = create_vector_item(bezpath, transform);
|
||||
let table = (0..5).map(|_| row.clone()).collect::<Table<Vector>>();
|
||||
|
||||
let length = super::path_length(Footprint::default(), table).await;
|
||||
|
|
@ -3173,7 +3173,7 @@ mod test {
|
|||
#[tokio::test]
|
||||
async fn morph() {
|
||||
let mut rectangles = vector_node_from_bezpath(Rect::new(0., 0., 100., 100.).to_path(DEFAULT_ACCURACY));
|
||||
let mut second_rectangle = rectangles.clone_row(0).unwrap();
|
||||
let mut second_rectangle = rectangles.clone_item(0).unwrap();
|
||||
*second_rectangle.attribute_mut_or_insert_default::<DAffine2>(ATTR_TRANSFORM) *= DAffine2::from_translation((-100., -100.).into());
|
||||
rectangles.push(second_rectangle);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue