From feb65f75f28c37d307890558ab47340900cfd28f Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 23 Oct 2025 16:05:51 +0200 Subject: [PATCH] Remember animation snapping state --- editor/animation/animation_track_editor.cpp | 15 +++++++++++---- editor/animation/animation_track_editor.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/editor/animation/animation_track_editor.cpp b/editor/animation/animation_track_editor.cpp index 9878dba30f5..cb832d6feee 100644 --- a/editor/animation/animation_track_editor.cpp +++ b/editor/animation/animation_track_editor.cpp @@ -5281,6 +5281,11 @@ void AnimationTrackEditor::_update_step_spinbox() { _update_snap_unit(); } +void AnimationTrackEditor::_store_snap_states() { + EditorSettings::get_singleton()->set_project_metadata("animation_track_editor", "snap_timeline", snap_timeline->is_pressed()); + EditorSettings::get_singleton()->set_project_metadata("animation_track_editor", "snap_keys", snap_keys->is_pressed()); +} + void AnimationTrackEditor::_update_fps_compat_mode(bool p_enabled) { _update_snap_unit(); } @@ -7997,19 +8002,21 @@ AnimationTrackEditor::AnimationTrackEditor() { snap_timeline = memnew(Button); snap_timeline->set_flat(true); - bottom_hf->add_child(snap_timeline); snap_timeline->set_disabled(true); snap_timeline->set_toggle_mode(true); - snap_timeline->set_pressed(false); snap_timeline->set_tooltip_text(TTR("Apply snapping to timeline cursor.")); + snap_timeline->set_pressed(EditorSettings::get_singleton()->get_project_metadata("animation_track_editor", "snap_timeline", false)); + bottom_hf->add_child(snap_timeline); + snap_timeline->connect(SceneStringName(toggled), callable_mp(this, &AnimationTrackEditor::_store_snap_states).unbind(1)); snap_keys = memnew(Button); snap_keys->set_flat(true); - bottom_hf->add_child(snap_keys); snap_keys->set_disabled(true); snap_keys->set_toggle_mode(true); - snap_keys->set_pressed(true); snap_keys->set_tooltip_text(TTR("Apply snapping to selected key(s).")); + snap_keys->set_pressed(EditorSettings::get_singleton()->get_project_metadata("animation_track_editor", "snap_keys", true)); + bottom_hf->add_child(snap_keys); + snap_keys->connect(SceneStringName(toggled), callable_mp(this, &AnimationTrackEditor::_store_snap_states).unbind(1)); fps_compat = memnew(Button); fps_compat->set_flat(true); diff --git a/editor/animation/animation_track_editor.h b/editor/animation/animation_track_editor.h index 8e80a5bc35d..8070922f1d2 100644 --- a/editor/animation/animation_track_editor.h +++ b/editor/animation/animation_track_editor.h @@ -664,6 +664,7 @@ class AnimationTrackEditor : public VBoxContainer { void _new_track_property_selected(const String &p_name); void _update_step_spinbox(); + void _store_snap_states(); PropertySelector *prop_selector = nullptr; PropertySelector *method_selector = nullptr;