Use Arc<List<Vector>> for vector_data metadata

This exposes List's attributes to message handlers, enabling them to
access the necessary attribute data such as ATTR_STROKE_PAINT_GRAPHIC
as `Fill` and `Stroke` will not have paint information in the future.
This commit is contained in:
YohYamasaki
2026-05-20 16:09:39 +09:00
parent 1adeb4cedd
commit 4285243a5d
5 changed files with 48 additions and 19 deletions

View File

@@ -391,7 +391,9 @@ pub struct RenderMetadata {
/// The Text tool composes this with `transform_to_viewport(layer)` to position its drag cage.
pub text_frames: HashMap<NodeId, DAffine2>,
pub clip_targets: HashSet<NodeId>,
pub vector_data: HashMap<NodeId, Arc<Vector>>,
// `RenderMetadata` only enters serialization via `TaggedValue::RenderOutput`, which also skips serde.
#[cfg_attr(feature = "serde", serde(skip))]
pub vector_data: HashMap<NodeId, Arc<List<Vector>>>,
pub backgrounds: Vec<Background>,
}
@@ -1525,6 +1527,11 @@ impl Render for List<Vector> {
let mut accumulated_click_targets: HashMap<NodeId, Vec<Arc<ClickTarget>>> = HashMap::new();
let mut accumulated_outlines: HashMap<NodeId, Vec<Arc<ClickTarget>>> = HashMap::new();
// Source geometry (not the click-target override) so editing tools work on letterforms.
if let Some(element_id) = caller_element_id {
metadata.vector_data.entry(element_id).or_insert_with(|| Arc::new(self.clone()));
}
for index in 0..self.len() {
let Some(source) = self.element(index) else { continue };
let transform: DAffine2 = self.attribute_cloned_or_default(ATTR_TRANSFORM, index);
@@ -1554,10 +1561,6 @@ impl Render for List<Vector> {
extend_targets_from_vector(&mut outlines_unwrapped, source, item_relative_transform);
accumulated_outlines.entry(element_id).or_default().extend(outlines_unwrapped.into_iter().map(Arc::new));
// Source geometry (not the click-target override) so editing tools work on letterforms.
// Only item 0 is recorded since editing tools can only target a single item currently.
metadata.vector_data.entry(element_id).or_insert_with(|| Arc::new(source.clone()));
// Surface `editor:text_frame` for the Text tool's drag cage
if let Some(&frame) = self.attribute::<DAffine2>(ATTR_EDITOR_TEXT_FRAME, index) {
metadata.text_frames.entry(element_id).or_insert(frame);