@@ -3615,7 +3615,8 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim, bool p_re
3615
3615
_update_step_spinbox ();
3616
3616
step->set_block_signals (false );
3617
3617
step->set_read_only (false );
3618
- snap->set_disabled (false );
3618
+ snap_keys->set_disabled (false );
3619
+ snap_timeline->set_disabled (false );
3619
3620
snap_mode->set_disabled (false );
3620
3621
auto_fit->set_disabled (false );
3621
3622
auto_fit_bezier->set_disabled (false );
@@ -3636,7 +3637,8 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim, bool p_re
3636
3637
step->set_value (0 );
3637
3638
step->set_block_signals (false );
3638
3639
step->set_read_only (true );
3639
- snap->set_disabled (true );
3640
+ snap_keys->set_disabled (true );
3641
+ snap_timeline->set_disabled (true );
3640
3642
snap_mode->set_disabled (true );
3641
3643
bezier_edit_icon->set_disabled (true );
3642
3644
auto_fit->set_disabled (true );
@@ -4555,8 +4557,12 @@ bool AnimationTrackEditor::is_key_clipboard_active() const {
4555
4557
return key_clipboard.keys .size ();
4556
4558
}
4557
4559
4558
- bool AnimationTrackEditor::is_snap_enabled () const {
4559
- return snap->is_pressed () ^ Input::get_singleton ()->is_key_pressed (Key::CMD_OR_CTRL);
4560
+ bool AnimationTrackEditor::is_snap_timeline_enabled () const {
4561
+ return snap_timeline->is_pressed () ^ Input::get_singleton ()->is_key_pressed (Key::CMD_OR_CTRL);
4562
+ }
4563
+
4564
+ bool AnimationTrackEditor::is_snap_keys_enabled () const {
4565
+ return snap_keys->is_pressed () ^ Input::get_singleton ()->is_key_pressed (Key::CMD_OR_CTRL);
4560
4566
}
4561
4567
4562
4568
bool AnimationTrackEditor::is_bezier_editor_active () const {
@@ -4896,7 +4902,8 @@ void AnimationTrackEditor::_notification(int p_what) {
4896
4902
case NOTIFICATION_THEME_CHANGED: {
4897
4903
zoom_icon->set_texture (get_editor_theme_icon (SNAME (" Zoom" )));
4898
4904
bezier_edit_icon->set_icon (get_editor_theme_icon (SNAME (" EditBezier" )));
4899
- snap->set_icon (get_editor_theme_icon (SNAME (" Snap" )));
4905
+ snap_timeline->set_icon (get_editor_theme_icon (SNAME (" SnapTimeline" )));
4906
+ snap_keys->set_icon (get_editor_theme_icon (SNAME (" SnapKeys" )));
4900
4907
view_group->set_icon (get_editor_theme_icon (view_group->is_pressed () ? SNAME (" AnimationTrackList" ) : SNAME (" AnimationTrackGroup" )));
4901
4908
selected_filter->set_icon (get_editor_theme_icon (SNAME (" AnimationFilter" )));
4902
4909
imported_anim_warning->set_icon (get_editor_theme_icon (SNAME (" NodeWarning" )));
@@ -5217,7 +5224,7 @@ int AnimationTrackEditor::_get_track_selected() {
5217
5224
void AnimationTrackEditor::_insert_key_from_track (float p_ofs, int p_track) {
5218
5225
ERR_FAIL_INDEX (p_track, animation->get_track_count ());
5219
5226
5220
- if (snap ->is_pressed () && step->get_value () != 0 ) {
5227
+ if (snap_keys ->is_pressed () && step->get_value () != 0 ) {
5221
5228
p_ofs = snap_time (p_ofs);
5222
5229
}
5223
5230
while (animation->track_find_key (p_track, p_ofs, Animation::FIND_MODE_APPROX) != -1 ) { // Make sure insertion point is valid.
@@ -5840,7 +5847,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(float p_ofs, bool p_ofs_valid, i
5840
5847
float insert_pos = p_ofs_valid ? p_ofs : timeline->get_play_position ();
5841
5848
5842
5849
if (p_ofs_valid) {
5843
- if (snap ->is_pressed () && step->get_value () != 0 ) {
5850
+ if (snap_keys ->is_pressed () && step->get_value () != 0 ) {
5844
5851
insert_pos = snap_time (insert_pos);
5845
5852
}
5846
5853
}
@@ -5988,7 +5995,7 @@ void AnimationTrackEditor::_anim_paste_keys(float p_ofs, bool p_ofs_valid, int p
5988
5995
float insert_pos = p_ofs_valid ? p_ofs : timeline->get_play_position ();
5989
5996
5990
5997
if (p_ofs_valid) {
5991
- if (snap ->is_pressed () && step->get_value () != 0 ) {
5998
+ if (snap_keys ->is_pressed () && step->get_value () != 0 ) {
5992
5999
insert_pos = snap_time (insert_pos);
5993
6000
}
5994
6001
}
@@ -7069,7 +7076,7 @@ void AnimationTrackEditor::_update_snap_unit() {
7069
7076
}
7070
7077
7071
7078
float AnimationTrackEditor::snap_time (float p_value, bool p_relative) {
7072
- if (is_snap_enabled ()) {
7079
+ if (is_snap_keys_enabled ()) {
7073
7080
if (Input::get_singleton ()->is_key_pressed (Key::SHIFT)) {
7074
7081
// Use more precise snapping when holding Shift.
7075
7082
snap_unit *= 0.25 ;
@@ -7323,13 +7330,21 @@ AnimationTrackEditor::AnimationTrackEditor() {
7323
7330
bottom_hb->add_child (view_group);
7324
7331
bottom_hb->add_child (memnew (VSeparator));
7325
7332
7326
- snap = memnew (Button );
7327
- snap->set_flat (true );
7328
- snap->set_text (TTR (" Snap:" ) + " " );
7329
- bottom_hb->add_child (snap);
7330
- snap->set_disabled (true );
7331
- snap->set_toggle_mode (true );
7332
- snap->set_pressed (true );
7333
+ snap_timeline = memnew (Button );
7334
+ snap_timeline->set_flat (true );
7335
+ bottom_hb->add_child (snap_timeline);
7336
+ snap_timeline->set_disabled (true );
7337
+ snap_timeline->set_toggle_mode (true );
7338
+ snap_timeline->set_pressed (false );
7339
+ snap_timeline->set_tooltip_text (TTR (" Apply snapping to timeline cursor." ));
7340
+
7341
+ snap_keys = memnew (Button );
7342
+ snap_keys->set_flat (true );
7343
+ bottom_hb->add_child (snap_keys);
7344
+ snap_keys->set_disabled (true );
7345
+ snap_keys->set_toggle_mode (true );
7346
+ snap_keys->set_pressed (true );
7347
+ snap_keys->set_tooltip_text (TTR (" Apply snapping to selected key(s)." ));
7333
7348
7334
7349
step = memnew (EditorSpinSlider);
7335
7350
step->set_min (0 );
0 commit comments