Rework song editor context menus: Streamline groups, add duplicate group and clean transpositions of group, add replace pattern with other track to track label context menu
self.scale=scaleifscaleelse(72,71,69,67,65,64,62,60)#Scale needs to be set first because on init/load data already depends on it, at least the default scale. The scale is part of the track meta callback.
self.data=dataifdataelselist()#For content see docstring. this cannot be the default parameter because we would set the same list for all instances.
self.simpleNoteNames=simpleNoteNamesifsimpleNoteNameselseself.parentTrack.parentData.lastUsedNotenames#This is mostly for the GUI or other kinds of representation instead midi notes
self.simpleNoteNames=simpleNoteNamesifsimpleNoteNameselseself.parentTrack.parentData.lastUsedNotenames[:]#This is mostly for the GUI or other kinds of representation instead midi notes
self._processAfterInit()
def_prepareBeforeInit(self):
@ -75,6 +75,14 @@ class Pattern(object):
self._builtPatternCache={}#holds a ready cbox pattern for a clip as value. Key is a tuple of hashable parameters. see self.buildPattern
defcopy(self,newParentTrack):
"""Return an independent copy of this pattern"""
data=[note.copy()fornoteinself.data]#list of mutable dicts. Dicts have only primitve data types inside
scale=self.scale#it is immutable so there is no risk of changing it in place for both patterns at once
simpleNoteNames=self.simpleNoteNames[:]#this mutable list always gets replaced completely by setting a new list, but we don't want to take any chances and create a slice copy.
(QtCore.QCoreApplication.translate("SongStructure","Insert {} empty measures before no. {}").format(measuresPerGroup,position+1),lambda:api.insertSilence(howMany=measuresPerGroup,beforeMeasureNumber=position)),
(QtCore.QCoreApplication.translate("SongStructure","Delete {} measures from no. {} on").format(measuresPerGroup,position+1),lambda:api.deleteSwitches(howMany=measuresPerGroup,fromMeasureNumber=position)),
(QtCore.QCoreApplication.translate("SongStructure","Insert empty group before this one").format(measuresPerGroup),lambda:api.insertSilence(howMany=measuresPerGroup,beforeMeasureNumber=startMeasureForGroup)),
(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)),
]
fortext,functioninlistOfLabelsAndFunctions:
@ -592,8 +597,8 @@ class TrackLabelEditor(QtWidgets.QGraphicsScene):