From a6949e6fbf2cef3e943f54c5cc3e36647af0d84e Mon Sep 17 00:00:00 2001 From: jsfer Date: Fri, 4 Mar 2022 14:07:44 -0500 Subject: [PATCH] Guides placed correctly when Document resized Using document coord space instead of XML coords since XML has y-axis inverted. Mimicking `PageManager::resizePage()` Fixes: https://gitlab.com/inkscape/inkscape/-/issues/1230 --- src/ui/dialog/document-properties.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 63dd8b102b..30985c0d84 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -221,16 +221,17 @@ void set_color(SPDesktop* desktop, Glib::ustring operation, unsigned int rgba, S void set_document_dimensions(SPDesktop* desktop, double width, double height, const Inkscape::Util::Unit* unit) { if (!desktop) return; - Inkscape::Util::Quantity w = Inkscape::Util::Quantity(width, unit); - Inkscape::Util::Quantity h = Inkscape::Util::Quantity(height, unit); + Inkscape::Util::Quantity width_quantity = Inkscape::Util::Quantity(width, unit); + Inkscape::Util::Quantity height_quantity = Inkscape::Util::Quantity(height, unit); SPDocument* doc = desktop->getDocument(); Inkscape::Util::Quantity const old_height = doc->getHeight(); - bool change_size = true; - doc->setWidthAndHeight(w, h, change_size); + auto rect = Geom::Rect(Geom::Point(0, 0), Geom::Point(width_quantity.value("px"), height_quantity.value("px"))); + doc->fitToRect(rect, false); + // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this - if (change_size && !doc->is_yaxisdown()) { - Geom::Translate const vert_offset(Geom::Point(0, (old_height.value("px") - h.value("px")))); + if (!doc->is_yaxisdown()) { + Geom::Translate const vert_offset(Geom::Point(0, (old_height.value("px") - height_quantity.value("px")))); doc->getRoot()->translateChildItems(vert_offset); } // units: this is most likely not needed, units are part of document size attributes -- GitLab