From b0949f6827cdd2edf75189178d1749fea1cd6874 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Thu, 22 Aug 2019 21:56:58 -0700 Subject: [PATCH] Add cases so selection from right, left in all orientations works --- clusterview/opengl_widget.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/clusterview/opengl_widget.py b/clusterview/opengl_widget.py index 56b5c56..23f011c 100644 --- a/clusterview/opengl_widget.py +++ b/clusterview/opengl_widget.py @@ -261,6 +261,21 @@ def box_hit(tx, ty, x1, y1, x2, y2): ty <= y1 and ty >= y2) + # The box in this case started from the top right + if x1 > x2 and y1 < y2: + return (tx <= x1 and + tx >= x2 and + ty >= y1 and + ty <= y2) + + # The box in this case started from the bottom left + if x1 < x2 and y1 > y2: + return (tx >= x1 and + tx <= x2 and + ty <= y1 and + ty >= y2) + + # Normal condition: Box starts from the top left return (tx >= x1 and tx <= x2 and ty >= y1 and