From 3aa361910ce50e5119600413254fc65b80bd365d Mon Sep 17 00:00:00 2001 From: Nils <> Date: Sat, 18 Jul 2020 20:08:45 +0200 Subject: [PATCH] Set selection z factor to a high value, stretchX selection --- qtgui/cursor.py | 12 +++++++++++- qtgui/scorescene.py | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qtgui/cursor.py b/qtgui/cursor.py index a669295..21ac3e2 100644 --- a/qtgui/cursor.py +++ b/qtgui/cursor.py @@ -149,7 +149,7 @@ class Playhead(QtWidgets.QGraphicsLineItem): self.setFlags(QtWidgets.QGraphicsItem.ItemIsMovable) self.setCursor(QtCore.Qt.SizeHorCursor) self.setAcceptedMouseButtons(QtCore.Qt.LeftButton) - self.setZValue(90) + self.setZValue(90) #This is relative to the parent, which is the scene. #self.parentScoreScene.parentView.verticalScrollBar().valueChanged.connect(self.setLineToWindowHeigth) #self.hide() #self.maxHeight = QtWidgets.QDesktopWidget().geometry().height() #we really hope the screen resolution does not change during the session. @@ -226,15 +226,25 @@ class Selection(QtWidgets.QGraphicsRectItem): self.invalidBrush = QtGui.QBrush(QtGui.QColor("grey")) self.invalidBrush.setStyle(QtCore.Qt.DiagCrossPattern) + self._tupleOfCursorExportObjects = None #cache for stretchX + self.setPen(pen) self.setOpacity(0.2) + self.setZValue(95) #Below playback cursor, but pretty high. This is relative to the parent, which is the scene. self.setEnabled(False) api.callbacks.setSelection.append(self.setSelection) def boundingRect(self, *args): return oneRectToReturnThemAll + def stretchXCoordinates(self, factor): + """Reposition the items on the X axis. + Call goes through all parents/children, starting from ScoreView._stretchXCoordinates. + Docstring there.""" + self.setSelection(self._tupleOfCursorExportObjects) + def setSelection(self, tupleOfCursorExportObjects): + self._tupleOfCursorExportObjects = tupleOfCursorExportObjects if tupleOfCursorExportObjects: validSelection, topleftCursorObject, bottomRightCursorObject = tupleOfCursorExportObjects if validSelection: diff --git a/qtgui/scorescene.py b/qtgui/scorescene.py index ec8a1bc..35455d6 100644 --- a/qtgui/scorescene.py +++ b/qtgui/scorescene.py @@ -314,6 +314,7 @@ class GuiScore(QtWidgets.QGraphicsScene): self.conductor.stretchXCoordinates(factor) self.cursor.setX(self.cursor.pos().x() * factor) self.playhead.setX(self.playhead.pos().x() * factor) + self.selection.stretchXCoordinates(factor) for track in self.tracks.values(): track.stretchXCoordinates(factor)