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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 4 deletions

View file

@ -4,7 +4,7 @@ use core::future::Future;
use dyn_any::StaticType;
use graphene_core::application_io::{ApplicationError, ApplicationIo, ExportFormat, RenderConfig, ResourceFuture, SurfaceHandle, SurfaceHandleFrame, SurfaceId};
use graphene_core::raster::Image;
use graphene_core::renderer::{GraphicElementRendered, ImageRenderMode, RenderParams, SvgRender};
use graphene_core::renderer::{format_transform_matrix, GraphicElementRendered, ImageRenderMode, RenderParams, SvgRender};
use graphene_core::transform::Footprint;
use graphene_core::Color;
use graphene_core::{
@ -291,8 +291,21 @@ pub struct RenderNode<Data, Surface, Parameter> {
}
fn render_svg(data: impl GraphicElementRendered, mut render: SvgRender, render_params: RenderParams, footprint: Footprint) -> RenderOutput {
if !data.contains_artboard() && !render_params.hide_artboards {
render.leaf_tag("rect", |attributes| {
attributes.push("x", "0");
attributes.push("x", "0");
attributes.push("y", "0");
attributes.push("width", footprint.resolution.x.to_string());
attributes.push("height", footprint.resolution.y.to_string());
attributes.push("transform", format_transform_matrix(footprint.transform.inverse()));
attributes.push("fill", "white");
});
}
data.render_svg(&mut render, &render_params);
render.wrap_with_transform(footprint.transform, Some(footprint.resolution.as_dvec2()));
RenderOutput::Svg(render.svg.to_string())
}