aboutsummaryrefslogtreecommitdiffstats
path: root/grc
diff options
context:
space:
mode:
authorDavid Winter <david.winter@analog.com>2021-07-07 14:19:19 +0200
committermormj <34754695+mormj@users.noreply.github.com>2021-07-09 11:43:26 -0400
commitb6f2120e84b3b541a636420ac2af8d2d86f091ac (patch)
treea33838574c43af645856e376861de4831d3ac06e /grc
parentclang-tidy: run-clang-tidy with default checks on gr-soapy (diff)
downloadgnuradio-b6f2120e84b3b541a636420ac2af8d2d86f091ac.tar.xz
gnuradio-b6f2120e84b3b541a636420ac2af8d2d86f091ac.zip
grc: Fix desync when dragging block
This commit fixes what's basically a broken numerical integration in the block dragging code, leading to a position desynchronization between mouse pointer and block. Signed-off-by: David Winter <david.winter@analog.com>
Diffstat (limited to 'grc')
-rw-r--r--grc/gui/canvas/flowgraph.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/grc/gui/canvas/flowgraph.py b/grc/gui/canvas/flowgraph.py
index 61bf96378..cb63f578a 100644
--- a/grc/gui/canvas/flowgraph.py
+++ b/grc/gui/canvas/flowgraph.py
@@ -803,11 +803,17 @@ class FlowGraph(CoreFlowgraph, Drawable):
x, y = coordinate
if not self.drawing_area.ctrl_mask:
X, Y = self.coordinate
- dX, dY = int(x - X), int(y - Y)
- active = Actions.TOGGLE_SNAP_TO_GRID.get_active() or self.drawing_area.mod1_mask
- if not active or abs(dX) >= Constants.CANVAS_GRID_SIZE or abs(dY) >= Constants.CANVAS_GRID_SIZE:
+ dX, dY = x - X, y - Y
+
+ if Actions.TOGGLE_SNAP_TO_GRID.get_active() or self.drawing_area.mod1_mask:
+ dX, dY = int(round(dX / Constants.CANVAS_GRID_SIZE)), int(round(dY / Constants.CANVAS_GRID_SIZE))
+ dX, dY = dX * Constants.CANVAS_GRID_SIZE, dY * Constants.CANVAS_GRID_SIZE
+ else:
+ dX, dY = int(round(dX)), int(round(dY))
+
+ if dX != 0 or dY != 0:
self.move_selected((dX, dY))
- self.coordinate = (x, y)
+ self.coordinate = (X+dX, Y+dY)
redraw = True
return redraw