#The following function is not neccesary. A selection is a user-created thing, not something you need for internal processing, especially not for undo.
#Leave it as reminder.
#def _createLambdaRecreateSelection():
# """for undo only
# Call it when you still have a selection, right after you do the
# processing you want to undo.
#
# A valid selection implies that the cursor is on one end
# of the selection. It doesn't matter which one but for the
# sake of consistency and convenience we make sure that we end up with
# the cursor on the bottomRight position.
# It is entirely possible that the selection changed
# the duration and the dimensions. The bottom right item might not
# be on the same tickindex nor does it need to exist anymore.
# Only the topLeft position is guaranteed to exist and have the same
# tickindex. The item on that position however may not be there
# return createSelectionFunction #When this function gets called we are back in the position that the newly generated data is selected, ready to to the complementary processing.
returncreateSelectionFunction#When this function gets called we are back in the position that the newly generated data is selected, ready to to the complementary processing.
#We need to gather the indices of the original items all at once.
#Otherwise, if we replace step by step, we will find items multiple times leading to little or no shuffling.
originalOrder=[]#tuples. we delete from the original track so the indices will be all wrong in the end, except the first! and after we insert a new item at that first position the second index will be correct again. and so on...
forchordintrack:#iterate over the original order
#Replace each chord with a random one by removing the original chord from block data. This keeps the chord objects unchanged, ready for undo by simply reordering.
assertnotchordinseentest#shared between all tracks.
seentest.add(chord)
data=next(blforblinchord.parentBlocks).data#just take any block. data is shared between all of them. Content linked data was removed from the selection
self.notelist=[]#only in Chord. Here for compatibility reasons
self.parentBlocks=WeakSet()#this is filled and manipulated by the Block Class through copy, split, contentLink etc. this takes also care of Item.copy(). Don't look in this file for anything parentBlocks related.
#self._secondInit(parentBlock = None) #Items don't know their parent object. They are in a mutable list which can be in several containers.
self.lilypondParameters={# Only use basic data types! Not all lilypond parameters are used by every item. For clarity and editing we keep them all in one place.
@ -930,7 +930,7 @@ class Chord(Item):
def__init__(self,firstDuration,firstPitch):
super().__init__()
firstNote=Note(self,firstDuration,firstPitch)
self.notelist=[firstNote]
self.notelist=[firstNote]#from lowest to highest
self._beamGroup=False# Works a bit like legato slurs, only this is a property of a note, not an item. self.beamGroup is a @property that self-corrects against errors.
self.mainWindow.ui.actionInstrument_Change:SecondaryProgramChangeMenu(self.mainWindow),#no lambda for submenus. They get created here once and have a __call__ option that executes them. There is no internal state in these menus.
self.mainWindow.ui.actionChannel_Change:SecondaryChannelChangeMenu(self.mainWindow),#no lambda for submenus. They get created here once and have a __call__ option that executes them. There is no internal state in these menus.