1- use core_types:: Color ;
21use core_types:: blending:: AlphaBlending ;
32use core_types:: bounds:: { BoundingBox , RenderBoundingBox } ;
43use core_types:: graphene_hash:: CacheHash ;
54use core_types:: ops:: TableConvert ;
65use core_types:: render_complexity:: RenderComplexity ;
76use core_types:: table:: { Table , TableRow } ;
87use core_types:: uuid:: NodeId ;
8+ use core_types:: { ATTR_ALPHA_BLENDING , ATTR_EDITOR_LAYER_PATH , ATTR_TRANSFORM , Color } ;
99use dyn_any:: DynAny ;
1010use glam:: DAffine2 ;
1111use raster_types:: { CPU , GPU , Raster } ;
@@ -141,19 +141,19 @@ fn flatten_graphic_table<T>(content: Table<Graphic>, extract_variant: fn(Graphic
141141
142142 fn flatten_recursive < T > ( output : & mut Table < T > , current_graphic_table : Table < Graphic > , extract_variant : fn ( Graphic ) -> Option < Table < T > > ) {
143143 for current_graphic_row in current_graphic_table. into_iter ( ) {
144- let layer_path: Table < NodeId > = current_graphic_row. attribute_cloned_or_default ( "editor:layer" ) ;
145- let current_transform: DAffine2 = current_graphic_row. attribute_cloned_or_default ( "transform" ) ;
146- let current_alpha_blending: AlphaBlending = current_graphic_row. attribute_cloned_or_default ( "alpha_blending" ) ;
144+ let layer_path: Table < NodeId > = current_graphic_row. attribute_cloned_or_default ( ATTR_EDITOR_LAYER_PATH ) ;
145+ let current_transform: DAffine2 = current_graphic_row. attribute_cloned_or_default ( ATTR_TRANSFORM ) ;
146+ let current_alpha_blending: AlphaBlending = current_graphic_row. attribute_cloned_or_default ( ATTR_ALPHA_BLENDING ) ;
147147
148148 match current_graphic_row. into_element ( ) {
149149 // Recurse into nested `Table<Graphic>` items, composing the parent's transform onto each child
150150 Graphic :: Graphic ( mut sub_table) => {
151151 for index in 0 ..sub_table. len ( ) {
152- let child_transform: DAffine2 = sub_table. attribute_cloned_or_default ( "transform" , index) ;
153- let child_alpha_blending: AlphaBlending = sub_table. attribute_cloned_or_default ( "alpha_blending" , index) ;
152+ let child_transform: DAffine2 = sub_table. attribute_cloned_or_default ( ATTR_TRANSFORM , index) ;
153+ let child_alpha_blending: AlphaBlending = sub_table. attribute_cloned_or_default ( ATTR_ALPHA_BLENDING , index) ;
154154
155- sub_table. set_attribute ( "transform" , index, current_transform * child_transform) ;
156- sub_table. set_attribute ( "alpha_blending" , index, compose_alpha_blending ( current_alpha_blending, child_alpha_blending) ) ;
155+ sub_table. set_attribute ( ATTR_TRANSFORM , index, current_transform * child_transform) ;
156+ sub_table. set_attribute ( ATTR_ALPHA_BLENDING , index, compose_alpha_blending ( current_alpha_blending, child_alpha_blending) ) ;
157157 }
158158
159159 flatten_recursive ( output, sub_table, extract_variant) ;
@@ -162,13 +162,13 @@ fn flatten_graphic_table<T>(content: Table<Graphic>, extract_variant: fn(Graphic
162162 other => {
163163 if let Some ( typed_table) = extract_variant ( other) {
164164 for row in typed_table. into_iter ( ) {
165- let row_transform: DAffine2 = row. attribute_cloned_or_default ( "transform" ) ;
166- let row_alpha_blending: AlphaBlending = row. attribute_cloned_or_default ( "alpha_blending" ) ;
165+ let row_transform: DAffine2 = row. attribute_cloned_or_default ( ATTR_TRANSFORM ) ;
166+ let row_alpha_blending: AlphaBlending = row. attribute_cloned_or_default ( ATTR_ALPHA_BLENDING ) ;
167167 let ( element, mut attributes) = row. into_parts ( ) ;
168168
169- attributes. insert ( "transform" , current_transform * row_transform) ;
170- attributes. insert ( "alpha_blending" , compose_alpha_blending ( current_alpha_blending, row_alpha_blending) ) ;
171- attributes. insert ( "editor:layer" , layer_path. clone ( ) ) ;
169+ attributes. insert ( ATTR_TRANSFORM , current_transform * row_transform) ;
170+ attributes. insert ( ATTR_ALPHA_BLENDING , compose_alpha_blending ( current_alpha_blending, row_alpha_blending) ) ;
171+ attributes. insert ( ATTR_EDITOR_LAYER_PATH , layer_path. clone ( ) ) ;
172172
173173 output. push ( TableRow :: from_parts ( element, attributes) ) ;
174174 }
@@ -321,7 +321,7 @@ impl Graphic {
321321
322322 pub fn had_clip_enabled ( & self ) -> bool {
323323 fn all_clipped < T > ( table : & Table < T > ) -> bool {
324- table. iter_attribute_values_or_default :: < AlphaBlending > ( "alpha_blending" ) . all ( |a| a. clip )
324+ table. iter_attribute_values_or_default :: < AlphaBlending > ( ATTR_ALPHA_BLENDING ) . all ( |a| a. clip )
325325 }
326326 match self {
327327 Graphic :: Vector ( table) => all_clipped ( table) ,
@@ -337,7 +337,7 @@ impl Graphic {
337337 match self {
338338 Graphic :: Vector ( vector) => vector
339339 . iter_element_values ( )
340- . zip ( vector. iter_attribute_values_or_default :: < AlphaBlending > ( "alpha_blending" ) )
340+ . zip ( vector. iter_attribute_values_or_default :: < AlphaBlending > ( ATTR_ALPHA_BLENDING ) )
341341 . all ( |( element, alpha_blending) | {
342342 ( alpha_blending. opacity > 1. - f32:: EPSILON ) && element. style . fill ( ) . is_opaque ( ) && element. style . stroke ( ) . is_none_or ( |stroke| !stroke. has_renderable_stroke ( ) )
343343 } ) ,
@@ -504,7 +504,7 @@ pub fn migrate_graphic<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Res
504504 Table ( serde_json:: Value ) ,
505505 }
506506
507- // Attributes (transform, alpha_blending, editor:layer ) are not serialized, so migration only needs
507+ // Attributes (transform, alpha_blending, editor:layer_path ) are not serialized, so migration only needs
508508 // to recover the elements. Per-item attribute values are populated at runtime by the node graph.
509509 Ok ( match GraphicFormat :: deserialize ( deserializer) ? {
510510 GraphicFormat :: OldGraphicGroup ( old) => old. elements . into_iter ( ) . map ( |( graphic, _) | TableRow :: new_from_element ( graphic) ) . collect ( ) ,
0 commit comments