From 0cee1c6c54888d723f3056edd433fca961f71ced Mon Sep 17 00:00:00 2001 From: Nils Date: Fri, 29 Jul 2022 19:50:57 +0200 Subject: [PATCH] undo for initial metrical instruction --- engine/api.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/engine/api.py b/engine/api.py index 4b1fe5f..6473a2c 100644 --- a/engine/api.py +++ b/engine/api.py @@ -1955,7 +1955,17 @@ def insertMetricalInstruction(treeOfInstructions, lilypondOverride = None): def setInitialMetricalInstruction(treeOfInstructions, lilypondOverride:str=None): - """Variation of insertMetricalInstruction to set the initial one for ALL tracks""" + """Variation of insertMetricalInstruction to set the initial one for ALL tracks. + Undo depends on it that all tracks have the same initial.""" + + #Undo + oldInitial = session.data.tracks[0].initialMetricalInstruction #the first one is the same as all. + def registeredUndoFunction(): + setInitialMetricalInstruction(oldInitial.treeOfInstructions, oldInitial.lilypondParameters["override"]) + session.history.register(registeredUndoFunction, descriptionString=f"Initial Metrical Instruction") + callbacks._historyChanged() + + #New one item = items.MetricalInstruction(treeOfInstructions) if lilypondOverride: