Fixes for removing artboards; white infinite canvas background (#1497)

* Fix crash when drawing on a deleted artboard

* Fix clear artboards button

* White background on no artboards

* Re-disable Clear Artboards since it still crashes

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2023-12-10 00:17:18 +00:00
committed by GitHub
parent 33845707db
commit b60736c2c6
6 changed files with 43 additions and 4 deletions

View File

@@ -227,6 +227,10 @@ pub trait GraphicElementRendered {
root: root_node.clone(),
}
}
fn contains_artboard(&self) -> bool {
false
}
}
impl GraphicElementRendered for GraphicGroup {
@@ -265,6 +269,10 @@ impl GraphicElementRendered for GraphicGroup {
}
root_node
}
fn contains_artboard(&self) -> bool {
self.iter().any(|element| element.contains_artboard())
}
}
impl GraphicElementRendered for VectorData {
@@ -427,6 +435,10 @@ impl GraphicElementRendered for Artboard {
let subpath = Subpath::new_rect(DVec2::ZERO, self.dimensions.as_dvec2());
click_targets.push(ClickTarget { stroke_width: 0., subpath });
}
fn contains_artboard(&self) -> bool {
true
}
}
impl GraphicElementRendered for ImageFrame<Color> {
@@ -546,6 +558,16 @@ impl GraphicElementRendered for GraphicElement {
GraphicElement::Artboard(artboard) => artboard.to_usvg_node(),
}
}
fn contains_artboard(&self) -> bool {
match self {
GraphicElement::VectorData(vector_data) => vector_data.contains_artboard(),
GraphicElement::ImageFrame(image_frame) => image_frame.contains_artboard(),
GraphicElement::Text(text) => text.contains_artboard(),
GraphicElement::GraphicGroup(graphic_group) => graphic_group.contains_artboard(),
GraphicElement::Artboard(artboard) => artboard.contains_artboard(),
}
}
}
/// Used to stop rust complaining about upstream traits adding display implementations to `Option<Color>`. This would not be an issue as we control that crate.