diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-12-11 13:31:24 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-12-11 13:31:24 +0000 |
| commit | 22b51fa87ea56f6ca9422c84bea18546412d7e9d (patch) | |
| tree | 3ad238131718e7babac3d77aa75b5de91673ef5c /src/ui/widget/registered-widget.cpp | |
| parent | Fix build with poppler 0.29.0 (Bug #1399811) (diff) | |
| download | inkscape-22b51fa87ea56f6ca9422c84bea18546412d7e9d.tar.gz inkscape-22b51fa87ea56f6ca9422c84bea18546412d7e9d.zip | |
Change grids to use 'user units'. Grids using absolute units are read in but
may be scaled incorrectly due to change of 90 to 96 dpi.
(bzr r13795)
Diffstat (limited to 'src/ui/widget/registered-widget.cpp')
| -rw-r--r-- | src/ui/widget/registered-widget.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index e97285de4..4065bd550 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -36,6 +36,8 @@ // for interruptability bug: #include "display/sp-canvas.h" +#include "sp-root.h" + namespace Inkscape { namespace UI { namespace Widget { @@ -203,7 +205,7 @@ RegisteredScalarUnit::~RegisteredScalarUnit() _value_changed_connection.disconnect(); } -RegisteredScalarUnit::RegisteredScalarUnit (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in) +RegisteredScalarUnit::RegisteredScalarUnit (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in, RSU_UserUnits user_units) : RegisteredWidget<ScalarUnit>(label, tip, UNIT_TYPE_LINEAR, "", "", rum.getUnitMenu()), _um(0) { @@ -215,6 +217,7 @@ RegisteredScalarUnit::RegisteredScalarUnit (const Glib::ustring& label, const Gl setUnit (rum.getUnitMenu()->getUnitAbbr()); setDigits (2); _um = rum.getUnitMenu(); + _user_units = user_units; _value_changed_connection = signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredScalarUnit::on_value_changed)); } @@ -233,12 +236,28 @@ RegisteredScalarUnit::on_value_changed() _wr->setUpdating (true); Inkscape::SVGOStringStream os; - os << getValue(""); - if (_um) - os << _um->getUnitAbbr(); + if (_user_units != RSU_none) { + // Output length in 'user units', taking into account scale in 'x' or 'y'. + double scale = 1.0; + if (doc) { + SPRoot *root = doc->getRoot(); + if (root->viewBox_set) { + if (_user_units == RSU_x) { + scale = root->viewBox.width() / root->width.computed; + } else { + scale = root->viewBox.height() / root->height.computed; + } + } + } + os << getValue("px") * scale; + } else { + // Output using unit identifiers. + os << getValue(""); + if (_um) + os << _um->getUnitAbbr(); + } write_to_xml(os.str().c_str()); - _wr->setUpdating (false); } |
