Proper grid snapping for audio clips, adjust audio clip and timeline styling
This commit is contained in:
@@ -4438,7 +4438,7 @@ TextEdit/styles/read_only = SubResource("StyleBoxFlat_6ucq2")
|
|||||||
ThemeEditor/colors/preview_picker_overlay_color = Color(0.1, 0.1, 0.1, 0.25)
|
ThemeEditor/colors/preview_picker_overlay_color = Color(0.1, 0.1, 0.1, 0.25)
|
||||||
ThemeEditor/styles/preview_picker_label = SubResource("StyleBoxFlat_jtsa3")
|
ThemeEditor/styles/preview_picker_label = SubResource("StyleBoxFlat_jtsa3")
|
||||||
ThemeEditor/styles/preview_picker_overlay = SubResource("StyleBoxFlat_qixj3")
|
ThemeEditor/styles/preview_picker_overlay = SubResource("StyleBoxFlat_qixj3")
|
||||||
Timeline/colors/line_primary_color = Color(0.4, 0.4, 0.4, 1)
|
Timeline/colors/line_primary_color = Color(0.25, 0.25, 0.25, 1)
|
||||||
Timeline/colors/line_secondary_color = Color(0.2, 0.2, 0.2, 1)
|
Timeline/colors/line_secondary_color = Color(0.2, 0.2, 0.2, 1)
|
||||||
Timeline/constants/time_label_offset_x = 30
|
Timeline/constants/time_label_offset_x = 30
|
||||||
Timeline/constants/time_label_offset_y = 20
|
Timeline/constants/time_label_offset_y = 20
|
||||||
|
|||||||
@@ -23,10 +23,11 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_8tb17")
|
|||||||
script = ExtResource("1_iy5jd")
|
script = ExtResource("1_iy5jd")
|
||||||
|
|
||||||
[node name="Panel" type="Panel" parent="."]
|
[node name="Panel" type="Panel" parent="."]
|
||||||
custom_minimum_size = Vector2(0, 14)
|
custom_minimum_size = Vector2(0, 20)
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 10
|
anchors_preset = 10
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
offset_bottom = 20.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="Panel"]
|
[node name="Label" type="Label" parent="Panel"]
|
||||||
@@ -36,7 +37,29 @@ anchor_right = 1.0
|
|||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme_override_font_sizes/font_size = 8
|
theme_override_font_sizes/font_size = 10
|
||||||
text = "New Audio Clip"
|
text = "New Audio Clip"
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
text_overrun_behavior = 3
|
text_overrun_behavior = 3
|
||||||
|
|
||||||
|
[node name="Window" type="ConfirmationDialog" parent="."]
|
||||||
|
title = "\"New Audio Clip\" Properties"
|
||||||
|
size = Vector2i(400, 600)
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="Window"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 8.0
|
||||||
|
offset_right = 92.0
|
||||||
|
offset_bottom = 51.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Window/Control"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 23.0
|
||||||
|
text = "Clip properties!"
|
||||||
|
|
||||||
|
[connection signal="on_double_click" from="." to="Window" method="popup_centered"]
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
class_name AudioClip
|
class_name AudioClip
|
||||||
extends Panel
|
extends Panel
|
||||||
|
|
||||||
|
@export var clip_name: String = "New Audio Clip"
|
||||||
@export var start_time: float = 0.0
|
@export var start_time: float = 0.0
|
||||||
@export var end_time: float = 0.0
|
@export var end_time: float = 0.0
|
||||||
@export var track_idx: int = 0
|
@export var track_idx: int = 0
|
||||||
|
|
||||||
|
signal on_selected
|
||||||
|
signal on_deselected
|
||||||
|
signal on_double_click
|
||||||
|
|
||||||
var timeline: Timeline
|
var timeline: Timeline
|
||||||
|
|
||||||
var dragging: bool
|
var dragging: bool
|
||||||
@@ -18,13 +23,17 @@ func _input(event):
|
|||||||
var mouse_position = get_global_mouse_position()
|
var mouse_position = get_global_mouse_position()
|
||||||
|
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
|
if selected and event.double_click:
|
||||||
|
print("double clicked!")
|
||||||
|
on_double_click.emit()
|
||||||
|
return
|
||||||
if event.pressed and event.button_mask == MOUSE_BUTTON_LEFT:
|
if event.pressed and event.button_mask == MOUSE_BUTTON_LEFT:
|
||||||
if selected:
|
if selected:
|
||||||
mouse_default_cursor_shape = CURSOR_MOVE
|
Input.set_default_cursor_shape(Input.CursorShape.CURSOR_MOVE)
|
||||||
dragging = true
|
dragging = true
|
||||||
else:
|
else:
|
||||||
dragging = false
|
dragging = false
|
||||||
mouse_default_cursor_shape = CURSOR_ARROW
|
Input.set_default_cursor_shape(Input.CursorShape.CURSOR_ARROW)
|
||||||
if rect.has_point(mouse_position):
|
if rect.has_point(mouse_position):
|
||||||
selected = true
|
selected = true
|
||||||
make_selected()
|
make_selected()
|
||||||
@@ -36,28 +45,33 @@ func _input(event):
|
|||||||
|
|
||||||
if !event.pressed and dragging:
|
if !event.pressed and dragging:
|
||||||
dragging = false
|
dragging = false
|
||||||
mouse_default_cursor_shape = CURSOR_ARROW
|
Input.set_default_cursor_shape(Input.CursorShape.CURSOR_ARROW)
|
||||||
|
|
||||||
if selected and dragging:
|
if selected and dragging:
|
||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
var movement = event.relative.x / timeline.get_pixels_per_unit() * timeline.time_interval
|
var movement = event.relative.x / timeline.get_pixels_per_unit() * timeline.time_interval
|
||||||
|
var mouse_position_timeline = (timeline.get_local_mouse_position().x / timeline.get_pixels_per_unit()) * timeline.time_interval
|
||||||
start_time += movement
|
var mouse_position_snapped = snapped(mouse_position_timeline, timeline.time_interval)
|
||||||
end_time += movement
|
|
||||||
|
|
||||||
if event.is_command_or_control_pressed():
|
if event.is_command_or_control_pressed():
|
||||||
start_time = snapped(start_time, timeline.time_interval)
|
var clip_length = end_time - start_time
|
||||||
end_time = snapped(end_time, timeline.time_interval)
|
start_time = mouse_position_snapped
|
||||||
|
end_time = start_time + clip_length
|
||||||
|
else:
|
||||||
|
start_time += movement
|
||||||
|
end_time += movement
|
||||||
|
|
||||||
timeline.queue_sort()
|
timeline.queue_sort()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func make_selected():
|
func make_selected():
|
||||||
|
on_selected.emit()
|
||||||
var color = get_theme_color("selected_modulate", "AudioClip")
|
var color = get_theme_color("selected_modulate", "AudioClip")
|
||||||
modulate = color
|
modulate = color
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func make_deselected():
|
func make_deselected():
|
||||||
|
on_deselected.emit()
|
||||||
var color = get_theme_color("deselected_modulate", "AudioClip")
|
var color = get_theme_color("deselected_modulate", "AudioClip")
|
||||||
modulate = color
|
modulate = color
|
||||||
pass
|
pass
|
||||||
@@ -22,10 +22,9 @@ layout_mode = 2
|
|||||||
|
|
||||||
[node name="AudioClip" parent="." instance=ExtResource("2_an2hv")]
|
[node name="AudioClip" parent="." instance=ExtResource("2_an2hv")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
start_time = 4000.0
|
end_time = 1000.0
|
||||||
end_time = 8000.0
|
|
||||||
|
|
||||||
[node name="AudioClip2" parent="." instance=ExtResource("2_an2hv")]
|
[node name="AudioClip2" parent="." instance=ExtResource("2_an2hv")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
start_time = 8000.0
|
start_time = 3000.0
|
||||||
end_time = 12000.0
|
end_time = 10000.0
|
||||||
|
|||||||
Reference in New Issue
Block a user