From 35079aea79fb66d7702e0d05c2b2e21c38be8520 Mon Sep 17 00:00:00 2001 From: Nils <> Date: Wed, 5 Jan 2022 15:48:02 +0100 Subject: [PATCH] Make sure tracks and groups are in front of the others while repositioning them --- qtgui/songeditor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qtgui/songeditor.py b/qtgui/songeditor.py index 719a1ba..f87aff9 100644 --- a/qtgui/songeditor.py +++ b/qtgui/songeditor.py @@ -1218,6 +1218,7 @@ class TrackLabel(QtWidgets.QGraphicsRectItem): return pos def mouseMoveEvent(self, event): + """Move track up and down. Started by mousePressEvent and finalized by mouseReleaseEvent""" if self._cursorPosOnMoveStart: self.parentTrackLabel.setY(max(0, event.scenePos().y())) #super().mouseMoveEvent(event) #with this the sync between cursor and item is off. @@ -1227,7 +1228,7 @@ class TrackLabel(QtWidgets.QGraphicsRectItem): We don't need to worry about the user just releasing the mouse on this item""" self._posBeforeMove = self.parentTrackLabel.pos() self._cursorPosOnMoveStart = QtGui.QCursor.pos() - + self.parentTrackLabel.setZValue(self.parentTrackLabel.zValue()+1) #in front of other tracks self._lineCursor = self.parentTrackLabel.lineEdit.cursor() self.parentTrackLabel.mousePressEvent(event) #super().mousePressEvent(event) #with this in mouseMoveEvent does not work. IIRC because we do not set the movableFlag @@ -1235,6 +1236,7 @@ class TrackLabel(QtWidgets.QGraphicsRectItem): def mouseReleaseEvent(self, event): newIndex = self.yPos2trackIndex(self.parentTrackLabel.y()) #we need to save that first, right after this we reset the position self.parentTrackLabel.setPos(self._posBeforeMove) #In case the block was moved to a position where no track is (below the tracks) we just reset the graphics before anything happens. The user will never see this really + self.parentTrackLabel.setZValue(self.parentTrackLabel.zValue()-1) #revert mousePressEvent's +1 self._posBeforeMove = None self._cursorPosOnMoveStart = None api.moveTrack(self.parentTrackLabel.exportDict["id"], newIndex) @@ -1426,12 +1428,14 @@ class GroupLabel(QtWidgets.QGraphicsRectItem): We don't need to worry about the user just releasing the mouse on this item""" self._posBeforeMove = self.parentGroupLabel.pos() self._cursorPosOnMoveStart = QtGui.QCursor.pos() + self.parentGroupLabel.setZValue(self.parentGroupLabel.zValue()+1) #in front of other groups #self.parentGroupLabel.mousePressEvent(event) #This blocks mouseMOveEvent #super().mousePressEvent(event) #with this in mouseMoveEvent does not work. IIRC because we do not set the movableFlag def mouseReleaseEvent(self, event): newIndex = self.yPos2trackIndex(self.parentGroupLabel.y()) #we need to save that first, right after this we reset the position self.parentGroupLabel.setPos(self._posBeforeMove) #In case the block was moved to a position where no track is (below the tracks) we just reset the graphics before anything happens. The user will never see this really + self.parentGroupLabel.setZValue(self.parentGroupLabel.zValue()-1) #revert mousePressEvent's + 1 self._posBeforeMove = None self._cursorPosOnMoveStart = None api.moveGroup(self.parentGroupLabel.group, newIndex)