From 67db5f77cd5c68d591b3bb696b6fe0ae336a924a Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Wed, 16 Mar 2016 15:59:49 +0100 Subject: [PATCH] scanwidget: lmb axis drag (9e6203c) --- artiq/gui/scanwidget.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/artiq/gui/scanwidget.py b/artiq/gui/scanwidget.py index 77715321e..9b6a996da 100644 --- a/artiq/gui/scanwidget.py +++ b/artiq/gui/scanwidget.py @@ -39,7 +39,7 @@ class ScanWidget(QtWidgets.QSlider): self._start, self._stop, self._num = None, None, None self._axisView, self._sliderView = None, None - self._offset, self._pressed = None, None + self._offset, self._pressed, self._dragLeft = None, None, None def contextMenuEvent(self, ev): self.menu.popup(ev.globalPos()) @@ -145,23 +145,27 @@ class ScanWidget(QtWidgets.QSlider): elif self._hitHandle(ev.pos(), self._start): self._pressed = "start" else: - self._pressed = None + self._pressed = "axis" + self._offset = ev.x() + self._dragLeft = self._axisView[0] def mouseMoveEvent(self, ev): if not self._pressed: ev.ignore() return - val = self._pixelToAxis(ev.pos().x() - self._offset) if self._pressed == "stop": - self._stop = val + self._stop = self._pixelToAxis(ev.x() - self._offset) self.update() if self.hasTracking(): - self.stopChanged.emit(val) + self.stopChanged.emit(self._stop) elif self._pressed == "start": - self._start = val + self._start = self._pixelToAxis(ev.x() - self._offset) self.update() if self.hasTracking(): - self.startChanged.emit(val) + self.startChanged.emit(self._start) + elif self._pressed == "axis": + self._setView(self._dragLeft + ev.x() - self._offset, + self._axisView[1]) def mouseReleaseEvent(self, ev): QtWidgets.QSlider.mouseReleaseEvent(self, ev)