From 0b27d6e652a5542bf0a373add06b2a5d5b55785d Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Tue, 4 Oct 2022 14:48:09 +0200 Subject: [PATCH] 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. --- libs/canvas/poly_line.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/canvas/poly_line.cc b/libs/canvas/poly_line.cc index 01ffe4e0da..c12bb49450 100644 --- a/libs/canvas/poly_line.cc +++ b/libs/canvas/poly_line.cc @@ -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; } }