From 9e06d10b94e787b2f7e3a1fdc7182b396a77f5c6 Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Sun, 12 Jun 2022 19:05:06 +0200 Subject: [PATCH] prefer selected shape when highlighting vertexes or shapes (#890) The use case is adjusting shapes by moving their vertexes, even if they are adjacent or overlapping another shape. Currently always the "later drawn" shape wins, making it impossible to adjust an earlier shape without re-creating it. Adjusting existing shapes is common for review scenarios. I have experimented with preferring the highlighted shape, but I found it finicky and less clear as to how the vertex preference works. JOSM (and OpenStreetMap editor) also uses the "prefer selected" approach and it works well there. --- libs/canvas.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/canvas.py b/libs/canvas.py index 4a8d9586..8b7dc479 100644 --- a/libs/canvas.py +++ b/libs/canvas.py @@ -216,7 +216,8 @@ class Canvas(QWidget): # - Highlight vertex # Update shape/vertex fill and tooltip value accordingly. self.setToolTip("Image") - for shape in reversed([s for s in self.shapes if self.isVisible(s)]): + priority_list = self.shapes + ([self.selected_shape] if self.selected_shape else []) + for shape in reversed([s for s in priority_list if self.isVisible(s)]): # Look for a nearby vertex to highlight. If that fails, # check if we happen to be inside a shape. index = shape.nearest_vertex(pos, self.epsilon)