Browse Source

various small improvements

master
Nils 2 years ago
parent
commit
340a065dec
  1. 3
      qtgui/mainwindow.py
  2. 6
      qtgui/selectedinstrumentcontroller.py
  3. 25
      qtgui/verticalpiano.py
  4. 1
      template/calfbox/py/nullbox.py

3
qtgui/mainwindow.py

@ -202,7 +202,8 @@ class MainWindow(TemplateMainWindow):
entry for a different instrument. This is purely a GUI function. This functions
relays the change to other widgets, except the above mentioned controller.
This only triggers for actual instruments, not a click on a library.
If a library is clicked, and not an instrument, both parameters will be None.
The pianos use this to switch off.
"""
self.verticalPiano.pianoScene.selectedInstrumentChanged(instrumentStatus, instrumentData)

6
qtgui/selectedinstrumentcontroller.py

@ -75,9 +75,13 @@ class SelectedInstrumentController(object):
self.ui.details_groupBox.setTitle(metadata["name"])
self.ui.info_label.setText(self._metadataToDescriptionLabel(metadata))
#Inform other widgets (but not recursively ourselves) that we clicked on no instrument.
#e.g. to switch off the gui keyboards.
self.parentMainWindow.selectedInstrumentChanged(None, None)
def _metadataToDescriptionLabel(self, metadata:dict)->str:
"""Can work with instruments and libraries alike"""

25
qtgui/verticalpiano.py

@ -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

1
template/calfbox/py/nullbox.py

@ -21,6 +21,7 @@ class NullCalfbox(str): #iterable
self.patch = {i:(0, "nullbox") for i in range(1,17)} #catches status().patch
self.frame_rate = 48000
self.frame = 0
self.gain = 0
def __getattr__(self, *args, **kwargs):
return __class__()

Loading…
Cancel
Save