From bad0504958a10f1b99db3ae2557305541f388a52 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Nov 2014 20:56:53 +0100 Subject: Units: make it absolutely clear that Document properties unit dropdown is for UI Display Units. Upon document load, calculate the units used for SVG values, if a viewbox is available. If not, default to "px" SVG units. Change all code to use either Display units OR svg units. (bzr r13751) --- src/sp-guide.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 581c8a440..74a0d829c 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -410,8 +410,8 @@ char* SPGuide::description(bool const verbose) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(this->point_on_line[X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(this->point_on_line[Y], "px"); - GString *position_string_x = g_string_new(x_q.string(namedview->doc_units).c_str()); - GString *position_string_y = g_string_new(y_q.string(namedview->doc_units).c_str()); + GString *position_string_x = g_string_new(x_q.string(namedview->display_units).c_str()); + GString *position_string_y = g_string_new(y_q.string(namedview->display_units).c_str()); gchar *shortcuts = g_strdup_printf("; %s", _("Shift+drag to rotate, Ctrl+drag to move origin, Del to delete")); -- cgit v1.2.3 From 789c2831fb88f3296ace1885de58d50a2b493f59 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 26 Nov 2014 15:26:13 +0100 Subject: Use SVG width/height and viewBox to correct guide position. (bzr r13769) --- src/sp-guide.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 74a0d829c..a92e6916b 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -37,6 +37,7 @@ #include #include "inkscape.h" #include "desktop.h" +#include "sp-root.h" #include "sp-namedview.h" #include <2geom/angle.h> #include "document.h" @@ -152,6 +153,12 @@ void SPGuide::set(unsigned int key, const gchar *value) { success += sp_svg_number_read_d(strarray[1], &newy); g_strfreev (strarray); if (success == 2) { + // If root viewBox set, interpret guides in terms of viewBox (90/96) + SPRoot *root = document->getRoot(); + if( root->viewBox_set ) { + newx = newx * root->width.computed / root->viewBox.width(); + newy = newy * root->height.computed / root->viewBox.height(); + } this->point_on_line = Geom::Point(newx, newy); } else if (success == 1) { // before 0.46 style guideline definition. @@ -318,8 +325,18 @@ void SPGuide::moveto(Geom::Point const point_on_line, bool const commit) /* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */ if (commit) { + // If root viewBox set, interpret guides in terms of viewBox (90/96) + double newx = point_on_line.x(); + double newy = point_on_line.y(); + + SPRoot *root = document->getRoot(); + if( root->viewBox_set ) { + newx = newx * root->viewBox.width() / root->width.computed; + newy = newy * root->viewBox.height() / root->height.computed; + } + //XML Tree being used here directly while it shouldn't be. - sp_repr_set_point(getRepr(), "position", point_on_line); + sp_repr_set_point(getRepr(), "position", Geom::Point(newx, newy) ); } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) -- cgit v1.2.3 From 1eb57acf61991fc8f886d1acf2b432eb41a78565 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 26 Nov 2014 18:23:19 +0100 Subject: Correct guide placement when created by dragging onto canvas or by creating guides around object/page. (bzr r13771) --- src/sp-guide.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index a92e6916b..d7d15bac7 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -192,7 +192,17 @@ SPGuide *SPGuide::createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::P Geom::Point n = Geom::rot90(pt2 - pt1); - sp_repr_set_point(repr, "position", pt1); + // If root viewBox set, interpret guides in terms of viewBox (90/96) + double newx = pt1.x(); + double newy = pt1.y(); + + SPRoot *root = doc->getRoot(); + if( root->viewBox_set ) { + newx = newx * root->viewBox.width() / root->width.computed; + newy = newy * root->viewBox.height() / root->height.computed; + } + + sp_repr_set_point(repr, "position", Geom::Point( newx, newy )); sp_repr_set_point(repr, "orientation", n); SPNamedView *namedview = sp_document_namedview(doc, NULL); -- cgit v1.2.3