Changing stroke width in statusbar is wrong with units selected other than 'px'

Bug #1671877 reported by Eman Modnar on 2017-03-10
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Low
Eman Modnar

Bug Description

There's a cool feature in Inkscape that one can change stroke width by moving mouse cursor on top of stroke width indicator in the statusbar and then scrolling or dragging ('gestures' or 'rotatable stroke width' feature).

If document's default units is not 'px' or if they been changed in the context menu of the stroke width indicator to units other than 'px', e.g. 'mm' or 'in', then width of a stroke changes somewhat unpredictably.

Steps to reproduce:
1. Create an object with a thick stroke
2. Do a right click on the stroke indicator in the statusbar and choose 'in' (inches)
3. Scroll on top of the indicator or drag it to change stroke width (width drops almost to zero no matter which direction you scroll to).

--

I've made some investigation and have found that new stroke width is not converted to proper units and remain in 'px' after preliminary conversion.

Patch attached. Also I changed the multiplication factor for stroke enlargement with 'gesture' to 10x as 4x is too few in my opinion.

Thank you.

Eman Modnar (eman-mod) wrote :
Eman Modnar (eman-mod) wrote :

Patch updated. In 'gesture', exponential function for stroke width is more smooth and natural than mixture of linear and quadratic. Also I decided to increase the multiplication factor to 50x.

Eman Modnar (eman-mod) wrote :

In the new patch, line 16, the expression
    newval = current * (std::exp(std::log(max_f-1) * (by+1)) - 1) / (max_f-2);

can be changed to
    newval = current * (std::pow(max_f-1, by+1) - 1) / (max_f-2);

as exp(log(x)*a) == pow(x,a).

su_v (suv-lp) on 2017-03-11
summary: - Changing storke width in statusbar is wrong with units selected other
+ Changing stroke width in statusbar is wrong with units selected other
than 'px'
tags: added: stroke ui
Mc (mc...) wrote :

pushed to r15622, thanks for the fix!

Changed in inkscape:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → Eman Modnar (eman-mod)
milestone: none → 0.93
status: Confirmed → Fix Committed
Eman Modnar (eman-mod) wrote :

Thank you very much, Mc!

And so sorry for the dirty patch :( I'm very new to programming and especially to C++. I now clearly see, that the name of a private variable `_sw_unit` is used wrong. Probably it'll be better to introduce new variable or a function for getting current units.

If you don't mind I'll soon make some corrections to the patch. Thank you.

Eman Modnar (eman-mod) wrote :

Mc, the corrections are available at `lp:~eman-mod/inkscape/inkscape` branch under revision 12625. Also you can see them at http://bazaar.launchpad.net/~eman-mod/inkscape/inkscape/revision/15625

Additionally I've attached diff (`bzr diff`) file.

Thank you.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers