Leave only one track type, WIP: track deletion.

This commit is contained in:
2025-07-27 23:52:25 +02:00
parent 90e85f5404
commit ecadfb7033
15 changed files with 190 additions and 218 deletions

View File

@@ -40,8 +40,19 @@ func format_time_ms_minutes(ms: float) -> String:
func _ready():
await get_tree().process_frame
queue_redraw()
for c in track_list.get_children():
if c is Track:
var track = c as Track
track.on_deleted.connect(_track_deleted)
pass
pass
func _track_deleted(idx: int):
print("track deleted")
await get_tree().process_frame
queue_redraw()
pass
func get_track_idx_by_y(y: float):
var idx = 0
@@ -97,7 +108,7 @@ func _draw():
draw_line(Vector2(x, 28.0), Vector2(x, timeline_y), secondary_color, line_thickness)
pass
# track lines
# track horizontal lines
for t in track_list.get_children():
draw_line(Vector2(0.0, t.global_position.y - global_position.y + t.size.y), Vector2(size.x, t.global_position.y - global_position.y + t.size.y), secondary_color, line_thickness)
pass
@@ -163,4 +174,4 @@ func add_audio_clip(path: String, clip_name: String, track_idx: int, clip_start_
clip_added.emit(audio_clip)
queue_redraw()
pass
pass

View File

@@ -1,7 +1,45 @@
class_name Track
extends Control
extends Button
signal on_deleted
signal on_renamed
signal on_duplicated
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
var menu: PopupMenu = $PopupMenu
menu.add_item("Rename", 0)
menu.add_item("Delete", 1)
menu.add_item("Duplicate", 2)
menu.id_pressed.connect(_on_menu_option)
func _on_menu_option(id: int):
match id:
0:
rename()
1:
delete()
2:
duplicate_track()
pass
func delete():
queue_free()
var idx = get_index()
print(idx)
on_deleted.emit(idx)
pass
func rename():
%TrackName.grab_focus()
pass
func duplicate_track():
pass
func _gui_input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_RIGHT and event.pressed:
var popup = %PopupMenu
#%PopupMenu.popup(get_global_mouse_position())
var pos = get_global_mouse_position()
var rect = Rect2i(pos, popup.get_contents_minimum_size())
popup.popup(rect)

9
Scripts/TrackLineEdit.gd Normal file
View File

@@ -0,0 +1,9 @@
extends LineEdit
func _ready() -> void:
text_submitted.connect(submit)
func submit(text: String):
caret_column = 0
release_focus()
pass

View File

@@ -0,0 +1 @@
uid://dxqa86sq21uac