feat: move audio editor selection with ctrl drag
This commit is contained in:
@@ -671,6 +671,43 @@ def test_waveform_click_sets_playhead_without_changing_selection(win):
|
||||
assert abs((w.playhead() or 0.0) - 7.0) < 0.05
|
||||
|
||||
|
||||
def test_waveform_ctrl_drag_moves_selection_without_moving_playhead(win):
|
||||
from PyQt6.QtCore import QEvent, QPointF, Qt
|
||||
from PyQt6.QtGui import QMouseEvent
|
||||
w = win._wave
|
||||
w.resize(400, 96)
|
||||
w.set_view(0.0, 10.0)
|
||||
w.set_selection(2.0, 4.0)
|
||||
w.set_playhead(7.0)
|
||||
got_sel = []
|
||||
got_play = []
|
||||
w.selection_changed.connect(lambda s, e: got_sel.append((s, e)))
|
||||
w.playhead_changed.connect(lambda t: got_play.append(t))
|
||||
|
||||
press = QMouseEvent(
|
||||
QEvent.Type.MouseButtonPress, QPointF(w._t_to_px(3.0), 20),
|
||||
Qt.MouseButton.LeftButton, Qt.MouseButton.LeftButton,
|
||||
Qt.KeyboardModifier.ControlModifier)
|
||||
move = QMouseEvent(
|
||||
QEvent.Type.MouseMove, QPointF(w._t_to_px(5.0), 20),
|
||||
Qt.MouseButton.NoButton, Qt.MouseButton.LeftButton,
|
||||
Qt.KeyboardModifier.ControlModifier)
|
||||
release = QMouseEvent(
|
||||
QEvent.Type.MouseButtonRelease, QPointF(w._t_to_px(5.0), 20),
|
||||
Qt.MouseButton.LeftButton, Qt.MouseButton.NoButton,
|
||||
Qt.KeyboardModifier.ControlModifier)
|
||||
w.mousePressEvent(press)
|
||||
w.mouseMoveEvent(move)
|
||||
w.mouseReleaseEvent(release)
|
||||
|
||||
s, e = w.selection()
|
||||
assert abs(s - 4.0) < 0.05
|
||||
assert abs(e - 6.0) < 0.05
|
||||
assert got_sel and abs(got_sel[-1][0] - 4.0) < 0.05
|
||||
assert got_play == []
|
||||
assert abs((w.playhead() or 0.0) - 7.0) < 0.05
|
||||
|
||||
|
||||
def test_waveform_drag_emits_selection(win):
|
||||
w = win._wave
|
||||
w.resize(400, 96)
|
||||
|
||||
Reference in New Issue
Block a user