Browse Source

Set background colors to prevent transparent edit areas

master
Nils 4 years ago
parent
commit
f209ba6406
  1. 56
      qtgui/pattern_grid.py
  2. 33
      qtgui/songeditor.py
  3. 5
      qtgui/timeline.py

56
qtgui/pattern_grid.py

@ -66,6 +66,10 @@ class PatternGrid(QtWidgets.QGraphicsScene):
self._zoomFactor = 1 # no save. We don't keep a qt config. self._zoomFactor = 1 # no save. We don't keep a qt config.
#Set color, otherwise it will be transparent in window managers or wayland that want that.
self.backColor = QtGui.QColor(55, 61, 69)
self.setBackgroundBrush(self.backColor)
role = QtGui.QPalette.BrightText role = QtGui.QPalette.BrightText
self.textColor = self.parentView.parentMainWindow.fPalBlue.color(role) self.textColor = self.parentView.parentMainWindow.fPalBlue.color(role)
self.labelColor = QtGui.QColor("black") #save for new step self.labelColor = QtGui.QColor("black") #save for new step
@ -187,7 +191,7 @@ class PatternGrid(QtWidgets.QGraphicsScene):
to trigger a redraw even during the track change. to trigger a redraw even during the track change.
""" """
if force or self.parentView.parentMainWindow.currentTrackId == exportDict["id"]: if force or self.parentView.parentMainWindow.currentTrackId == exportDict["id"]:
self.trackName.setText(exportDict["sequencerInterface"]["name"]) self.trackName.setText(exportDict["sequencerInterface"]["name"])
self.trackName.show() self.trackName.show()
c = QtGui.QColor(exportDict["color"]) c = QtGui.QColor(exportDict["color"])
@ -306,24 +310,24 @@ class PatternGrid(QtWidgets.QGraphicsScene):
potentialStep = self.itemAt(event.scenePos().x(), event.scenePos().y(), self.parentView.transform()) potentialStep = self.itemAt(event.scenePos().x(), event.scenePos().y(), self.parentView.transform())
potentialSteps = [st for st in self.items(event.scenePos()) if type(st) is Step] potentialSteps = [st for st in self.items(event.scenePos()) if type(st) is Step]
#An over-long active step is stacked before the actual step. We need to either find the lowest #An over-long active step is stacked before the actual step. We need to either find the lowest
#or the one furthest to the right because active notes can't have negative duration #or the one furthest to the right because active notes can't have negative duration
if potentialSteps: if potentialSteps:
potentialStep = max(potentialSteps, key=lambda ls: ls.column) potentialStep = max(potentialSteps, key=lambda ls: ls.column)
else: else:
potentialStep = None potentialStep = None
listOfLabelsAndFunctions = [ listOfLabelsAndFunctions = [
(QtCore.QCoreApplication.translate("EventContextMenu", "Invert Steps"), lambda: api.patternInvertSteps(trackId)), (QtCore.QCoreApplication.translate("EventContextMenu", "Invert Steps"), lambda: api.patternInvertSteps(trackId)),
(QtCore.QCoreApplication.translate("EventContextMenu", "All Steps On"), lambda: api.patternOnAllSteps(trackId)), (QtCore.QCoreApplication.translate("EventContextMenu", "All Steps On"), lambda: api.patternOnAllSteps(trackId)),
(QtCore.QCoreApplication.translate("EventContextMenu", "All Steps Off"), lambda: api.patternOffAllSteps(trackId)), (QtCore.QCoreApplication.translate("EventContextMenu", "All Steps Off"), lambda: api.patternOffAllSteps(trackId)),
] ]
if potentialStep: if potentialStep:
listOfLabelsAndFunctions.insert(0, (QtCore.QCoreApplication.translate("EventContextMenu", "Repeat to step {} incl. to fill Row").format(potentialStep.column+1), lambda: api.patternRowRepeatFromStep(trackId, potentialStep.row, potentialStep.column))) listOfLabelsAndFunctions.insert(0, (QtCore.QCoreApplication.translate("EventContextMenu", "Repeat to step {} incl. to fill Row").format(potentialStep.column+1), lambda: api.patternRowRepeatFromStep(trackId, potentialStep.row, potentialStep.column)))
listOfLabelsAndFunctions.insert(0, (QtCore.QCoreApplication.translate("EventContextMenu", "Clear Row"), lambda: api.patternClearRow(trackId, potentialStep.row))) listOfLabelsAndFunctions.insert(0, (QtCore.QCoreApplication.translate("EventContextMenu", "Clear Row"), lambda: api.patternClearRow(trackId, potentialStep.row)))
listOfLabelsAndFunctions.insert(0, (QtCore.QCoreApplication.translate("EventContextMenu", "Invert Row"), lambda: api.patternInvertRow(trackId, potentialStep.row))) listOfLabelsAndFunctions.insert(0, (QtCore.QCoreApplication.translate("EventContextMenu", "Invert Row"), lambda: api.patternInvertRow(trackId, potentialStep.row)))
for text, function in listOfLabelsAndFunctions: for text, function in listOfLabelsAndFunctions:
if function is None: if function is None:
@ -353,17 +357,17 @@ class PatternGrid(QtWidgets.QGraphicsScene):
elif QtWidgets.QApplication.keyboardModifiers() == QtCore.Qt.AltModifier: elif QtWidgets.QApplication.keyboardModifiers() == QtCore.Qt.AltModifier:
potentialStep = self.itemAt(event.scenePos().x(), event.scenePos().y(), self.parentView.transform()) potentialStep = self.itemAt(event.scenePos().x(), event.scenePos().y(), self.parentView.transform())
if type(potentialStep) is Step: if type(potentialStep) is Step:
trackId = self.parentView.parentMainWindow.currentTrackId trackId = self.parentView.parentMainWindow.currentTrackId
if event.delta() > 0: if event.delta() > 0:
delta = 2 delta = 2
else: else:
delta = -2 delta = -2
api.patternRowChangeVelocity(trackId, potentialStep.row, delta) api.patternRowChangeVelocity(trackId, potentialStep.row, delta)
self.showVelocities() #removed in self.keyReleaseEvent self.showVelocities() #removed in self.keyReleaseEvent
event.accept() event.accept()
else: else:
event.ignore() event.ignore()
super().wheelEvent(event) super().wheelEvent(event)
else: else:
event.ignore() event.ignore()
super().wheelEvent(event) super().wheelEvent(event)
@ -371,10 +375,10 @@ class PatternGrid(QtWidgets.QGraphicsScene):
def keyReleaseEvent(self, event): def keyReleaseEvent(self, event):
"""Complementary for wheelEvent with Alt to change row velocity. """Complementary for wheelEvent with Alt to change row velocity.
It is hard to detect the Alt key. We just brute force because there are not many It is hard to detect the Alt key. We just brute force because there are not many
keyPresses in Patroneo at all.""" keyPresses in Patroneo at all."""
self.hideVelocities() self.hideVelocities()
event.ignore() event.ignore()
super().keyReleaseEvent(event) super().keyReleaseEvent(event)
def _zoom(self, event): def _zoom(self, event):
if 0.1 < self._zoomFactor < 5: if 0.1 < self._zoomFactor < 5:
@ -764,13 +768,13 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
def __init__(self, parentItem): def __init__(self, parentItem):
super().__init__() super().__init__()
self.parentItem = parentItem self.parentItem = parentItem
self.spinBox = QtWidgets.QSpinBox() self.spinBox = QtWidgets.QSpinBox()
#self.spinBox.setFrame(True) #self.spinBox.setFrame(True)
self.spinBox.setMinimum(0) self.spinBox.setMinimum(0)
self.spinBox.setMaximum(127) self.spinBox.setMaximum(127)
self.spinBox.stepBy = self.stepBy self.spinBox.stepBy = self.stepBy
#self.spinBox.setValue(0) #No init value. This is changed on active track callback #self.spinBox.setValue(0) #No init value. This is changed on active track callback
widget = QtWidgets.QWidget() widget = QtWidgets.QWidget()
layout = QtWidgets.QHBoxLayout() layout = QtWidgets.QHBoxLayout()
@ -789,7 +793,7 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
self.setWidget(widget) self.setWidget(widget)
self.spinBox.wheelEvent = self.spinBoxMouseWheelEvent self.spinBox.wheelEvent = self.spinBoxMouseWheelEvent
self.spinBox.valueChanged.connect(self.spinBoxValueChanged) self.spinBox.valueChanged.connect(self.spinBoxValueChanged)
self.spinBox.editingFinished.connect(self.spinBoxEditingFinished) self.spinBox.editingFinished.connect(self.spinBoxEditingFinished)
#self.spinBoxValueChanged() #Delay that. The engine Data is not ready yet. It will be sent by the callback #self.spinBoxValueChanged() #Delay that. The engine Data is not ready yet. It will be sent by the callback
@ -807,7 +811,7 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
exit() exit()
def spinBoxValueChanged(self): def spinBoxValueChanged(self):
self.label.setText(self.midiToNotename(self.spinBox.value())) self.label.setText(self.midiToNotename(self.spinBox.value()))
#self.parentItem.sendToEngine(callback=False) # results in a loop with callback, and in wrong data without. This is not the right place to implement immediate note feedback while editing is still going on. #self.parentItem.sendToEngine(callback=False) # results in a loop with callback, and in wrong data without. This is not the right place to implement immediate note feedback while editing is still going on.
def spinBoxEditingFinished(self): def spinBoxEditingFinished(self):
@ -827,13 +831,13 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
def spinBoxMouseWheelEvent(self, event): def spinBoxMouseWheelEvent(self, event):
"""We cannot use spinBoxValueChanged to send mousewheel scrolling pitch changing directly """We cannot use spinBoxValueChanged to send mousewheel scrolling pitch changing directly
to the engine while editing is still active. this results in signal loops and various to the engine while editing is still active. this results in signal loops and various
data corruptions. Fixing this would be far too much work. data corruptions. Fixing this would be far too much work.
You can either use the arrow keys and press enter, which triggers editingFinished. You can either use the arrow keys and press enter, which triggers editingFinished.
But here we intercept the mousewheel directly.""" But here we intercept the mousewheel directly."""
event.ignore() event.ignore()
QtWidgets.QSpinBox.wheelEvent(self.spinBox, event) #this changes to the new text and therefore the new value. Call BEFORE sendToEngine QtWidgets.QSpinBox.wheelEvent(self.spinBox, event) #this changes to the new text and therefore the new value. Call BEFORE sendToEngine
self.parentItem.sendToEngine(callback=False) self.parentItem.sendToEngine(callback=False)
#if event.angleDelta().y() > 0: #up #if event.angleDelta().y() > 0: #up
#else: #down #else: #down
@ -868,7 +872,7 @@ class Playhead(QtWidgets.QGraphicsLineItem):
class VelocityControls(QtWidgets.QWidget): class VelocityControls(QtWidgets.QWidget):
def __init__(self, mainWindow, patternScene): def __init__(self, mainWindow, patternScene):
super().__init__() super().__init__()
self.parentScene = patternScene self.parentScene = patternScene
self.mainWindow = mainWindow self.mainWindow = mainWindow

33
qtgui/songeditor.py

@ -40,6 +40,10 @@ class SongEditor(QtWidgets.QGraphicsScene):
super().__init__() super().__init__()
self.parentView = parentView self.parentView = parentView
#Set color, otherwise it will be transparent in window managers or wayland that want that.
self.backColor = QtGui.QColor(55, 61, 69)
self.setBackgroundBrush(self.backColor)
#Subitems #Subitems
self.playhead = Playhead(parentScene = self) self.playhead = Playhead(parentScene = self)
self.addItem(self.playhead) self.addItem(self.playhead)
@ -323,11 +327,11 @@ class TrackStructure(QtWidgets.QGraphicsRectItem):
position = self.scenePos2switchPosition(event.scenePos().x()) #measure number 0 based position = self.scenePos2switchPosition(event.scenePos().x()) #measure number 0 based
measuresPerGroup = self.parentScene.measuresPerGroupCache measuresPerGroup = self.parentScene.measuresPerGroupCache
offset = position % measuresPerGroup offset = position % measuresPerGroup
startMeasureForGroup = position - offset startMeasureForGroup = position - offset
endMeasureExclusive = startMeasureForGroup + measuresPerGroup endMeasureExclusive = startMeasureForGroup + measuresPerGroup
listOfLabelsAndFunctions = [ listOfLabelsAndFunctions = [
(QtCore.QCoreApplication.translate("SongStructure", "Insert empty group before this one").format(measuresPerGroup), lambda: api.insertSilence(howMany=measuresPerGroup, beforeMeasureNumber=startMeasureForGroup)), (QtCore.QCoreApplication.translate("SongStructure", "Insert empty group before this one").format(measuresPerGroup), lambda: api.insertSilence(howMany=measuresPerGroup, beforeMeasureNumber=startMeasureForGroup)),
(QtCore.QCoreApplication.translate("SongStructure", "Delete whole group").format(measuresPerGroup), lambda: api.deleteSwitches(howMany=measuresPerGroup, fromMeasureNumber=startMeasureForGroup)), (QtCore.QCoreApplication.translate("SongStructure", "Delete whole group").format(measuresPerGroup), lambda: api.deleteSwitches(howMany=measuresPerGroup, fromMeasureNumber=startMeasureForGroup)),
(QtCore.QCoreApplication.translate("SongStructure", "Duplicate whole group including measures"), lambda: api.duplicateSwitchGroup(startMeasureForGroup, endMeasureExclusive)), (QtCore.QCoreApplication.translate("SongStructure", "Duplicate whole group including measures"), lambda: api.duplicateSwitchGroup(startMeasureForGroup, endMeasureExclusive)),
(QtCore.QCoreApplication.translate("SongStructure", "Clear all group transpositions"), lambda: api.clearSwitchGroupTranspositions(startMeasureForGroup, endMeasureExclusive)), (QtCore.QCoreApplication.translate("SongStructure", "Clear all group transpositions"), lambda: api.clearSwitchGroupTranspositions(startMeasureForGroup, endMeasureExclusive)),
@ -524,6 +528,11 @@ class TrackLabelEditor(QtWidgets.QGraphicsScene):
self._cachedExportDictsInOrder = [] self._cachedExportDictsInOrder = []
#Set color, otherwise it will be transparent in window managers or wayland that want that.
self.backColor = QtGui.QColor(55, 61, 69)
self.backColor = QtGui.QColor(48, 53, 60)
self.setBackgroundBrush(self.backColor)
api.callbacks.numberOfTracksChanged.append(self.callback_numberOfTracksChanged) api.callbacks.numberOfTracksChanged.append(self.callback_numberOfTracksChanged)
api.callbacks.trackMetaDataChanged.append(self.callback_trackMetaDataChanged) api.callbacks.trackMetaDataChanged.append(self.callback_trackMetaDataChanged)
api.callbacks.exportCacheChanged.append(self.cacheExportDict) api.callbacks.exportCacheChanged.append(self.cacheExportDict)
@ -536,7 +545,7 @@ class TrackLabelEditor(QtWidgets.QGraphicsScene):
"""This is not for the initial track creation, only for later changes""" """This is not for the initial track creation, only for later changes"""
self.tracks[exportDict["id"]].update(exportDict) self.tracks[exportDict["id"]].update(exportDict)
def callback_numberOfTracksChanged(self, exportDictList): def callback_numberOfTracksChanged(self, exportDictList):
toDelete = set(self.tracks.keys()) toDelete = set(self.tracks.keys())
self._cachedExportDictsInOrder = exportDictList self._cachedExportDictsInOrder = exportDictList
@ -603,13 +612,13 @@ class TrackLabelEditor(QtWidgets.QGraphicsScene):
a.triggered.connect(function) a.triggered.connect(function)
#Add a submenu for merge/cop #Add a submenu for merge/cop
mergeMenu = menu.addMenu(QtCore.QCoreApplication.translate("TrackLabelContext", "Merge/Copy Measure-Structure from")) mergeMenu = menu.addMenu(QtCore.QCoreApplication.translate("TrackLabelContext", "Merge/Copy Measure-Structure from"))
def createCopyMergeLambda(srcId): def createCopyMergeLambda(srcId):
return lambda: api.trackMergeCopyFrom(srcId, exportDict["id"]) return lambda: api.trackMergeCopyFrom(srcId, exportDict["id"])
for sourceDict in self._cachedExportDictsInOrder: for sourceDict in self._cachedExportDictsInOrder:
a = QtWidgets.QAction(sourceDict["sequencerInterface"]["name"], mergeMenu) a = QtWidgets.QAction(sourceDict["sequencerInterface"]["name"], mergeMenu)
mergeMenu.addAction(a) mergeMenu.addAction(a)
mergeCommand = createCopyMergeLambda(sourceDict["id"]) mergeCommand = createCopyMergeLambda(sourceDict["id"])
@ -619,18 +628,18 @@ class TrackLabelEditor(QtWidgets.QGraphicsScene):
#Add a submenu for pattern merge/copy #Add a submenu for pattern merge/copy
copyMenu = menu.addMenu(QtCore.QCoreApplication.translate("TrackLabelContext", "Replace Pattern with")) copyMenu = menu.addMenu(QtCore.QCoreApplication.translate("TrackLabelContext", "Replace Pattern with"))
def replacePatternWithLambda(srcId): def replacePatternWithLambda(srcId):
return lambda: api.trackPatternReplaceFrom(srcId, exportDict["id"]) return lambda: api.trackPatternReplaceFrom(srcId, exportDict["id"])
for sourceDict in self._cachedExportDictsInOrder: for sourceDict in self._cachedExportDictsInOrder:
a = QtWidgets.QAction(sourceDict["sequencerInterface"]["name"], copyMenu) a = QtWidgets.QAction(sourceDict["sequencerInterface"]["name"], copyMenu)
copyMenu.addAction(a) copyMenu.addAction(a)
mergeCommand = replacePatternWithLambda(sourceDict["id"]) mergeCommand = replacePatternWithLambda(sourceDict["id"])
if sourceDict["id"] == exportDict["id"]: if sourceDict["id"] == exportDict["id"]:
a.setEnabled(False) a.setEnabled(False)
a.triggered.connect(mergeCommand) a.triggered.connect(mergeCommand)
pos = QtGui.QCursor.pos() pos = QtGui.QCursor.pos()
pos.setY(pos.y() + 5) pos.setY(pos.y() + 5)
self.parentView.parentMainWindow.setFocus() self.parentView.parentMainWindow.setFocus()

5
qtgui/timeline.py

@ -33,6 +33,11 @@ class Timeline(QtWidgets.QGraphicsScene):
self.parentView = parentView self.parentView = parentView
self.addItem(TimelineRect(parentScene=self)) self.addItem(TimelineRect(parentScene=self))
#Set color, otherwise it will be transparent in window managers or wayland that want that.
self.backColor = QtGui.QColor(55, 61, 69)
self.setBackgroundBrush(self.backColor)
class TimelineRect(QtWidgets.QGraphicsRectItem): class TimelineRect(QtWidgets.QGraphicsRectItem):
"""Shows information about song progression. """Shows information about song progression.

Loading…
Cancel
Save