def __init__(self, parentView):
super().__init__()
self.parentView = parentView
self.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex)
self.tracks = {} #trackId:guiTrack, #if we don't save the instances here in Python space Qt will loose them and they will not be displayed without any error message.
self.deleteOnIdleStack = [] # a stack that holds hidden items that need to be deleted. Hiding is much faster than deleting so we use that for the blocking function. Since we always recreate items and never re-use this is ok as a list. no need for a set.
self._deleteOnIdleLoop = QtCore.QTimer()
self._deleteOnIdleLoop.start(0) #0 means "if there is time"
self._deleteOnIdleLoop.timeout.connect(self._deleteOnIdle) #processes deleteOnIdleStack
self.duringTrackDragAndDrop = None #switched to a QGraphicsItem (e.g. GuiTrack) while a track is moved around by the mouse
self.duringBlockDragAndDrop = None #switched to a QGraphicsItem (e.g. GuiTrack) while a block is moved around by the mouse
self.conductor = Conductor(parentView = self.parentView)
self.addItem(self.conductor)
self.conductor.setPos(0, -1 * self.conductor.totalHeight)
self.yStart = self.conductor.y() - self.conductor.totalHeight/2
self.hiddenTrackCounter = QtWidgets.QGraphicsSimpleTextItem("") #filled in by self.redraw on callback tracksChanged (loading or toggling visibility of backend tracks)
self.addItem(self.hiddenTrackCounter)
self.backColor = QtGui.QColor()
self.backColor.setNamedColor("#fdfdff")
self.setBackgroundBrush(self.backColor)
self.grid = GuiGrid(parent=self)
self.addItem(self.grid)
self.grid.setPos(0, -20 * constantsAndConfigs.stafflineGap) #this is more calculation than simply using self.yStart, and might require manual adjustment in the future, but at least it guarantees the grid matches the staffline positions
self.grid.setZValue(-50)
self.cachedSceneHeight = 0 #set in self.redraw. Used by updateTrack to set the sceneRect
#All Cursors
self.cursor = Cursor()
self.addItem(self.cursor)
self.selection = Selection()
self.addItem(self.selection)
self.playhead = Playhead(self)
self.addItem(self.playhead)
self.playhead.setY(self.yStart)
#Callbacks
api.getCallbacksDatabase().tracksChanged.append(self.redraw)
api.getCallbacksDatabase().updateTrack.append(self.updateTrack)
api.getCallbacksDatabase().updateBlockTrack.append(self.trackPaintBlockBackgroundColors)
api.getCallbacksDatabase().updateGraphTrackCC.append(self.updateGraphTrackCC)
api.getCallbacksDatabase().updateGraphBlockTrack.append(self.updateGraphBlockTrack)
api.getCallbacksDatabase().graphCCTracksChanged.append(self.syncCCsToBackend)
评论列表
文章目录