diff --git a/CHANGELOG b/CHANGELOG index b405c07..c8ed5df 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ Add midi-in selector drop down, as seen in Tembro and Fluajho. Rewrite grid, which was a performance drag in the past. Add functions to move block to start or end of track. Scroll view when dragging blocks and tracks with the mouse. +Block name font color is now always readable, no matter the background color Add 3/2 to metrical instruction. Autosave when exporting Lilypond .ly or PDF. Command to quickly add text below or above a staff. diff --git a/qtgui/musicstructures.py b/qtgui/musicstructures.py index b6c37e3..a735167 100644 --- a/qtgui/musicstructures.py +++ b/qtgui/musicstructures.py @@ -58,7 +58,6 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem): #self.setFlag(QtWidgets.QGraphicsItem.ItemContainsChildrenInShape, True) self.parent = parent #GuiTrack instance self.parentGuiTrack = parent #redundant, but specifically for block movement. see ScoreScene - self.color = None #QColor inserted by the creating function in GuiTrack. Used during dragging, then reset to transparent. self.trans = QtGui.QColor("transparent") self.setPen(self.trans) self.setBrush(self.trans) @@ -68,7 +67,7 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem): self.setParentItem(parent) self.setZValue(10) #This is the z value within GuiTrack self.staticExportItem = staticExportItem - + self._color = None # @property self.posBeforeMove = None self.cursorPosOnMoveStart = None @@ -99,6 +98,25 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem): self.endLabel.setPos(self.rect().width() - self.endLabel.boundingRect().width(), constantsAndConfigs.stafflineGap) self.endLabel.setFlags(QtWidgets.QGraphicsItem.ItemIgnoresParentOpacity) + @property + def color(self): + assert self._color + return self._color + + @color.setter + def color(self, c:QtGui.QColor): + """QColor inserted by the creating function in GuiTrack. + Only available during mousePressEvent. Used during dragging, then reset to transparent. + + This is on every change. Every note.""" + self._color = c + if c.lightness() > 127: #between 0 (for black) and 255 (for white) + labelColor = QtGui.QColor("black") + else: + labelColor = QtGui.QColor("white") + self.startLabel.setBrush(labelColor) + self.endLabel.setBrush(labelColor) + def stretchXCoordinates(self, factor): """Reposition the items on the X axis. Call goes through all parents/children, starting from ScoreView._stretchXCoordinates. @@ -114,6 +132,7 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem): self.startLabel.hide() self.endLabel.hide() + def mousePressEventCustom(self, event): """Not a qt-override. This is called directly by GuiScore if you click on a block with the right modifier keys (none)""" @@ -143,8 +162,6 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem): We do not use event parameter. This is for compatibility. """ if self.startLabel.isVisible(): #block mode - print (self.staticExportItem["name"], event) - listOfLabelsAndFunctions = [ (translate("musicstructures", "edit properties"), lambda: BlockPropertiesEdit(self.scene().parentView.mainWindow, staticExportItem = self.staticExportItem)), ("separator", None),