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

Bug #1671877 reported by Eman Modnar
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
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.

Tags: ui stroke
Revision history for this message
Eman Modnar (eman-mod) wrote :
Revision history for this message
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.

Revision history for this message
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)
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
Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
Jonathan Hofinger (jhofinger) wrote :

I've created a follow-up issue on Gitlab, which deals with the unreasonably high values that are created by this feature, see https://gitlab.com/inkscape/inbox/-/issues/2280. Thanks for your patch, it works fine! The behavior is now identical with all units.

Closed by: https://gitlab.com/jhofinger

Changed in inkscape:
status: Fix Committed → Invalid
Revision history for this message
Jonathan Hofinger (jhofinger) wrote :

Hi, I've created a follow-up issue that deals with the unreasonably high values created using this feature: https://gitlab.com/inkscape/inbox/-/issues/2280. Your patch works fine, thanks again, the behavior is now identical with all units.

Closed by: https://gitlab.com/jhofinger

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.