summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2016-09-30 23:00:59 +0000
committerShlomi Fish <shlomif@shlomifish.org>2016-09-30 23:00:59 +0000
commitc14ec0bf6954beca505ed58b794632bd1ffe72ca (patch)
tree4841d8360f4dc76b836a0799f5b027bb7ee0804e /src
parentMerged. (diff)
downloadinkscape-c14ec0bf6954beca505ed58b794632bd1ffe72ca.tar.gz
inkscape-c14ec0bf6954beca505ed58b794632bd1ffe72ca.zip
Extract a function to prevent assignment + const-ing.
(bzr r15100.1.26)
Diffstat (limited to 'src')
-rw-r--r--src/widgets/stroke-style.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 4a658c5dc..f5735190f 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -976,6 +976,16 @@ StrokeStyle::setScaledDash(SPCSSAttr *css,
}
}
+static inline double calcScaleLineWidth(const double width_typed, SPItem *const item, Inkscape::Util::Unit const *const unit)
+{
+ if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
+ return Inkscape::Util::Quantity::convert(width_typed, unit, "px");
+ } else { // percentage
+ const gdouble old_w = item->style->stroke_width.computed;
+ return old_w * width_typed / 100;
+ }
+}
+
/**
* Sets line properties like width, dashes, markers, etc. on all currently selected items.
*/
@@ -1007,13 +1017,7 @@ StrokeStyle::scaleLine()
for(auto i=items.begin();i!=items.end();++i){
/* Set stroke width */
- double width;
- if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
- width = Inkscape::Util::Quantity::convert(width_typed, unit, "px");
- } else { // percentage
- gdouble old_w = (*i)->style->stroke_width.computed;
- width = old_w * width_typed / 100;
- }
+ const double width = calcScaleLineWidth(width_typed, (*i), unit);
{
Inkscape::CSSOStringStream os_width;