@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from time import time
import engine . api as api #Session is already loaded and created, no duplication.
from template . engine import pitch
from PyQt5 import QtCore , QtGui , QtWidgets
from PyQt5 import QtCore , QtGui , QtWidgets , QtOpenGL
SIZE_UNIT = 40
SIZE_TOP_OFFSET = 75
@ -349,10 +349,32 @@ class PatternGrid(QtWidgets.QGraphicsScene):
self . _zoomFactor = max ( 0.1 , round ( self . _zoomFactor - 0.25 , 2 ) )
self . _zoom ( event )
event . accept ( )
elif QtWidgets . QApplication . keyboardModifiers ( ) == QtCore . Qt . AltModifier :
potentialStep = self . itemAt ( event . scenePos ( ) . x ( ) , event . scenePos ( ) . y ( ) , self . parentView . transform ( ) )
if type ( potentialStep ) is Step :
trackId = self . parentView . parentMainWindow . currentTrackId
if event . delta ( ) > 0 :
delta = 2
else :
delta = - 2
api . patternRowChangeVelocity ( trackId , potentialStep . row , delta )
self . showVelocities ( ) #removed in self.keyReleaseEvent
event . accept ( )
else :
event . ignore ( )
super ( ) . wheelEvent ( event )
else :
event . ignore ( )
super ( ) . wheelEvent ( event )
def keyReleaseEvent ( self , event ) :
""" Complementary for wheelEvent with Alt to change row velocity.
It is hard to detect the Alt key . We just brute force because there are not many
keyPresses in Patroneo at all . """
self . hideVelocities ( )
event . ignore ( )
super ( ) . keyReleaseEvent ( event )
def _zoom ( self , event ) :
if 0.1 < self . _zoomFactor < 5 :
self . parentView . resetTransform ( )
@ -623,10 +645,12 @@ class Scale(QtWidgets.QGraphicsRectItem):
for pitchWidget in self . pitchWidgets :
pitchWidget . spinBoxValueChanged ( ) #change all current pitchWidgets
def sendToEngine ( self ) :
def sendToEngine ( self , callback = True ) :
result = [ widget . spinBox . value ( ) for widget in self . pitchWidgets ]
#result.reverse()
api . setScale ( trackId = self . parentScene . parentView . parentMainWindow . currentTrackId , scale = result )
trackId = self . parentScene . parentView . parentMainWindow . currentTrackId
if trackId : #startup check
api . setScale ( trackId , scale = result , callback = callback )
class TransposeControls ( QtWidgets . QWidget ) :
""" Communication with the scale spinBoxes is done via api callbacks. We just fire and forget """
@ -738,12 +762,13 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
def __init__ ( self , parentItem ) :
super ( ) . __init__ ( )
self . parentItem = parentItem
self . spinBox = QtWidgets . QSpinBox ( )
self . spinBox = QtWidgets . QSpinBox ( )
#self.spinBox.setFrame(True)
self . spinBox . setMinimum ( 0 )
self . spinBox . setMaximum ( 127 )
self . spinBox . stepBy = self . stepBy
#self.spinBox.setValue(0) #No init value. This is changed on active track callback
widget = QtWidgets . QWidget ( )
layout = QtWidgets . QHBoxLayout ( )
@ -792,7 +817,8 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
exit ( )
def spinBoxValueChanged ( self ) :
self . label . setText ( self . midiToNotename ( self . spinBox . value ( ) ) )
self . label . setText ( self . midiToNotename ( self . spinBox . value ( ) ) )
self . parentItem . sendToEngine ( callback = False )
def spinBoxEditingFinished ( self ) :
if not self . rememberLastValue == self . spinBox . value ( ) :