13
0

Fix proximity threshold for polyline

I'm not good with a mouse, so I found it hard to edit animation lines.
The mouse position has to be quite precise, with only a small threshold.

Looking at the code, AutomationLine sets the threshold for the PolyLine
to 4.0 . That seems to be a distance, and better for me than what I
experience.

The actual code in PolyLine is however comparing it directly to the
squared distance, making it more sensitive than expected.

Fixed by computing the squared threshold - also including the line
width.
This commit is contained in:
Mads Kiilerich 2022-10-04 14:48:09 +02:00 committed by Robin Gareus
parent d1265b5a02
commit 0b27d6e652
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -153,6 +153,9 @@ PolyLine::covers (Duple const& point) const
Points::size_type i;
Points::size_type j;
double squared_threshold = _threshold + _outline_width;
squared_threshold *= squared_threshold;
/* repeat for each line segment */
const Rect visible (window_to_item (_canvas->visible_area ()));
@ -180,7 +183,7 @@ PolyLine::covers (Duple const& point) const
continue;
}
if (d < _threshold + _outline_width) {
if (d < squared_threshold) {
return true;
}
}