Remove artboard from graphic element (#1824)

* Remove artboard from graphic element

* Fix transform bug
This commit is contained in:
James Lindsay
2024-07-14 05:10:29 +01:00
committed by GitHub
parent 027d3f4e60
commit 0c2e3361ab
4 changed files with 51 additions and 72 deletions

View File

@@ -121,15 +121,6 @@ impl ArtboardGroup {
fn add_artboard(&mut self, artboard: Artboard) {
self.artboards.push(artboard);
}
pub fn get_graphic_group(&self) -> GraphicGroup {
let mut graphic_group = GraphicGroup::EMPTY;
for artboard in self.artboards.clone() {
let graphic_element: GraphicElement = artboard.into();
graphic_group.push(graphic_element);
}
graphic_group
}
}
pub struct ConstructLayerNode<Stack, GraphicElement> {
@@ -240,11 +231,6 @@ impl From<GraphicGroup> for GraphicElement {
GraphicElement::GraphicGroup(graphic_group)
}
}
impl From<Artboard> for GraphicElement {
fn from(artboard: Artboard) -> Self {
GraphicElement::Artboard(artboard)
}
}
impl Deref for GraphicGroup {
type Target = Vec<GraphicElement>;
@@ -265,7 +251,6 @@ trait ToGraphicElement: Into<GraphicElement> {}
impl ToGraphicElement for VectorData {}
impl ToGraphicElement for ImageFrame<Color> {}
impl ToGraphicElement for Artboard {}
impl<T> From<T> for GraphicGroup
where

View File

@@ -469,15 +469,19 @@ impl GraphicElementRendered for Artboard {
impl GraphicElementRendered for crate::ArtboardGroup {
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
self.get_graphic_group().render_svg(render, render_params);
for artboard in &self.artboards {
artboard.render_svg(render, render_params);
}
}
fn bounding_box(&self, transform: DAffine2) -> Option<[DVec2; 2]> {
self.get_graphic_group().bounding_box(transform)
self.artboards.iter().filter_map(|element| element.bounding_box(transform)).reduce(Quad::combine_bounds)
}
fn add_click_targets(&self, click_targets: &mut Vec<ClickTarget>) {
self.get_graphic_group().add_click_targets(click_targets);
for artboard in &self.artboards {
artboard.add_click_targets(click_targets);
}
}
fn contains_artboard(&self) -> bool {