Browse Source

Fix regressions when changing the pitch widget with the mousewheel

master
Nils 5 years ago
parent
commit
95f06345cc
  1. 20
      qtgui/pattern_grid.py

20
qtgui/pattern_grid.py

@ -637,7 +637,8 @@ class Scale(QtWidgets.QGraphicsRectItem):
widget.rememberLastValue = scaleMidiPitch
def setNoteNames(self, pNoteNames):
"""A list of 128 strings. Gets only called by the callback."""
"""A list of 128 strings. Gets only called by the callback.
E.g. it happens when you switch the active gui track"""
#if pNoteNames in pitch.notenames.keys():
# self.simpleNoteNames = pitch.notenames[pNoteNames]
#else:
@ -787,6 +788,8 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
self.setWidget(widget)
self.spinBox.wheelEvent = self.spinBoxMouseWheelEvent
self.spinBox.valueChanged.connect(self.spinBoxValueChanged)
self.spinBox.editingFinished.connect(self.spinBoxEditingFinished)
#self.spinBoxValueChanged() #Delay that. The engine Data is not ready yet. It will be sent by the callback
@ -818,7 +821,7 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
def spinBoxValueChanged(self):
self.label.setText(self.midiToNotename(self.spinBox.value()))
self.parentItem.sendToEngine(callback=False)
#self.parentItem.sendToEngine(callback=False) # results in a loop with callback, and in wrong data without. This is not the right place to implement immediate note feedback while editing is still going on.
def spinBoxEditingFinished(self):
if not self.rememberLastValue == self.spinBox.value():
@ -834,6 +837,19 @@ class PitchWidget(QtWidgets.QGraphicsProxyWidget):
else:
QtWidgets.QAbstractSpinBox.stepBy(self.spinBox, n)
def spinBoxMouseWheelEvent(self, event):
"""We cannot use spinBoxValueChanged to send mousewheel scrolling pitch changing directly
to the engine while editing is still active. this results in signal loops and various
data corruptions. Fixing this would be far too much work.
You can either use the arrow keys and press enter, which triggers editingFinished.
But here we intercept the mousewheel directly."""
event.ignore()
QtWidgets.QSpinBox.wheelEvent(self.spinBox, event) #this changes to the new text and therefore the new value. Call BEFORE sendToEngine
self.parentItem.sendToEngine(callback=False)
#if event.angleDelta().y() > 0: #up
#else: #down
class Playhead(QtWidgets.QGraphicsLineItem):
def __init__(self, parentScene):
super().__init__(0, 0, 0, api.NUMBER_OF_STEPS*SIZE_UNIT) # (x1, y1, x2, y2)

Loading…
Cancel
Save