|
|
@ -124,7 +124,7 @@ class _VerticalPianoScene(QtWidgets.QGraphicsScene): |
|
|
|
self.addItem(hline) |
|
|
|
hline.setPos(0, i * STAFFLINEGAP) |
|
|
|
hline.setEnabled(False) |
|
|
|
hline.setAcceptedMouseButtons(QtCore.Qt.NoButton) |
|
|
|
hline.setAcceptedMouseButtons(QtCore.Qt.NoButton) #Disabled items discard the mouse event unless mouseButtons are not accepted |
|
|
|
self.linesHorizontal.append(hline) |
|
|
|
|
|
|
|
blackKey = i % 12 in (1, 3, 6, 8, 10) |
|
|
@ -155,15 +155,19 @@ class _VerticalPianoScene(QtWidgets.QGraphicsScene): |
|
|
|
|
|
|
|
self.numberLabels.reverse() |
|
|
|
|
|
|
|
|
|
|
|
self.fakeDeactivationOverlay = QtWidgets.QGraphicsRectItem(0,0,MAX_DURATION,SCOREHEIGHT) |
|
|
|
|
|
|
|
self.fakeDeactivationOverlay.setBrush(QtGui.QColor("black")) |
|
|
|
self.fakeDeactivationOverlay.setOpacity(0.6) |
|
|
|
self.fakeDeactivationOverlay.setEnabled(False) |
|
|
|
self.fakeDeactivationOverlay.setAcceptedMouseButtons(QtCore.Qt.NoButton) #Disabled items discard the mouse event unless mouseButtons are not accepted |
|
|
|
self.addItem(self.fakeDeactivationOverlay) |
|
|
|
self.fakeDeactivationOverlay.setPos(0,0) |
|
|
|
self.fakeDeactivationOverlay.show() |
|
|
|
#Keyboard Creation Done |
|
|
|
|
|
|
|
|
|
|
|
api.callbacks.instrumentMidiNoteOnActivity.append(self.highlightNoteOn) |
|
|
|
api.callbacks.instrumentMidiNoteOffActivity.append(self.highlightNoteOff) |
|
|
|
api.callbacks.instrumentStatusChanged.append(self.instrumentStatusChanged) |
|
|
@ -177,6 +181,7 @@ class _VerticalPianoScene(QtWidgets.QGraphicsScene): |
|
|
|
def instrumentStatusChanged(self, instrumentStatus:dict): |
|
|
|
"""GUI callback. Data is live""" |
|
|
|
#Is this for us? |
|
|
|
|
|
|
|
if instrumentStatus and self._selectedInstrument and not instrumentStatus["idKey"] == self._selectedInstrument[0]["idKey"]: |
|
|
|
return |
|
|
|
#else: |
|
|
@ -204,11 +209,18 @@ class _VerticalPianoScene(QtWidgets.QGraphicsScene): |
|
|
|
keyObject.hide() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def selectedInstrumentChanged(self, instrumentStatus, instrumentData): |
|
|
|
"""GUI click to different instrument. The arguments are cached GUI data""" |
|
|
|
self._selectedInstrument = (instrumentStatus, instrumentData) |
|
|
|
self.instrumentStatusChanged(instrumentStatus) |
|
|
|
"""GUI click to different instrument. The arguments are cached GUI data |
|
|
|
|
|
|
|
If a library is clicked, and not an instrument, both parameters will be None. |
|
|
|
""" |
|
|
|
if instrumentStatus is None: |
|
|
|
self._selectedInstrument = None |
|
|
|
self.clearVerticalPiano() |
|
|
|
self.fakeDeactivationOverlay.show() |
|
|
|
else: |
|
|
|
self._selectedInstrument = (instrumentStatus, instrumentData) |
|
|
|
self.instrumentStatusChanged(instrumentStatus) |
|
|
|
|
|
|
|
def highlightNoteOn(self, idKey:tuple, pitch:int, velocity:int): |
|
|
|
highlight = self.highlights[pitch] |
|
|
@ -230,6 +242,9 @@ class _VerticalPianoScene(QtWidgets.QGraphicsScene): |
|
|
|
self._play(event) |
|
|
|
super().mousePressEvent(event) |
|
|
|
|
|
|
|
def wheelEvent(self, event): |
|
|
|
event.ignore() #let the view handle it, for the scrollbar |
|
|
|
|
|
|
|
def _off(self): |
|
|
|
if self._selectedInstrument and not self._lastPlayPitch is None: |
|
|
|
status, data = self._selectedInstrument |
|
|
|