def __init__(self, parent, noteExportObject):
#Dimensions and Position
x = noteExportObject["leftModInTicks"] / constantsAndConfigs.ticksToPixelRatio
y = -1 * constantsAndConfigs.stafflineGap / 2 + 1
w = (noteExportObject["rightModInTicks"] + noteExportObject["completeDuration"] - noteExportObject["leftModInTicks"]) / constantsAndConfigs.ticksToPixelRatio
h = constantsAndConfigs.stafflineGap - 2 #2 pixel to make room for the pen-width.
super().__init__(x, y, w, h)
self.setPos(0, constantsAndConfigs.stafflineGap * noteExportObject["dotOnLine"] / 2)
self.setParentItem(parent)
#Prepare self.shape()
#NOTE: this was from a time when mouse modification was possible. Leave for later use.
#self.path = QtGui.QPainterPath()
#self.pathRect = QtCore.QRectF(x, y-1, w, h+4) #this is directly related to inits parameter x, y, w, h
#self.path.addRect(self.pathRect)
#self.setCursor(QtCore.Qt.SizeHorCursor)
#Different color when the duration was modified by the user
inactive = "green" if noteExportObject["manualOverride"] else "black"
self.inactiveColor = QtGui.QColor(inactive)
self.setBrush(self.inactiveColor)
#Pen for the borders
pen = QtGui.QPen()
pen.setCapStyle(QtCore.Qt.RoundCap)
pen.setJoinStyle(QtCore.Qt.RoundJoin)
pen.setWidth(1)
pen.setColor(QtGui.QColor("darkGrey"))
self.setPen(pen)
#Since accidentals are part of the notehead we need one here. It doesn't matter if the traditional notehead already has one
if noteExportObject["accidental"]: #0 means no difference to keysig
self.accidental = GuiNote.createAccidentalGraphicsItem(self, noteExportObject["accidental"])
self.accidental.setPos(0, 0) #not analogue to the notehead acciental position because here we choose the rectangle as parent
self.accidental.setParentItem(self)
#NOTE: this was from a time when mouse modification was possible. Leave for later use.
#def shape(self):
# """Qt Function
# Return a more accurate shape for this item so that
# mouse hovering is more accurate.
#
# Must be within the bounding rect."""
# return self.path
#def boundingRect(self, *args):
# """Keep in syn with self.shape()"""
# return self.pathRect
#def paint(self, *args):
#Do NOT implement this. This actually works already. The parent item needs this.
评论列表
文章目录