Skip to content

Commit 7013d2c

Browse files
Fix keyframe timeline seeker being in the wrong place when switching layers
1 parent fa925c4 commit 7013d2c

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/UI/Timeline/KeyframeTimeline/KeyframeTimeline.gd

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ static var selected_keyframes: Array[int]
99
var current_layer: BaseLayer:
1010
set(value):
1111
if is_instance_valid(current_layer):
12-
if current_layer.effects_added_removed.is_connected(recreate_timeline):
13-
current_layer.effects_added_removed.disconnect(recreate_timeline)
12+
if current_layer.effects_added_removed.is_connected(_on_effects_added_removed):
13+
current_layer.effects_added_removed.disconnect(_on_effects_added_removed)
1414
current_layer = value
1515
recreate_timeline()
16-
current_layer.effects_added_removed.connect(recreate_timeline)
16+
current_layer.effects_added_removed.connect(_on_effects_added_removed)
1717
await get_tree().process_frame
18-
keyframe_timeline_cursor.update_position()
1918
await get_tree().process_frame
19+
keyframe_timeline_cursor.update_position()
2020
var v_scroll := track_scroll_container.scroll_vertical
2121
track_scroll_container.ensure_control_visible(keyframe_timeline_cursor)
2222
track_scroll_container.scroll_vertical = v_scroll
@@ -87,6 +87,12 @@ func _on_cel_switched() -> void:
8787
unselect_keyframe()
8888

8989

90+
func _on_effects_added_removed() -> void:
91+
# Await is needed so that the params get added to the layer effect.
92+
await get_tree().process_frame
93+
recreate_timeline()
94+
95+
9096
func _on_project_about_to_switch() -> void:
9197
var project := Global.current_project
9298
project.frames_updated.disconnect(_add_ui_frames)
@@ -115,8 +121,6 @@ func recreate_timeline() -> void:
115121
for child in track_container.get_children():
116122
child.queue_free()
117123
#region Add tracks for animatable objects.
118-
# Await is needed so that the params get added to the layer effect.
119-
await get_tree().process_frame
120124
for effect in current_layer.effects:
121125
var effect_item := add_section(effect.name, KeyframeAnimationTrack.TrackTypes.LAYER_EFFECT)
122126
for param_name in effect.params:
@@ -130,7 +134,6 @@ func recreate_timeline() -> void:
130134
)
131135
#endregion
132136
select_keyframes()
133-
await get_tree().process_frame
134137
track_scroll_container.scroll_horizontal = h_scroll
135138
track_scroll_container.scroll_vertical = v_scroll
136139
# Hide UI which is un-usable
@@ -498,6 +501,7 @@ func _on_track_scroll_container_resized() -> void:
498501
var r_marg := properties_container.size.x if properties_container.is_visible_in_tree() else 0.0
499502
margin_container.add_theme_constant_override(&"margin_left", l_marg + split_separation)
500503
margin_container.add_theme_constant_override(&"margin_right", r_marg + split_separation)
504+
keyframe_timeline_cursor.update_position()
501505

502506

503507
func _on_track_scroll_container_sort_children() -> void:

0 commit comments

Comments
 (0)