self.setFlag(QtWidgets.QGraphicsItem.ItemHasNoContents,True)#only child items. Without this we get notImplementedError: QGraphicsItem.paint() is abstract and must be overridden
self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
self.setEnabled(False)
self.setOpacity(constantsAndConfigs.gridOpacity)
self.actualGridItem=None
self.nrOfVerticalLines=0#remember for optimisations
self._rememberSceneHeight=0
defreactOnScoreChange(self):
"""Entry point for callbacks and parent functions"""
gapVertical=constantsAndConfigs.gridRhythm/constantsAndConfigs.ticksToPixelRatio#this is necessary every time after stretching (ticksToPixelRatio) and after changing the gridRhythm
width=self.parent.maxTrackLength()
height=self.parent.cachedSceneHeight
lines=int(width/gapVertical)+8# + extra ones for a good feeling
self.parent.removeWhenIdle(self.actualGridItem)#remove all at once
except:
pass#will fail the first time on start
self.actualGridItem=ActualGrid(self)
self.actualGridItem.setFlag(QtWidgets.QGraphicsItem.ItemHasNoContents,True)#only child items. Without this we get notImplementedError: QGraphicsItem.paint() is abstract and must be overridden
gapVertical=constantsAndConfigs.gridRhythm/constantsAndConfigs.ticksToPixelRatio#this is necessary every time after stretching (ticksToPixelRatio) and after changing the gridRhythm
forvlineinself.actualGridItem.childItems():#rhythm- and barlines
@ -70,12 +70,14 @@ class GuiScore(QtWidgets.QGraphicsScene):
self.backColor.setNamedColor("#fdfdff")
self.setBackgroundBrush(self.backColor)
self.cachedSceneHeight=0#set in self.redraw. Used by updateTrack to set the sceneRect
self.grid=GuiGrid(parentScene=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()
@ -109,8 +111,8 @@ class GuiScore(QtWidgets.QGraphicsScene):
@ -139,7 +139,7 @@ class ScoreView(QtWidgets.QGraphicsView):
function()#this is most likely an api function
defresizeEvent(self,event):
"""Triggers mostly when new notes are entered"""
"""Triggers at least when the window is resized"""
self.scoreScene.grid.reactToresizeEventOrZoom()
super().resizeEvent(event)
@ -200,8 +200,8 @@ class ScoreView(QtWidgets.QGraphicsView):
ifself.mainWindow.ui.actionCC_Mode.isChecked():
ifcalledByMenuandself._lastSavedMode=="block":
self.stretchXCoordinates(4.0) #return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling
#if calledByMenu and self._lastSavedMode == "block":
# self.stretchXCoordinates(4.0) #return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling
self.stretchXCoordinates(4.0) #return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling
#if calledByMenu and self._lastSavedMode == "block":
# self.stretchXCoordinates(4.0) #return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling