diff options
| author | Alvin Penner <penner@vaxxine.com> | 2014-11-28 20:54:41 +0000 |
|---|---|---|
| committer | apenner <penner@vaxxine.com> | 2014-11-28 20:54:41 +0000 |
| commit | 561b8791651a0b3f9d49dfd9809519f06039e0a4 (patch) | |
| tree | eda7c9f819d13cbb691be35d5870211e5848ee5e | |
| parent | Dutch translation update (diff) | |
| download | inkscape-561b8791651a0b3f9d49dfd9809519f06039e0a4.tar.gz inkscape-561b8791651a0b3f9d49dfd9809519f06039e0a4.zip | |
avoid recalculating viewbox if it is not necessary. (Bug 1384915, comment 24)
Fixed bugs:
- https://launchpad.net/bugs/1384915
(bzr r13776)
| -rw-r--r-- | src/document.cpp | 8 | ||||
| -rw-r--r-- | src/document.h | 4 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.cpp | 9 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.h | 2 |
4 files changed, 12 insertions, 11 deletions
diff --git a/src/document.cpp b/src/document.cpp index 25afc1311..c7d14727a 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -627,7 +627,7 @@ Inkscape::Util::Quantity SPDocument::getWidth() const return Inkscape::Util::Quantity(result, unit_table.getUnit(u)); } -void SPDocument::setWidth(const Inkscape::Util::Quantity &width) +void SPDocument::setWidth(const Inkscape::Util::Quantity &width, bool changeSize) { Inkscape::Util::Unit const *old_units = unit_table.getUnit("px"); if (root->width.unit) @@ -638,7 +638,7 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->width.value = width.quantity; root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); - if (root->viewBox_set) + if (root->viewBox_set && changeSize) root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.value / old_converted) * root->viewBox.width(), root->viewBox.bottom())); root->updateRepr(); @@ -662,7 +662,7 @@ Inkscape::Util::Quantity SPDocument::getHeight() const return Inkscape::Util::Quantity(result, unit_table.getUnit(u)); } -void SPDocument::setHeight(const Inkscape::Util::Quantity &height) +void SPDocument::setHeight(const Inkscape::Util::Quantity &height, bool changeSize) { Inkscape::Util::Unit const *old_units = unit_table.getUnit("px"); if (root->height.unit) @@ -673,7 +673,7 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height) root->height.value = height.quantity; root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); - if (root->viewBox_set) + if (root->viewBox_set && changeSize) root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.value / old_converted) * root->viewBox.height())); root->updateRepr(); diff --git a/src/document.h b/src/document.h index 287228a67..4a24ff502 100644 --- a/src/document.h +++ b/src/document.h @@ -246,8 +246,8 @@ public: Inkscape::Util::Quantity getHeight() const; Geom::Point getDimensions() const; Geom::OptRect preferredBounds() const; - void setWidth(const Inkscape::Util::Quantity &width); - void setHeight(const Inkscape::Util::Quantity &height); + void setWidth(const Inkscape::Util::Quantity &width, bool changeSize=true); + void setHeight(const Inkscape::Util::Quantity &height, bool changeSize=true); void setViewBox(const Geom::Rect &viewBox); void requestModified(); int ensureUpToDate(); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index b775b3c49..df464fbb0 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -459,7 +459,7 @@ PageSizer::init () * \param changeList whether to modify the paper size list */ void -PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList) +PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList, bool changeSize) { static bool _called = false; if (_called) { @@ -479,8 +479,8 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); Inkscape::Util::Quantity const old_height = doc->getHeight(); - doc->setWidth (w); - doc->setHeight (h); + doc->setWidth (w, changeSize); + doc->setHeight (h, changeSize); // 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 Geom::Translate const vert_offset(Geom::Point(0, (old_height.value("px") - h.value("px")))); @@ -717,7 +717,8 @@ PageSizer::on_units_changed() if (_widgetRegistry->isUpdating()) return; _unit = _dimensionUnits.getUnit()->abbr; setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), - Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); + Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit()), + true, false); } } // namespace Widget diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index f4bcae4b6..bed117e5a 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -161,7 +161,7 @@ public: * Set the page size to the given dimensions. If 'changeList' is * true, then reset the paper size list to the closest match */ - void setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList=true); + void setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList=true, bool changeSize=true); /** * Updates the scalar widgets for the fit margins. (Just changes the value |
