feat: improve audio region timeline picking
This commit is contained in:
@@ -321,6 +321,56 @@ def test_timeline_audio_band_resize_right(win):
|
||||
tl.set_audio_mode(False)
|
||||
|
||||
|
||||
def test_timeline_audio_click_outside_moves_region_start(win):
|
||||
tl = win._timeline
|
||||
win._file_path = "/x/v.mp4"
|
||||
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)
|
||||
got = []
|
||||
tl.audio_region_changed.connect(lambda s, e: got.append((s, e)))
|
||||
tl._audio_begin_drag_at_x(tl._time_to_x(12.0))
|
||||
tl._audio_end_drag()
|
||||
assert got[-1] == tl._audio_region
|
||||
s, e = tl._audio_region
|
||||
assert abs(s - 12.0) < 0.1
|
||||
assert abs((e - s) - 4.0) < 0.1
|
||||
|
||||
|
||||
def test_timeline_audio_drag_empty_creates_region(win):
|
||||
tl = win._timeline
|
||||
win._file_path = "/x/v.mp4"
|
||||
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._audio_begin_drag_at_x(tl._time_to_x(12.0))
|
||||
tl._audio_drag_to_x(tl._time_to_x(15.0))
|
||||
tl._audio_end_drag()
|
||||
s, e = tl._audio_region
|
||||
assert abs(s - 12.0) < 0.1
|
||||
assert abs(e - 15.0) < 0.1
|
||||
|
||||
|
||||
def test_timeline_audio_hover_cursor_state(win):
|
||||
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)
|
||||
assert tl._audio_hit_at_x(tl._time_to_x(4.0)) == "left"
|
||||
assert tl._audio_hit_at_x(tl._time_to_x(8.0)) == "right"
|
||||
assert tl._audio_hit_at_x(tl._time_to_x(6.0)) == "move"
|
||||
assert tl._audio_hit_at_x(tl._time_to_x(12.0)) == "create"
|
||||
|
||||
|
||||
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