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/object/sp-guide.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/object/sp-guide.cpp') diff --git a/src/object/sp-guide.cpp b/src/object/sp-guide.cpp index 0b8558230..acb0707d0 100644 --- a/src/object/sp-guide.cpp +++ b/src/object/sp-guide.cpp @@ -131,6 +131,12 @@ void SPGuide::set(unsigned int key, const gchar *value) { g_strfreev (strarray); if (success == 2 && (fabs(newx) > 1e-6 || fabs(newy) > 1e-6)) { Geom::Point direction(newx, newy); + + // stores inverted y-axis coordinates + if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->is_yaxisdown()) { + direction[Geom::Y] *= -1.0; + } + direction.normalize(); this->normal_to_line = direction; } else { @@ -176,6 +182,11 @@ void SPGuide::set(unsigned int key, const gchar *value) { this->point_on_line = Geom::Point(newx, 0); } } + + // stores inverted y-axis coordinates + if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->is_yaxisdown()) { + this->point_on_line[Geom::Y] = document->getHeight().value("px") - this->point_on_line[Geom::Y]; + } } else { // default to (0,0) for bad arguments this->point_on_line = Geom::Point(0,0); @@ -217,6 +228,12 @@ SPGuide *SPGuide::createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::P } } + // stores inverted y-axis coordinates + if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->is_yaxisdown()) { + newy = doc->getHeight().value("px") - newy; + n[Geom::Y] *= -1.0; + } + sp_repr_set_point(repr, "position", Geom::Point( newx, newy )); sp_repr_set_point(repr, "orientation", n); @@ -368,6 +385,11 @@ void SPGuide::moveto(Geom::Point const point_on_line, bool const commit) double newx = point_on_line.x(); double newy = point_on_line.y(); + // stores inverted y-axis coordinates + if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->is_yaxisdown()) { + newy = document->getHeight().value("px") - newy; + } + SPRoot *root = document->getRoot(); if( root->viewBox_set ) { // check to see if scaling is uniform @@ -414,7 +436,14 @@ void SPGuide::set_normal(Geom::Point const normal_to_line, bool const commit) case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */ if (commit) { //XML Tree being used directly while it shouldn't be - sp_repr_set_point(getRepr(), "orientation", normal_to_line); + auto normal = normal_to_line; + + // stores inverted y-axis coordinates + if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->is_yaxisdown()) { + normal[Geom::Y] *= -1.0; + } + + sp_repr_set_point(getRepr(), "orientation", normal); } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) -- cgit v1.2.3