Finalize audio clip movement, fix being able to drag audio clips out of bounds.
This commit is contained in:
@@ -35,6 +35,11 @@ func format_time_ms_minutes(ms: float) -> String:
|
||||
var milliseconds = fmod(ms, 1000.0)
|
||||
return "%02d:%02d.%03d" % [minutes, seconds, milliseconds]
|
||||
|
||||
func _ready():
|
||||
await get_tree().process_frame
|
||||
queue_redraw()
|
||||
pass
|
||||
|
||||
|
||||
func get_track_idx_by_y(y: float):
|
||||
var idx = 0
|
||||
@@ -133,14 +138,13 @@ func _gui_input(event):
|
||||
time_offset = max(0.0, time_offset)
|
||||
|
||||
func local_x_to_timeline(x: float) -> float:
|
||||
return (x / get_pixels_per_unit()) * time_interval + time_offset
|
||||
return (x + time_offset) / get_pixels_per_unit() * time_interval
|
||||
|
||||
|
||||
func clip_dropped(at_position: Vector2, clip_name: String, clip_start_time: float, clip_end_time: float):
|
||||
var local_position = at_position - global_position
|
||||
var timeline_position = local_x_to_timeline(local_position.x)
|
||||
print(timeline_position)
|
||||
print(time_offset)
|
||||
|
||||
var track_idx = get_track_idx_by_y(at_position.y)
|
||||
add_audio_clip(clip_name, track_idx, timeline_position + clip_start_time, timeline_position + clip_end_time)
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user