Browse Source

Send save status to nsm

master
Nils 5 years ago
parent
commit
60fb2acc98
  1. 19
      engine/api.py

19
engine/api.py

@ -46,17 +46,18 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
export = None
for func in self.quarterNotesPerMinuteChanged:
func(export)
callbacks._dataChanged()
def _setPlaybackTicks(self): #Differs from the template because it has subdivisions.
ppqn = cbox.Transport.status().pos_ppqn * session.data.subdivisions
status = playbackStatus()
for func in self.setPlaybackTicks:
func(ppqn, status)
func(ppqn, status)
def _loopChanged(self, measurenumber, loopStart, loopEnd):
export = measurenumber
for func in self.loopChanged:
func(export)
func(export)
def _timeSignatureChanged(self):
nr = session.data.howManyUnits
@ -69,6 +70,7 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
self._patternChanged(track)
self._subdivisionsChanged() #update subdivisions. We do not include them in the score or track export on purpose.
callbacks._dataChanged()
def _subdivisionsChanged(self):
"""Subdivisions are tricky, therefore we keep them isolated in their own callback.
@ -93,6 +95,8 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
export = session.data.subdivisions
for func in self.subdivisionsChanged:
func(export)
callbacks._dataChanged()
def _scoreChanged(self):
"""This includes the time signature as well, but is not send on a timesig change.
@ -103,6 +107,7 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
export = session.data.export()
for func in self.scoreChanged:
func(export)
callbacks._dataChanged()
def _exportCacheChanged(self, track):
"""Send the export cache for GUI caching reasons. Don't react by redrawing immediately!
@ -113,7 +118,7 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
and stepChanged."""
export = track.export()
for func in self.exportCacheChanged:
func(export)
func(export)
def _patternChanged(self, track):
"""each track has only one pattern. We can identify the pattern by track and vice versa.
@ -125,6 +130,7 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
self._exportCacheChanged(track)
for func in self.patternChanged:
func(export)
callbacks._dataChanged()
def _stepChanged(self, track, stepDict):
"""A simple GUI will most like not listen to that callback since they
@ -135,12 +141,14 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
self._exportCacheChanged(track)
for func in self.stepChanged:
func(stepDict)
callbacks._dataChanged()
def _removeStep(self, track, index, pitch):
"""Opposite of _stepChanged"""
self._exportCacheChanged(track)
for func in self.stepChanged:
func(index, pitch)
callbacks._dataChanged()
def _trackStructureChanged(self, track):
"""update one track structure. Does not export cbox.
@ -148,6 +156,7 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
export = track.export()
for func in self.trackStructureChanged:
func(export)
callbacks._dataChanged()
def _trackMetaDataChanged(self, track):
"""a low cost function that should not trigger anything costly to redraw
@ -155,13 +164,13 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
export = track.export()
for func in self.trackMetaDataChanged:
func(export)
callbacks._dataChanged()
def _numberOfMeasuresChanged(self):
export = session.data.export()
for func in self.numberOfMeasuresChanged:
func(export)
callbacks._dataChanged()
#Inject our derived Callbacks into the parent module

Loading…
Cancel
Save