Browse Source

New menu action to always show velocities

master
Nils 2 years ago
parent
commit
9a163fb234
  1. 10
      qtgui/mainwindow.py
  2. 26
      qtgui/pattern_grid.py

10
qtgui/mainwindow.py

@ -597,12 +597,19 @@ class MainWindow(TemplateMainWindow):
self.ui.splitter.setSizes([1,1])
def toggleFollowPlayheadInPattern(self):
"""We do not need to do anything here at the moment. Pattern.playhead will just check
"""Toggling is done by Qt. We do not need to do anything here at the moment. Pattern.playhead will just check
the menu checkbox"""
pass
#now = self.ui.actionPatternFollowPlayhead.isChecked()
#self.ui.actionPatternFollowPlayhead.setChecked(not now)
def toggleVelocitiesAlwaysVisible(self):
"""Toggling is done by Qt."""
#now = self.ui.actionVelocitiesAlwaysVisible.isChecked()
#self.ui.actionVelocitiesAlwaysVisible.setChecked(not now)
self.patternGrid.decideYourselfIToShowVelocities()
def halftoneTranspose(self, value):
if self.songEditor.currentHoverStep and self.songEditor.currentHoverStep.isVisible():
if value == 1: #only +1 and -1 for the menu action.
@ -665,6 +672,7 @@ class MainWindow(TemplateMainWindow):
self.menu.addMenuEntry("menuView", "actionMaximizePatternArea", QtCore.QCoreApplication.translate("menu", "Maximize Pattern Area"), self.maximizePatternArea)
self.menu.addMenuEntry("menuView", "actionEqualSizeSongPatternArea", QtCore.QCoreApplication.translate("menu", "Equal space for Pattern/Song Area"), self.equalizeSongPatternAreas)
self.menu.addMenuEntry("menuView", "actionPatternFollowPlayhead", QtCore.QCoreApplication.translate("menu", "Follow playhead in pattern-view by scrolling."), self.toggleFollowPlayheadInPattern, checkable=True, shortcut="f")
self.menu.addMenuEntry("menuView", "actionVelocitiesAlwaysVisible", QtCore.QCoreApplication.translate("menu", "Velocity numbers are always visible"), self.toggleVelocitiesAlwaysVisible, checkable=True, shortcut="v")
#self.menu.addSeparator("menuEdit")
self.menu.orderSubmenus(["menuFile", "menuEdit", "menuView", "menuHelp", "menuDebug"])

26
qtgui/pattern_grid.py

@ -308,9 +308,19 @@ class PatternGrid(QtWidgets.QGraphicsScene):
for patternStep in self._steps.values():
if patternStep.status:
patternStep.velocityNumber.show()
def hideVelocities(self):
for patternStep in self._steps.values():
patternStep.velocityNumber.hide()
if not self.parentView.parentMainWindow.ui.actionVelocitiesAlwaysVisible.isChecked():
for patternStep in self._steps.values():
patternStep.velocityNumber.hide()
def decideYourselfIToShowVelocities(self):
"""Called by the menu action to always show velocities"""
if self.parentView.parentMainWindow.ui.actionVelocitiesAlwaysVisible.isChecked():
self.showVelocities()
else:
self.hideVelocities()
def mousePressEvent(self, event):
self._middleMouseDown = False
@ -519,7 +529,11 @@ class Step(QtWidgets.QGraphicsRectItem):
self.velocityNumber.setParentItem(self)
self.velocityNumber.setBrush(self.parentScene.labelColor)
self.velocityNumber.setPos(offset*2,offset*2) #that is not pretty but you can see it under the cursor
self.velocityNumber.hide() #only visible during mouse wheel event
if self.parentScene.parentView.parentMainWindow.ui.actionVelocitiesAlwaysVisible.isChecked():
self.velocityNumber.show()
else:
self.velocityNumber.hide() #only visible during mouse wheel event
#The data section. On creation all the steps are uninitialized. They are off and hold no musical values
#self.velocity = set in self.useDefaultValues . We don't set it at all here to have a clear Exception when the program tries to access it.
@ -602,6 +616,9 @@ class Step(QtWidgets.QGraphicsRectItem):
else: #User clicked on an empty field.
self.useDefaultValues()
if self.parentScene.parentView.parentMainWindow.ui.actionVelocitiesAlwaysVisible.isChecked():
self.velocityNumber.show()
self.exceedsPlayback = exceedsPlayback
assert self.factor > 0
@ -679,7 +696,8 @@ class Step(QtWidgets.QGraphicsRectItem):
"""Hover events are only triggered if no mouse button is down. The mouse got grabbed
by the item. Which makes sense because we want to receive mouseRelease on an item even
if the mouse cursor is not on that item anymore"""
self.velocityNumber.hide()
if not self.parentScene.parentView.parentMainWindow.ui.actionVelocitiesAlwaysVisible.isChecked():
self.velocityNumber.hide()
self.statusMessage("")
if self.status:
event.accept()

Loading…
Cancel
Save