Browse Source

Add missing rects and removal of whitespace

master
Nils 4 years ago
parent
commit
58de2ba26c
  1. 25
      qtgui/conductor.py
  2. 19
      qtgui/cursor.py
  3. 22
      qtgui/graphs.py
  4. 19
      qtgui/grid.py
  5. 3
      qtgui/items.py
  6. 10
      qtgui/musicstructures.py
  7. 17
      qtgui/scorescene.py
  8. 2
      qtgui/scoreview.py

25
qtgui/conductor.py

@ -52,6 +52,8 @@ class Conductor(QtWidgets.QGraphicsItem):
self.staticBlocks = None #Cached Block Data list self.staticBlocks = None #Cached Block Data list
self.staticMeta = None #Cached track meta data dict. self.staticMeta = None #Cached track meta data dict.
self.setFlag(QtWidgets.QGraphicsItem.ItemHasNoContents, True) #only child items. Without this we get notImplementedError: QGraphicsItem.paint() is abstract and must be overridden
self.staffLine = QtWidgets.QGraphicsLineItem(0,0,10,0) #x1, y1, x2, y2 self.staffLine = QtWidgets.QGraphicsLineItem(0,0,10,0) #x1, y1, x2, y2
self.staffLine.setParentItem(self) self.staffLine.setParentItem(self)
self.staffLine.setPos(0,0) self.staffLine.setPos(0,0)
@ -64,10 +66,9 @@ class Conductor(QtWidgets.QGraphicsItem):
api.callbacks.updateTempoTrack.append(self.createGraphicItemsFromData) api.callbacks.updateTempoTrack.append(self.createGraphicItemsFromData)
api.callbacks.updateTempoTrackMeta.append(self.updateMetaData) api.callbacks.updateTempoTrackMeta.append(self.updateMetaData)
def paint(self, *args):
pass
def boundingRect(self, *args): def boundingRect(self, *args):
return oneRectToReturnThemAll """The tempo track extends above the real tracks"""
return QtCore.QRectF(0, -1*self.totalHeight, 20000, 1.2*self.totalHeight) #x,y,w,h
def blockAt(self, xScenePosition): def blockAt(self, xScenePosition):
for block in ConductorTransparentBlock.instances: for block in ConductorTransparentBlock.instances:
@ -238,6 +239,11 @@ class ConductorTransparentBlock(QtWidgets.QGraphicsRectItem):
#self.setZValue(_zValuesRelativeToConductor["handle"]) #includes the handle #self.setZValue(_zValuesRelativeToConductor["handle"]) #includes the handle
#Doesn't need it because only pure QGraphicItem subclasses need that. But we are already a rect.
#def boundingRect(self, *args):
# return oneRectToReturnThemAll
#Doesn't need it because only pure QGraphicItem subclasses need that. But we are already a rect.
#def paint(self, *args): #def paint(self, *args):
# """Prevent the selection rectangle when clicking the item""" # """Prevent the selection rectangle when clicking the item"""
#!! This also prevents the rectangle to show up. Very bad decision. #!! This also prevents the rectangle to show up. Very bad decision.
@ -431,11 +437,8 @@ class TempoPoint(QtWidgets.QGraphicsItem):
self.parentTempoTrack = parentTempoTrack self.parentTempoTrack = parentTempoTrack
self.parentBlock = parentBlock self.parentBlock = parentBlock
self.setZValue(_zValuesRelativeToConductor["item"]) self.setZValue(_zValuesRelativeToConductor["item"])
self.setAcceptHoverEvents(True) self.setAcceptHoverEvents(True)
if not self.staticExportItem["positionInBlock"] == 0: if not self.staticExportItem["positionInBlock"] == 0:
self.setFlags(QtWidgets.QGraphicsItem.ItemIsMovable|QtWidgets.QGraphicsItem.ItemIsFocusable) self.setFlags(QtWidgets.QGraphicsItem.ItemIsMovable|QtWidgets.QGraphicsItem.ItemIsFocusable)
#Too irritating. And confuses with handle movement. self.setCursor(QtCore.Qt.SizeHorCursor) #this sets the cursor while the mouse is over the item. It is independent of AcceptHoverEvents #Too irritating. And confuses with handle movement. self.setCursor(QtCore.Qt.SizeHorCursor) #this sets the cursor while the mouse is over the item. It is independent of AcceptHoverEvents
@ -531,7 +534,6 @@ class TempoPoint(QtWidgets.QGraphicsItem):
def wheelEvent(self, event): def wheelEvent(self, event):
"""This buffers until hoverLeaveEvent and then the new value is sent in self.hoverLeaveEvent""" """This buffers until hoverLeaveEvent and then the new value is sent in self.hoverLeaveEvent"""
print ("w")
if event.delta() > 0: if event.delta() > 0:
self.wheelEventChangedValue += 1 self.wheelEventChangedValue += 1
else: else:
@ -581,15 +583,16 @@ class TimeLine(QtWidgets.QGraphicsItem):
def __init__(self, parent): def __init__(self, parent):
super().__init__() super().__init__()
self.parent = parent self.parent = parent #
self.gridInSeconds = 10 self.gridInSeconds = 10
api.callbacks.updateTempoTrackBlocks.append(self.redraw) api.callbacks.updateTempoTrackBlocks.append(self.redraw)
#no redraw on init. self.parent.staticPoints is not set yet. #no redraw on init. self.parent.staticPoints is not set yet.
def paint(self, *args): def paint(self, *args):
pass pass
def boundingRect(self, *args): def boundingRect(self, *args):
return oneRectToReturnThemAll return self.parent.boundingRect()
def redraw(self, staticRepresentationList): def redraw(self, staticRepresentationList):
if not self.parent.staticPoints: if not self.parent.staticPoints:
@ -640,7 +643,3 @@ class TimeLine(QtWidgets.QGraphicsItem):
time grid""" time grid"""
for timePoint in self.TimePoint.instances: for timePoint in self.TimePoint.instances:
timePoint.setX(timePoint.pos().x() * factor) timePoint.setX(timePoint.pos().x() * factor)

19
qtgui/cursor.py

@ -31,6 +31,8 @@ pen.setJoinStyle(QtCore.Qt.RoundJoin)
pen.setWidth(2) pen.setWidth(2)
#pen.setColor(QtGui.QColor("red")) #pen.setColor(QtGui.QColor("red"))
oneRectToReturnThemAll = QtCore.QRectF(0,0,0,0) #prevent the annoying "NotImplementError" from Qt for boundingRect. For items that don't need any collision detection.
class PitchCursor(QtWidgets.QGraphicsRectItem): class PitchCursor(QtWidgets.QGraphicsRectItem):
def __init__(self): def __init__(self):
"""Does not need the actual dotOnLine. """Does not need the actual dotOnLine.
@ -42,6 +44,8 @@ class PitchCursor(QtWidgets.QGraphicsRectItem):
self.setPen(pen) self.setPen(pen)
self.setEnabled(False) self.setEnabled(False)
def boundingRect(self, *args): return oneRectToReturnThemAll
class PositionCursor(QtWidgets.QGraphicsRectItem): class PositionCursor(QtWidgets.QGraphicsRectItem):
def __init__(self): def __init__(self):
"""Does not need the actual position. """Does not need the actual position.
@ -53,6 +57,10 @@ class PositionCursor(QtWidgets.QGraphicsRectItem):
self.setScale(0.8) self.setScale(0.8)
self.setEnabled(False) self.setEnabled(False)
def boundingRect(self, *args):
return oneRectToReturnThemAll
class Cursor(QtWidgets.QGraphicsItemGroup): class Cursor(QtWidgets.QGraphicsItemGroup):
"""A cursor that shows the vertical """A cursor that shows the vertical
as well as the horizontal position as well as the horizontal position
@ -67,6 +75,10 @@ class Cursor(QtWidgets.QGraphicsItemGroup):
api.callbacks.setCursor.append(self.setCursor) api.callbacks.setCursor.append(self.setCursor)
self.setEnabled(False) self.setEnabled(False)
def boundingRect(self, *args):
return oneRectToReturnThemAll
def clearItemHighlight(self): def clearItemHighlight(self):
"""Gets called before a track changes. Most of the time when a new item is inserted/deleted. """Gets called before a track changes. Most of the time when a new item is inserted/deleted.
This means the gui track will be recreated and a current highlight on an item might get This means the gui track will be recreated and a current highlight on an item might get
@ -142,6 +154,10 @@ class Playhead(QtWidgets.QGraphicsLineItem):
#self.hide() #self.hide()
#self.maxHeight = QtWidgets.QDesktopWidget().geometry().height() #we really hope the screen resolution does not change during the session. #self.maxHeight = QtWidgets.QDesktopWidget().geometry().height() #we really hope the screen resolution does not change during the session.
def boundingRect(self, *args):
return oneRectToReturnThemAll
def setCursorPosition(self, tickindex:int, playbackStatus:bool): def setCursorPosition(self, tickindex:int, playbackStatus:bool):
"""Set the playhead to the right position, but keep the viewport stable. """Set the playhead to the right position, but keep the viewport stable.
Shift the entire "page" if the cursor becomes invisible because its steps outside the viewport""" Shift the entire "page" if the cursor becomes invisible because its steps outside the viewport"""
@ -215,6 +231,9 @@ class Selection(QtWidgets.QGraphicsRectItem):
self.setEnabled(False) self.setEnabled(False)
api.callbacks.setSelection.append(self.setSelection) api.callbacks.setSelection.append(self.setSelection)
def boundingRect(self, *args):
return oneRectToReturnThemAll
def setSelection(self, tupleOfCursorExportObjects): def setSelection(self, tupleOfCursorExportObjects):
if tupleOfCursorExportObjects: if tupleOfCursorExportObjects:
validSelection, topleftCursorObject, bottomRightCursorObject = tupleOfCursorExportObjects validSelection, topleftCursorObject, bottomRightCursorObject = tupleOfCursorExportObjects

22
qtgui/graphs.py

@ -25,6 +25,8 @@ from .constantsAndConfigs import constantsAndConfigs
from template.qtgui.helper import stringToColor, removeInstancesFromScene, callContextMenu, stretchLine, stretchRect from template.qtgui.helper import stringToColor, removeInstancesFromScene, callContextMenu, stretchLine, stretchRect
import engine.api as api import engine.api as api
oneRectToReturnThemAll = QtCore.QRectF(0,0,0,0) #prevent the annoying "NotImplementError" from Qt for boundingRect. For items that don't need any collision detection.
class CCPath(QtWidgets.QGraphicsRectItem): class CCPath(QtWidgets.QGraphicsRectItem):
""" """
A CCPath only exists when the backend track has a cc-part activated. A CCPath only exists when the backend track has a cc-part activated.
@ -66,6 +68,8 @@ class CCPath(QtWidgets.QGraphicsRectItem):
self.blockdictCache = {} #blockId:guiBlock updated through self.updateGraphBlockTrack self.blockdictCache = {} #blockId:guiBlock updated through self.updateGraphBlockTrack
self.transparentBlockHandles = [] #transparentBlockHandles in correct order. updated through self.updateGraphBlockTrack self.transparentBlockHandles = [] #transparentBlockHandles in correct order. updated through self.updateGraphBlockTrack
def boundingRect(self, *args): return oneRectToReturnThemAll
def itemChange(self, changeEnum, value): def itemChange(self, changeEnum, value):
if changeEnum == QtWidgets.QGraphicsItem.ItemVisibleHasChanged: #12 if changeEnum == QtWidgets.QGraphicsItem.ItemVisibleHasChanged: #12
if self.isVisible(): if self.isVisible():
@ -76,7 +80,7 @@ class CCPath(QtWidgets.QGraphicsRectItem):
return super().itemChange(changeEnum, value) return super().itemChange(changeEnum, value)
def mousePressEvent(self, event): def mousePressEvent(self, event):
if event.button() == 1: #QtCore.Qt.MouseButton.LeftButton if event.button() == 1: #QtCore.Qt.LeftButton
self.add(event.pos()) self.add(event.pos())
@property @property
@ -253,6 +257,8 @@ class CCGraphTransparentBlock(QtWidgets.QGraphicsRectItem):
self.posBeforeMove = None self.posBeforeMove = None
self.cursorPosOnMoveStart = None self.cursorPosOnMoveStart = None
def boundingRect(self, *args): return oneRectToReturnThemAll
def stretchXCoordinates(self, factor): def stretchXCoordinates(self, factor):
"""Reposition the items on the X axis. """Reposition the items on the X axis.
Call goes through all parents/children, starting from ScoreView._stretchXCoordinates. Call goes through all parents/children, starting from ScoreView._stretchXCoordinates.
@ -359,6 +365,8 @@ class CCGraphBlockEndMarker(QtWidgets.QGraphicsLineItem):
self.activePen = QtGui.QPen(pen) self.activePen = QtGui.QPen(pen)
self.activePen.setColor(QtGui.QColor("cyan")) self.activePen.setColor(QtGui.QColor("cyan"))
def boundingRect(self, *args): return oneRectToReturnThemAll
def allItemsRightOfMe(self): def allItemsRightOfMe(self):
for item in self.parentCCPath.items: for item in self.parentCCPath.items:
if item.x() > self.x(): if item.x() > self.x():
@ -376,7 +384,7 @@ class CCGraphBlockEndMarker(QtWidgets.QGraphicsLineItem):
"""After moving a point around """After moving a point around
send an update to the backend""" send an update to the backend"""
super(CCGraphBlockEndMarker, self).mouseReleaseEvent(event) super(CCGraphBlockEndMarker, self).mouseReleaseEvent(event)
if event.button() == 1: #QtCore.Qt.MouseButton.LeftButton if event.button() == 1: #QtCore.Qt.LeftButton
x = event.scenePos().x() x = event.scenePos().x()
#x = self.x() #x = self.x()
x = x * constantsAndConfigs.ticksToPixelRatio x = x * constantsAndConfigs.ticksToPixelRatio
@ -390,7 +398,7 @@ class CCGraphBlockEndMarker(QtWidgets.QGraphicsLineItem):
def mousePressEvent(self, event): def mousePressEvent(self, event):
super(CCGraphBlockEndMarker, self).mousePressEvent(event) super(CCGraphBlockEndMarker, self).mousePressEvent(event)
if event.button() == 1: #QtCore.Qt.MouseButton.LeftButton if event.button() == 1: #QtCore.Qt.LeftButton
for i in self.allItemsRightOfMe(): for i in self.allItemsRightOfMe():
i.hide() i.hide()
@ -422,6 +430,8 @@ class CCInterpolatedPoint(QtWidgets.QGraphicsEllipseItem):
self.setEnabled(False) self.setEnabled(False)
self.setZValue(1) self.setZValue(1)
def boundingRect(self, *args): return oneRectToReturnThemAll
class CCUserPoint(QtWidgets.QGraphicsEllipseItem): class CCUserPoint(QtWidgets.QGraphicsEllipseItem):
"""the position is set by the parent""" """the position is set by the parent"""
def __init__(self, parentCCPath, staticExportItem): def __init__(self, parentCCPath, staticExportItem):
@ -439,6 +449,8 @@ class CCUserPoint(QtWidgets.QGraphicsEllipseItem):
self.interpolatedItemsLeft = [] self.interpolatedItemsLeft = []
self.setZValue(9) self.setZValue(9)
def boundingRect(self, *args): return oneRectToReturnThemAll
def shape(self): def shape(self):
"""Return a more accurate shape for this item so that """Return a more accurate shape for this item so that
mouse hovering is more accurate""" mouse hovering is more accurate"""
@ -450,7 +462,7 @@ class CCUserPoint(QtWidgets.QGraphicsEllipseItem):
super().mousePressEvent(event) super().mousePressEvent(event)
self.lastPos = self.pos() self.lastPos = self.pos()
if event.button() == 1: #QtCore.Qt.MouseButton.LeftButton if event.button() == 1: #QtCore.Qt.LeftButton
self.setCursor(QtCore.Qt.BlankCursor) self.setCursor(QtCore.Qt.BlankCursor)
for i in self.interpolatedItemsLeft + self.interpolatedItemsRight: for i in self.interpolatedItemsLeft + self.interpolatedItemsRight:
i.hide() i.hide()
@ -480,7 +492,7 @@ class CCUserPoint(QtWidgets.QGraphicsEllipseItem):
send an update to the backend""" send an update to the backend"""
super(CCUserPoint, self).mouseReleaseEvent(event) super(CCUserPoint, self).mouseReleaseEvent(event)
self.setCursor(QtCore.Qt.SizeAllCursor) self.setCursor(QtCore.Qt.SizeAllCursor)
if event.button() == 1: #QtCore.Qt.MouseButton.LeftButton if event.button() == 1: #QtCore.Qt.LeftButton
api.changeGraphItem(self.staticExportItem["id"], self.getXDifferenceAsBackendValue(), self.getYAsBackendValue()) #send update to the backend, don't wait for callback. api.changeGraphItem(self.staticExportItem["id"], self.getXDifferenceAsBackendValue(), self.getYAsBackendValue()) #send update to the backend, don't wait for callback.
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):

19
qtgui/grid.py

@ -21,15 +21,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging; logger = logging.getLogger(__name__); logger.info("import") import logging; logger = logging.getLogger(__name__); logger.info("import")
#Standard Library #Standard Library
#Third Party #Third Party
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
#Our Template Modules #Our Template Modules
from template.engine.sequencer import MAXIMUM_TICK_DURATION
#Client Modules #Client Modules
from .constantsAndConfigs import constantsAndConfigs from .constantsAndConfigs import constantsAndConfigs
import engine.api as api
oneRectToReturnThemAll = QtCore.QRectF(0,0,0,0) #prevent the annoying "NotImplementError" from Qt for boundingRect. For items that don't need any collision detection.
masterLine = QtCore.QLineF(0, 0, 0, 128*constantsAndConfigs.stafflineGap) # (x1, y1, x2, y2)
class RhythmLine(QtWidgets.QGraphicsLineItem):
def __init__(self, parentGrid):
super().__init__(masterLine)
self.setEnabled(False)
self.setParentItem(parentGrid)
self.setAcceptedMouseButtons(QtCore.Qt.NoButton) #we still need this otherwise no rubberband.
class GuiGrid(QtWidgets.QGraphicsItemGroup): class GuiGrid(QtWidgets.QGraphicsItemGroup):
"""The grid consists of vertical and horizontal lines. """The grid consists of vertical and horizontal lines.
@ -81,6 +98,8 @@ class GuiGrid(QtWidgets.QGraphicsItemGroup):
gridPen = QtGui.QPen(QtCore.Qt.DotLine) gridPen = QtGui.QPen(QtCore.Qt.DotLine)
gridPen.setCosmetic(True) gridPen.setCosmetic(True)
def boundingRect(self, *args): return oneRectToReturnThemAll
def reactToHorizontalScroll(self, value): def reactToHorizontalScroll(self, value):
if not self.initialGridExists: if not self.initialGridExists:
return return

3
qtgui/items.py

@ -60,6 +60,9 @@ class GuiTieCurveGraphicsItem(QtWidgets.QGraphicsPathItem):
self.noteExportObject = noteExportObject self.noteExportObject = noteExportObject
self.draw() self.draw()
def boundingRect(self, *args):
return oneRectToReturnThemAll
def draw(self): def draw(self):
lengthInPixel = self.noteExportObject["tieDistanceInTicks"] / constantsAndConfigs.ticksToPixelRatio lengthInPixel = self.noteExportObject["tieDistanceInTicks"] / constantsAndConfigs.ticksToPixelRatio
path = QtGui.QPainterPath() path = QtGui.QPainterPath()

10
qtgui/musicstructures.py

@ -43,6 +43,8 @@ from .submenus import BlockPropertiesEdit
cosmeticPen = QtGui.QPen() cosmeticPen = QtGui.QPen()
cosmeticPen.setCosmetic(True) cosmeticPen.setCosmetic(True)
oneRectToReturnThemAll = QtCore.QRectF(0,0,0,0) #prevent the annoying "NotImplementError" from Qt for boundingRect. For items that don't need any collision detection.
class GuiBlockHandle(QtWidgets.QGraphicsRectItem): class GuiBlockHandle(QtWidgets.QGraphicsRectItem):
"""A simplified version of a Block. Since we don't use blocks in the GUI, only in the backend """A simplified version of a Block. Since we don't use blocks in the GUI, only in the backend
we still need them sometimes as macro strutures, where we don't care about the content. we still need them sometimes as macro strutures, where we don't care about the content.
@ -93,6 +95,8 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem):
self.startLabel = QtWidgets.QGraphicsSimpleTextItem("") self.startLabel = QtWidgets.QGraphicsSimpleTextItem("")
self.endLabel = QtWidgets.QGraphicsSimpleTextItem("") self.endLabel = QtWidgets.QGraphicsSimpleTextItem("")
def boundingRect(self, *args): return oneRectToReturnThemAll
def stretchXCoordinates(self, factor): def stretchXCoordinates(self, factor):
"""Reposition the items on the X axis. """Reposition the items on the X axis.
Call goes through all parents/children, starting from ScoreView._stretchXCoordinates. Call goes through all parents/children, starting from ScoreView._stretchXCoordinates.
@ -221,6 +225,8 @@ class GuiTrack(QtWidgets.QGraphicsItem):
#self.secondStageInitNowThatWeHaveAScene gets called by the ScoreScene.redraw(), where new tracks get created. After it was inserted into the scene. #self.secondStageInitNowThatWeHaveAScene gets called by the ScoreScene.redraw(), where new tracks get created. After it was inserted into the scene.
def boundingRect(self, *args): return oneRectToReturnThemAll
class NameGraphic(QtWidgets.QGraphicsSimpleTextItem): class NameGraphic(QtWidgets.QGraphicsSimpleTextItem):
def __init__(self, text, parent): def __init__(self, text, parent):
super().__init__(text) super().__init__(text)
@ -237,6 +243,8 @@ class GuiTrack(QtWidgets.QGraphicsItem):
if result[1]: if result[1]:
api.setTrackName(self.parent.staticExportItem["id"], nameString = result[0], initialInstrumentName = self.parent.staticExportItem["initialInstrumentName"], initialShortInstrumentName = self.parent.staticExportItem["initialShortInstrumentName"]) #keep the old lilypond names api.setTrackName(self.parent.staticExportItem["id"], nameString = result[0], initialInstrumentName = self.parent.staticExportItem["initialInstrumentName"], initialShortInstrumentName = self.parent.staticExportItem["initialShortInstrumentName"]) #keep the old lilypond names
#def boundingRect(self, *args): return oneRectToReturnThemAll
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
listOfLabelsAndFunctions = [ (translate("musicstructures", "edit name"), self._editName), ] listOfLabelsAndFunctions = [ (translate("musicstructures", "edit name"), self._editName), ]
callContextMenu(listOfLabelsAndFunctions) callContextMenu(listOfLabelsAndFunctions)
@ -399,6 +407,8 @@ class GuiTrack(QtWidgets.QGraphicsItem):
self.setFlag(QtWidgets.QGraphicsItem.ItemHasNoContents, True) #only child items. Without this we get notImplementedError: QGraphicsItem.paint() is abstract and must be overridden self.setFlag(QtWidgets.QGraphicsItem.ItemHasNoContents, True) #only child items. Without this we get notImplementedError: QGraphicsItem.paint() is abstract and must be overridden
self.setFlag(QtWidgets.QGraphicsItem.ItemContainsChildrenInShape, True) self.setFlag(QtWidgets.QGraphicsItem.ItemContainsChildrenInShape, True)
def boundingRect(self, *args): return oneRectToReturnThemAll
def createGraphicItemsFromData(self, staticRepresentationList): def createGraphicItemsFromData(self, staticRepresentationList):
"""Create staff objects including simple barlines""" """Create staff objects including simple barlines"""

17
qtgui/scorescene.py

@ -69,7 +69,7 @@ class GuiScore(QtWidgets.QGraphicsScene):
self.backColor.setNamedColor("#fdfdff") self.backColor.setNamedColor("#fdfdff")
self.setBackgroundBrush(self.backColor) self.setBackgroundBrush(self.backColor)
self.grid = GuiGrid(parent=self) self.grid = Grid(parentScene=self)
self.addItem(self.grid) 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.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.grid.setZValue(-50)
@ -278,8 +278,16 @@ class GuiScore(QtWidgets.QGraphicsScene):
return None return None
def wheelEvent(self, event): def notTrueAnymore_wheelEvent(self, event):
"""We MUST handle the event somehow. Otherwise background grid items will block the views(!) """
This docstring was either wrong in the first place or something changed in my code.
However, we do not need to eat wheelEvent here anymore. On the contrary: It will block
items, like the tempoItem from receiving wheelEvents.
The commented out if/else for item detection also has a chance to work, but we don't need
to test for that at all. Standard Qt-behavoiour is fine.
What follows is the old docstring, for legacy documentation reasons:
We MUST handle the event somehow. Otherwise background grid items will block the views(!)
wheel scrolling, even when disabled and setting accepting mouse events to none. wheel scrolling, even when disabled and setting accepting mouse events to none.
This is a qt bug that won't be fixed because API stability over correctnes (according to the This is a qt bug that won't be fixed because API stability over correctnes (according to the
bugtracker. bugtracker.
@ -291,10 +299,11 @@ class GuiScore(QtWidgets.QGraphicsScene):
""" """
#item = self.itemAt(event.scenePos(), self.parentView.transform()) #item = self.itemAt(event.scenePos(), self.parentView.transform())
#if type(item) is items.Note: #if type(item) is items.Note:
# super().wheelEvent(event) #send to child item #super().wheelEvent(event) #send to child item
#else: #else:
event.ignore() #so the view scrolls or we zoom event.ignore() #so the view scrolls or we zoom
def stretchXCoordinates(self, factor): def stretchXCoordinates(self, factor):
"""Reposition the items on the X axis. """Reposition the items on the X axis.
Call goes through all parents/children, starting from ScoreView._stretchXCoordinates. Call goes through all parents/children, starting from ScoreView._stretchXCoordinates.

2
qtgui/scoreview.py

@ -144,7 +144,7 @@ class ScoreView(QtWidgets.QGraphicsView):
raise ValueError("Edit Mode unknown") raise ValueError("Edit Mode unknown")
def resizeEvent(self, event): def resizeEvent(self, event):
self.scoreScene.grid.reactToresizeEventOrZoom() #self.scoreScene.grid.reactToresizeEventOrZoom()
super().resizeEvent(event) super().resizeEvent(event)
def changeGridRhythm(self): def changeGridRhythm(self):

Loading…
Cancel
Save