@@ -3615,7 +3615,8 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim, bool p_re
36153615 _update_step_spinbox ();
36163616 step->set_block_signals (false );
36173617 step->set_read_only (false );
3618- snap->set_disabled (false );
3618+ snap_keys->set_disabled (false );
3619+ snap_timeline->set_disabled (false );
36193620 snap_mode->set_disabled (false );
36203621 auto_fit->set_disabled (false );
36213622 auto_fit_bezier->set_disabled (false );
@@ -3636,7 +3637,8 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim, bool p_re
36363637 step->set_value (0 );
36373638 step->set_block_signals (false );
36383639 step->set_read_only (true );
3639- snap->set_disabled (true );
3640+ snap_keys->set_disabled (true );
3641+ snap_timeline->set_disabled (true );
36403642 snap_mode->set_disabled (true );
36413643 bezier_edit_icon->set_disabled (true );
36423644 auto_fit->set_disabled (true );
@@ -4555,8 +4557,12 @@ bool AnimationTrackEditor::is_key_clipboard_active() const {
45554557 return key_clipboard.keys .size ();
45564558}
45574559
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);
45604566}
45614567
45624568bool AnimationTrackEditor::is_bezier_editor_active () const {
@@ -4896,7 +4902,8 @@ void AnimationTrackEditor::_notification(int p_what) {
48964902 case NOTIFICATION_THEME_CHANGED: {
48974903 zoom_icon->set_texture (get_editor_theme_icon (SNAME (" Zoom" )));
48984904 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" )));
49004907 view_group->set_icon (get_editor_theme_icon (view_group->is_pressed () ? SNAME (" AnimationTrackList" ) : SNAME (" AnimationTrackGroup" )));
49014908 selected_filter->set_icon (get_editor_theme_icon (SNAME (" AnimationFilter" )));
49024909 imported_anim_warning->set_icon (get_editor_theme_icon (SNAME (" NodeWarning" )));
@@ -5217,7 +5224,7 @@ int AnimationTrackEditor::_get_track_selected() {
52175224void AnimationTrackEditor::_insert_key_from_track (float p_ofs, int p_track) {
52185225 ERR_FAIL_INDEX (p_track, animation->get_track_count ());
52195226
5220- if (snap ->is_pressed () && step->get_value () != 0 ) {
5227+ if (snap_keys ->is_pressed () && step->get_value () != 0 ) {
52215228 p_ofs = snap_time (p_ofs);
52225229 }
52235230 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
58405847 float insert_pos = p_ofs_valid ? p_ofs : timeline->get_play_position ();
58415848
58425849 if (p_ofs_valid) {
5843- if (snap ->is_pressed () && step->get_value () != 0 ) {
5850+ if (snap_keys ->is_pressed () && step->get_value () != 0 ) {
58445851 insert_pos = snap_time (insert_pos);
58455852 }
58465853 }
@@ -5988,7 +5995,7 @@ void AnimationTrackEditor::_anim_paste_keys(float p_ofs, bool p_ofs_valid, int p
59885995 float insert_pos = p_ofs_valid ? p_ofs : timeline->get_play_position ();
59895996
59905997 if (p_ofs_valid) {
5991- if (snap ->is_pressed () && step->get_value () != 0 ) {
5998+ if (snap_keys ->is_pressed () && step->get_value () != 0 ) {
59925999 insert_pos = snap_time (insert_pos);
59936000 }
59946001 }
@@ -7069,7 +7076,7 @@ void AnimationTrackEditor::_update_snap_unit() {
70697076}
70707077
70717078float AnimationTrackEditor::snap_time (float p_value, bool p_relative) {
7072- if (is_snap_enabled ()) {
7079+ if (is_snap_keys_enabled ()) {
70737080 if (Input::get_singleton ()->is_key_pressed (Key::SHIFT)) {
70747081 // Use more precise snapping when holding Shift.
70757082 snap_unit *= 0.25 ;
@@ -7323,13 +7330,21 @@ AnimationTrackEditor::AnimationTrackEditor() {
73237330 bottom_hb->add_child (view_group);
73247331 bottom_hb->add_child (memnew (VSeparator));
73257332
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)." ));
73337348
73347349 step = memnew (EditorSpinSlider);
73357350 step->set_min (0 );
0 commit comments