|
|
@ -69,7 +69,8 @@ class _VerticalPianoScene(QtWidgets.QGraphicsScene): |
|
|
|
self.parentView = parentView |
|
|
|
#Set color, otherwise it will be transparent in window managers or wayland that want that. |
|
|
|
self.backColor = QtGui.QColor() |
|
|
|
self.backColor.setNamedColor("#fdfdff") |
|
|
|
#self.backColor.setNamedColor("#fdfdff") |
|
|
|
self.backColor.setNamedColor("#999999") #grey |
|
|
|
self.setBackgroundBrush(self.backColor) |
|
|
|
|
|
|
|
self.linesHorizontal = [] |
|
|
@ -125,7 +126,7 @@ class _VerticalPianoScene(QtWidgets.QGraphicsScene): |
|
|
|
bk.setPos(0, (127-i) * STAFFLINEGAP) |
|
|
|
|
|
|
|
#Various purpose color keys. They are opaque and are on top of white/black keys |
|
|
|
ck = ColorKey(self, QtGui.QColor("cyan")) |
|
|
|
ck = ColorKey(self, QtGui.QColor("cyan"), blackKey) |
|
|
|
self.addItem(ck) |
|
|
|
self.colorKeys[i] = ck |
|
|
|
ck.setPos(0, (127-i) * STAFFLINEGAP) |
|
|
@ -140,7 +141,7 @@ class _VerticalPianoScene(QtWidgets.QGraphicsScene): |
|
|
|
numberLabel = NumberLabel(self, 127-i) |
|
|
|
self.addItem(numberLabel) |
|
|
|
self.numberLabels.append(numberLabel) #index is pitch |
|
|
|
numberLabel.setPos(0, i * STAFFLINEGAP + 2) |
|
|
|
numberLabel.setPos(3, i * STAFFLINEGAP + 2) |
|
|
|
numberLabel.setZValue(10) |
|
|
|
|
|
|
|
self.numberLabels.reverse() |
|
|
@ -196,12 +197,11 @@ class _VerticalPianoScene(QtWidgets.QGraphicsScene): |
|
|
|
if keyPitch in instrumentStatus["keySwitches"]: |
|
|
|
opcode, keyswitchLabel = instrumentStatus["keySwitches"][keyPitch] |
|
|
|
self.numberLabels[keyPitch].setLabel(keyswitchLabel) |
|
|
|
keyObject.setBrush(QtGui.QColor("red")) |
|
|
|
elif keyPitch in instrumentStatus["playableKeys"]: |
|
|
|
keyObject.setBrush(QtGui.QColor("orange")) |
|
|
|
else: |
|
|
|
#self.numberLabels[keyPitch].hide() |
|
|
|
keyObject.hide() |
|
|
|
#keyObject.hide() |
|
|
|
keyObject.setPlayable(keyPitch in instrumentStatus["playableKeys"]) |
|
|
|
|
|
|
|
def selectedInstrumentChanged(self, instrumentStatus, instrumentData): |
|
|
|
"""GUI click to different instrument. The arguments are cached GUI data |
|
|
@ -322,20 +322,40 @@ class Highlight(QtWidgets.QGraphicsRectItem): |
|
|
|
|
|
|
|
|
|
|
|
class ColorKey(QtWidgets.QGraphicsRectItem): |
|
|
|
def __init__(self, parentGrid, color:QtGui.QColor): |
|
|
|
def __init__(self, parentGrid, color:QtGui.QColor, blackKey:bool): |
|
|
|
super().__init__(0, 0, WIDTH, STAFFLINEGAP) #x, y, w, h |
|
|
|
self.setEnabled(False) #Not clickable, still visible. |
|
|
|
self.setAcceptedMouseButtons(QtCore.Qt.NoButton) |
|
|
|
self.setFlag(QtWidgets.QGraphicsItem.ItemIgnoresParentOpacity, True) |
|
|
|
self.setBrush(color) |
|
|
|
self.setOpacity(0.2) #just a tint |
|
|
|
self.blackKey = blackKey |
|
|
|
self.hide() |
|
|
|
|
|
|
|
def setPlayable(self, state:bool): |
|
|
|
c = QtGui.QColor() |
|
|
|
if state: |
|
|
|
if self.blackKey: |
|
|
|
c.setNamedColor("#0c0c0c") |
|
|
|
else: |
|
|
|
c.setNamedColor("#fdfdff") |
|
|
|
else: |
|
|
|
#Only if the instrument is activated. Not loaded instruments are just dark black and white |
|
|
|
if self.blackKey: |
|
|
|
c.setNamedColor("#444444") |
|
|
|
else: |
|
|
|
c.setNamedColor("#999999") |
|
|
|
self.setBrush(c) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BlackKey(QtWidgets.QGraphicsRectItem): |
|
|
|
def __init__(self, parentGrid): |
|
|
|
super().__init__(0, 0, WIDTH, STAFFLINEGAP) #x, y, w, h |
|
|
|
self.parentGrid = parentGrid |
|
|
|
self.setPen(QtGui.QPen(QtCore.Qt.NoPen)) |
|
|
|
self.setBrush(QtGui.QColor("black")) |
|
|
|
c = QtGui.QColor() |
|
|
|
c.setNamedColor("#444444") |
|
|
|
self.setBrush(c) |
|
|
|
self.setOpacity(1.0) |
|
|
|
self.setEnabled(False) |
|
|
|
self.setAcceptedMouseButtons(QtCore.Qt.NoButton) |
|
|
|