Add track moving to audio clips
This commit is contained in:
@@ -35,6 +35,18 @@ func format_time_ms_minutes(ms: float) -> String:
|
||||
return "%02d:%02d.%03d" % [minutes, seconds, milliseconds]
|
||||
|
||||
|
||||
func get_track_idx_by_y(y: float):
|
||||
var idx = 0
|
||||
for track in track_list.get_children():
|
||||
if y >= track.global_position.y and y <= track.global_position.y + track.size.y:
|
||||
return idx
|
||||
idx += 1
|
||||
pass
|
||||
return -1
|
||||
|
||||
func get_track_by_idx(idx: int) -> Control:
|
||||
return track_list.get_child(idx)
|
||||
|
||||
func get_pixels_per_unit() -> float:
|
||||
return 50.0 * zoom
|
||||
|
||||
@@ -82,12 +94,17 @@ func _notification(what):
|
||||
if what == NOTIFICATION_SORT_CHILDREN:
|
||||
for c in get_children():
|
||||
if c is not AudioClip: continue
|
||||
|
||||
var track = get_track_by_idx(c.track_idx)
|
||||
|
||||
if track == null: return
|
||||
|
||||
var pixels_per_unit := 50.0 * zoom
|
||||
var start = ((c.start_time / time_interval) * pixels_per_unit) - time_offset
|
||||
var width = (c.end_time - c.start_time) / time_interval * pixels_per_unit
|
||||
|
||||
c.position = Vector2(start, 0.0)
|
||||
c.size = Vector2(width, c.size.y)
|
||||
c.position = Vector2(start, track.global_position.y - global_position.y)
|
||||
c.size = Vector2(width, track.size.y)
|
||||
|
||||
func _gui_input(event):
|
||||
var zoom_factor = 1.1
|
||||
|
||||
Reference in New Issue
Block a user