@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from time import time
from time import time
import engine . api as api #Session is already loaded and created, no duplication.
import engine . api as api #Session is already loaded and created, no duplication.
from template . engine import pitch
from template . engine import pitch
from PyQt5 import QtCore , QtGui , QtWidgets
from PyQt5 import QtCore , QtGui , QtWidgets , QtOpenGL
SIZE_UNIT = 40
SIZE_UNIT = 40
SIZE_TOP_OFFSET = 75
SIZE_TOP_OFFSET = 75
@ -349,10 +349,32 @@ class PatternGrid(QtWidgets.QGraphicsScene):
self . _zoomFactor = max ( 0.1 , round ( self . _zoomFactor - 0.25 , 2 ) )
self . _zoomFactor = max ( 0.1 , round ( self . _zoomFactor - 0.25 , 2 ) )
self . _zoom ( event )
self . _zoom ( event )
event . accept ( )
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 :
else :
event . ignore ( )
event . ignore ( )
super ( ) . wheelEvent ( event )
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 ) :
def _zoom ( self , event ) :
if 0.1 < self . _zoomFactor < 5 :
if 0.1 < self . _zoomFactor < 5 :
self . parentView . resetTransform ( )
self . parentView . resetTransform ( )
@ -623,10 +645,12 @@ class Scale(QtWidgets.QGraphicsRectItem):
for pitchWidget in self . pitchWidgets :
for pitchWidget in self . pitchWidgets :
pitchWidget . spinBoxValueChanged ( ) #change all current 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 = [ widget . spinBox . value ( ) for widget in self . pitchWidgets ]
#result.reverse()
#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 ) :
class TransposeControls ( QtWidgets . QWidget ) :
""" Communication with the scale spinBoxes is done via api callbacks. We just fire and forget """
""" Communication with the scale spinBoxes is done via api callbacks. We just fire and forget """
@ -745,6 +769,7 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
self . spinBox . stepBy = self . stepBy
self . spinBox . stepBy = self . stepBy
#self.spinBox.setValue(0) #No init value. This is changed on active track callback
#self.spinBox.setValue(0) #No init value. This is changed on active track callback
widget = QtWidgets . QWidget ( )
widget = QtWidgets . QWidget ( )
layout = QtWidgets . QHBoxLayout ( )
layout = QtWidgets . QHBoxLayout ( )
layout . setSpacing ( 0 )
layout . setSpacing ( 0 )
@ -793,6 +818,7 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
def spinBoxValueChanged ( self ) :
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 ) :
def spinBoxEditingFinished ( self ) :
if not self . rememberLastValue == self . spinBox . value ( ) :
if not self . rememberLastValue == self . spinBox . value ( ) :