From 1fa0c72b664afa4803dffd463ed11ce01632ab76 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Wed, 12 Sep 2018 16:43:47 +0200 Subject: New option to invert y-axis Replaces all hard coded or implicit desktop coordinate usage with doc2dt multiplication. New global preference: Interface > Origin at upper left https://bugs.launchpad.net/inkscape/+bug/170049 --- src/document.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 658bc93c9..d4094b7e9 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -841,6 +841,12 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) margin_bottom = Inkscape::Util::Quantity::convert(margin_bottom, nv_units, "px"); } } + + double y_dir = SP_ACTIVE_DESKTOP->yaxisdir(); + + if (y_dir > 0) { + std::swap(margin_top, margin_bottom); + } Geom::Rect const rect_with_margins( rect.min() - Geom::Point(margin_left, margin_bottom), @@ -852,7 +858,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) ); Geom::Translate const tr( - Geom::Point(0, old_height - rect_with_margins.height()) + Geom::Point(0, (y_dir > 0) ? 0 : old_height - rect_with_margins.height()) - rect_with_margins.min()); root->translateChildItems(tr); @@ -862,7 +868,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) nv->translateGrids(tr2); // update the viewport so the drawing appears to stay where it was - nv->scrollAllDesktops(-tr2[0], tr2[1], false); + nv->scrollAllDesktops(-tr2[0], -tr2[1] * y_dir, false); } } -- cgit v1.2.3