diff options
| author | Shlomi Fish <shlomif@shlomifish.org> | 2016-09-30 23:00:59 +0000 |
|---|---|---|
| committer | Shlomi Fish <shlomif@shlomifish.org> | 2016-09-30 23:00:59 +0000 |
| commit | c14ec0bf6954beca505ed58b794632bd1ffe72ca (patch) | |
| tree | 4841d8360f4dc76b836a0799f5b027bb7ee0804e /src/widgets/stroke-style.cpp | |
| parent | Merged. (diff) | |
| download | inkscape-c14ec0bf6954beca505ed58b794632bd1ffe72ca.tar.gz inkscape-c14ec0bf6954beca505ed58b794632bd1ffe72ca.zip | |
Extract a function to prevent assignment + const-ing.
(bzr r15100.1.26)
Diffstat (limited to 'src/widgets/stroke-style.cpp')
| -rw-r--r-- | src/widgets/stroke-style.cpp | 18 |
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; |
