Browse Source

Better piano colors

master
Nils 8 months ago
parent
commit
c1a71c28b5
  1. 30
      qtgui/horizontalpiano.py
  2. 38
      qtgui/verticalpiano.py

30
qtgui/horizontalpiano.py

@ -73,7 +73,7 @@ class _HorizontalPianoScene(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("#999999") #grey
self.setBackgroundBrush(self.backColor)
self.linesHorizontal = []
@ -336,8 +336,6 @@ class BlackKey(QtWidgets.QGraphicsRectItem):
self.decorationOverlay.setEnabled(False)
self.decorationOverlay.setAcceptedMouseButtons(QtCore.Qt.NoButton)
self.decorationOverlay.setFlag(QtWidgets.QGraphicsItem.ItemIgnoresParentOpacity, True)
self.decorationOverlay.setOpacity(0.2) #just a tint
self.decorationOverlay.hide()
self.decorationOverlay.setParentItem(self)
self.highlight = QtWidgets.QGraphicsRectItem(0, 0, WIDTH * 0.8, HEIGHT) #x, y, w, h
@ -349,17 +347,21 @@ class BlackKey(QtWidgets.QGraphicsRectItem):
self.highlight.hide()
self.highlight.setParentItem(self)
def setPlayable(self, state:bool):
c = QtGui.QColor()
if state:
self.decorationOverlay.show()
self.decorationOverlay.setBrush(QtGui.QColor("orange"))
c.setNamedColor("#0c0c0c")
else:
self.decorationOverlay.hide()
#Only if the instrument is activated. Not loaded instruments are just dark black and white
c.setNamedColor("#444444")
self.setBrush(c)
def setKeySwitch(self, state:bool):
if state:
self.decorationOverlay.show()
self.decorationOverlay.setBrush(QtGui.QColor("red"))
self.decorationOverlay.setBrush(QtGui.QColor("orange"))
else:
self.decorationOverlay.hide()
@ -384,9 +386,6 @@ class WhiteKey(QtWidgets.QGraphicsRectItem):
self.decorationOverlay.setEnabled(False)
self.decorationOverlay.setAcceptedMouseButtons(QtCore.Qt.NoButton)
self.decorationOverlay.setFlag(QtWidgets.QGraphicsItem.ItemIgnoresParentOpacity, True)
self.decorationOverlay.setOpacity(0.2) #just a tint
self.decorationOverlay.hide()
self.highlight = QtWidgets.QGraphicsRectItem(0, 0, WIDTH, HEIGHT) #x, y, w, h
self.highlight.setParentItem(self)
@ -398,18 +397,19 @@ class WhiteKey(QtWidgets.QGraphicsRectItem):
self.highlight.hide()
def setPlayable(self, state:bool):
c = QtGui.QColor()
if state:
self.decorationOverlay.show()
self.decorationOverlay.setBrush(QtGui.QColor("orange"))
c.setNamedColor("#fdfdff")
else:
self.decorationOverlay.hide()
#Only if the instrument is activated. Not loaded instruments are just dark black and white
c.setNamedColor("#999999")
self.setBrush(c)
def setKeySwitch(self, state:bool):
if state:
self.decorationOverlay.show()
self.decorationOverlay.setBrush(QtGui.QColor("red"))
self.decorationOverlay.setBrush(QtGui.QColor("orange"))
else:
self.decorationOverlay.hide()

38
qtgui/verticalpiano.py

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

Loading…
Cancel
Save