Browse Source

Make sure tracks and groups are in front of the others while repositioning them

master
Nils 2 years ago
parent
commit
35079aea79
  1. 6
      qtgui/songeditor.py

6
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)

Loading…
Cancel
Save