Browse Source

some cleanup and docstrings

master
Nils 1 year ago
parent
commit
6c2f283f19
  1. 12
      engine/api.py
  2. 2
      engine/main.py

12
engine/api.py

@ -599,9 +599,15 @@ def _reinsertDeletedTrack(track, trackIndex):
callbacks._numberOfTracksChanged()
def deleteTrack(trackId):
""" indirectly calls session.data.buildAllTracks() through group change.
This is wasteful, but it acceptable. We let the code stay simple in exchange for redundant
re-building of all tracks.
"""
track = session.data.trackById(trackId)
if not track: return
oldIndex = session.data.tracks.index(track)
with session.history.sequence("Delete Track"):
setTrackGroup(trackId, "") #has it's own undo
deletedTrack = session.data.deleteTrack(track)
@ -613,7 +619,9 @@ def deleteTrack(trackId):
session.history.register(lambda tr=deletedTrack, pos=oldIndex: _reinsertDeletedTrack(tr, pos), descriptionString="Delete Track")
updatePlayback()
callbacks._numberOfTracksChanged()
callbacks._numberOfTracksChanged() #TODO: throws a console error "port not found". but that is not critical.
def moveTrack(trackId, newIndex):
"""index is 0 based.
@ -667,7 +675,7 @@ def setTrackGroup(trackId, groupName:str):
if not track.group == groupName:
if not groupName.lower() in (track.sequencerInterface.name.lower() for track in session.data.tracks):
session.history.register(lambda tr=trackId, v=track.group: setTrackGroup(trackId, v), descriptionString="Track Group")
session.data.setGroup(track, groupName) #includes session.data.buildAllTracks()
session.data.setGroup(track, groupName) #includes session.data.buildAllTracks(). This is wasteful, but it acceptable. We let the code stay simple in exchange for redundant re-building of all tracks.
updatePlayback()
callbacks._numberOfTracksChanged()

2
engine/main.py

@ -290,6 +290,8 @@ class Data(template.engine.sequencer.Score):
self.sortTracks()
if buildAllTracksAfterwards:
#TODO: this could be optimized. Currently everytime you delete a track, even an empty one, all tracks are re-built.
#However, it is not *that* important. Everything works, good enough.
self.buildAllTracks()
def sortTracks(self):

Loading…
Cancel
Save