fix: let lock mode scrub audio timeline playhead
This commit is contained in:
@@ -2617,8 +2617,10 @@ class TimelineWidget(QWidget):
|
||||
self._sb_drag_offset = thumb_w / 2
|
||||
self.update()
|
||||
return
|
||||
# Audio mode: dragging/resizing the teal band takes priority over seeking.
|
||||
# Audio mode: dragging/resizing the teal band takes priority over seeking,
|
||||
# except in lock mode where clicks scrub playback without moving regions.
|
||||
if (self._audio_mode and self._audio_region is not None
|
||||
and not self._locked
|
||||
and event.button() == Qt.MouseButton.LeftButton):
|
||||
self._audio_begin_drag_at_x(x)
|
||||
if self._audio_drag is not None:
|
||||
|
||||
@@ -371,6 +371,42 @@ def test_timeline_audio_hover_cursor_state(win):
|
||||
assert tl._audio_hit_at_x(tl._time_to_x(12.0)) == "create"
|
||||
|
||||
|
||||
def test_timeline_audio_mode_lock_click_scrubs_playhead_not_region(win):
|
||||
from PyQt6.QtCore import QEvent, QPointF, Qt
|
||||
from PyQt6.QtGui import QMouseEvent
|
||||
tl = win._timeline
|
||||
tl._duration = 20.0
|
||||
tl._view_start = 0.0
|
||||
tl._view_span = 20.0
|
||||
tl.resize(400, tl.height() or 80)
|
||||
tl.set_audio_mode(True)
|
||||
tl.set_audio_region(4.0, 8.0)
|
||||
tl.set_cursor(4.0)
|
||||
tl._locked = True
|
||||
got_seek = []
|
||||
got_audio = []
|
||||
tl.seek_changed.connect(lambda t: got_seek.append(t))
|
||||
tl.audio_region_changed.connect(lambda s, e: got_audio.append((s, e)))
|
||||
|
||||
x = tl._time_to_x(12.0)
|
||||
y = tl._SCROLLBAR_H + tl._RULER_H + 20
|
||||
press = QMouseEvent(
|
||||
QEvent.Type.MouseButtonPress, QPointF(x, y),
|
||||
Qt.MouseButton.LeftButton, Qt.MouseButton.LeftButton,
|
||||
Qt.KeyboardModifier.NoModifier)
|
||||
release = QMouseEvent(
|
||||
QEvent.Type.MouseButtonRelease, QPointF(x, y),
|
||||
Qt.MouseButton.LeftButton, Qt.MouseButton.NoButton,
|
||||
Qt.KeyboardModifier.NoModifier)
|
||||
tl.mousePressEvent(press)
|
||||
tl.mouseReleaseEvent(release)
|
||||
|
||||
assert abs((tl._play_pos or 0.0) - 12.0) < 0.1
|
||||
assert tl._audio_region == (4.0, 8.0)
|
||||
assert not got_audio
|
||||
assert got_seek and abs(got_seek[-1] - 12.0) < 0.1
|
||||
|
||||
|
||||
def test_timeline_audio_mode_follows_deck(win):
|
||||
win._control_deck.setCurrentWidget(win._tab_audio)
|
||||
assert win._timeline._audio_mode is True
|
||||
|
||||
Reference in New Issue
Block a user