1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-03 16:55:53 +00:00

Merge pull request #107959 from rapust/add-keyframe-shortcuts

Add "Go to Next/Previous Keyframe" to Animation Edit menu
This commit is contained in:
Thaddeus Crews
2025-11-14 14:22:44 -06:00
4 changed files with 17 additions and 7 deletions

View File

@@ -246,7 +246,7 @@ void AnimationPlayerEditor::_autoplay_pressed() {
} }
} }
void AnimationPlayerEditor::_go_to_nearest_keyframe(bool p_backward) { void AnimationPlayerEditor::go_to_nearest_keyframe(bool p_backward) {
if (_get_current().is_empty()) { if (_get_current().is_empty()) {
return; return;
} }
@@ -1667,10 +1667,10 @@ void AnimationPlayerEditor::shortcut_input(const Ref<InputEvent> &p_ev) {
_play_bw_pressed(); _play_bw_pressed();
accept_event(); accept_event();
} else if (ED_IS_SHORTCUT("animation_editor/go_to_next_keyframe", p_ev)) { } else if (ED_IS_SHORTCUT("animation_editor/go_to_next_keyframe", p_ev)) {
_go_to_nearest_keyframe(false); go_to_nearest_keyframe(false);
accept_event(); accept_event();
} else if (ED_IS_SHORTCUT("animation_editor/go_to_previous_keyframe", p_ev)) { } else if (ED_IS_SHORTCUT("animation_editor/go_to_previous_keyframe", p_ev)) {
_go_to_nearest_keyframe(true); go_to_nearest_keyframe(true);
accept_event(); accept_event();
} }
} }
@@ -2298,8 +2298,6 @@ void fragment() {
ED_SHORTCUT("animation_editor/play_animation_backwards", TTRC("Play Animation Backwards"), Key::A); ED_SHORTCUT("animation_editor/play_animation_backwards", TTRC("Play Animation Backwards"), Key::A);
ED_SHORTCUT("animation_editor/play_animation_from_start", TTRC("Play Animation from Start"), KeyModifierMask::SHIFT + Key::D); ED_SHORTCUT("animation_editor/play_animation_from_start", TTRC("Play Animation from Start"), KeyModifierMask::SHIFT + Key::D);
ED_SHORTCUT("animation_editor/play_animation_from_end", TTRC("Play Animation Backwards from End"), KeyModifierMask::SHIFT + Key::A); ED_SHORTCUT("animation_editor/play_animation_from_end", TTRC("Play Animation Backwards from End"), KeyModifierMask::SHIFT + Key::A);
ED_SHORTCUT("animation_editor/go_to_next_keyframe", TTRC("Go to Next Keyframe"), KeyModifierMask::SHIFT + KeyModifierMask::ALT + Key::D);
ED_SHORTCUT("animation_editor/go_to_previous_keyframe", TTRC("Go to Previous Keyframe"), KeyModifierMask::SHIFT + KeyModifierMask::ALT + Key::A);
} }
AnimationPlayerEditor::~AnimationPlayerEditor() { AnimationPlayerEditor::~AnimationPlayerEditor() {

View File

@@ -179,7 +179,6 @@ class AnimationPlayerEditor : public VBoxContainer {
void _select_anim_by_name(const String &p_anim); void _select_anim_by_name(const String &p_anim);
float _get_editor_step() const; float _get_editor_step() const;
void _go_to_nearest_keyframe(bool p_backward);
void _play_pressed(); void _play_pressed();
void _play_from_pressed(); void _play_from_pressed();
void _play_bw_pressed(); void _play_bw_pressed();
@@ -271,6 +270,7 @@ public:
void clear(); void clear();
void ensure_visibility(); void ensure_visibility();
void go_to_nearest_keyframe(bool p_backward);
void edit(AnimationMixer *p_node, AnimationPlayer *p_player, bool p_is_dummy); void edit(AnimationMixer *p_node, AnimationPlayer *p_player, bool p_is_dummy);
void forward_force_draw_over_viewport(Control *p_overlay); void forward_force_draw_over_viewport(Control *p_overlay);

View File

@@ -7322,6 +7322,13 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
goto_prev_step(false); goto_prev_step(false);
} break; } break;
case EDIT_GOTO_NEXT_KEYFRAME: {
AnimationPlayerEditor::get_singleton()->go_to_nearest_keyframe(false);
} break;
case EDIT_GOTO_PREV_KEYFRAME: {
AnimationPlayerEditor::get_singleton()->go_to_nearest_keyframe(true);
} break;
case EDIT_APPLY_RESET: { case EDIT_APPLY_RESET: {
AnimationPlayerEditor::get_singleton()->get_player()->apply_reset(true); AnimationPlayerEditor::get_singleton()->get_player()->apply_reset(true);
} break; } break;
@@ -8152,6 +8159,9 @@ AnimationTrackEditor::AnimationTrackEditor() {
edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_next_step", TTRC("Go to Next Step"), KeyModifierMask::CMD_OR_CTRL | Key::RIGHT), EDIT_GOTO_NEXT_STEP); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_next_step", TTRC("Go to Next Step"), KeyModifierMask::CMD_OR_CTRL | Key::RIGHT), EDIT_GOTO_NEXT_STEP);
edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_prev_step", TTRC("Go to Previous Step"), KeyModifierMask::CMD_OR_CTRL | Key::LEFT), EDIT_GOTO_PREV_STEP); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_prev_step", TTRC("Go to Previous Step"), KeyModifierMask::CMD_OR_CTRL | Key::LEFT), EDIT_GOTO_PREV_STEP);
edit->get_popup()->add_separator(); edit->get_popup()->add_separator();
edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/go_to_next_keyframe", TTRC("Go to Next Keyframe"), KeyModifierMask::SHIFT | KeyModifierMask::ALT | Key::D), EDIT_GOTO_NEXT_KEYFRAME);
edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/go_to_previous_keyframe", TTRC("Go to Previous Keyframe"), KeyModifierMask::SHIFT | KeyModifierMask::ALT | Key::A), EDIT_GOTO_PREV_KEYFRAME);
edit->get_popup()->add_separator();
edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/apply_reset", TTRC("Apply Reset")), EDIT_APPLY_RESET); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/apply_reset", TTRC("Apply Reset")), EDIT_APPLY_RESET);
edit->get_popup()->add_separator(); edit->get_popup()->add_separator();
edit->get_popup()->add_item(TTR("Bake Animation..."), EDIT_BAKE_ANIMATION); edit->get_popup()->add_item(TTR("Bake Animation..."), EDIT_BAKE_ANIMATION);

View File

@@ -925,7 +925,9 @@ public:
EDIT_OPTIMIZE_ANIMATION, EDIT_OPTIMIZE_ANIMATION,
EDIT_OPTIMIZE_ANIMATION_CONFIRM, EDIT_OPTIMIZE_ANIMATION_CONFIRM,
EDIT_CLEAN_UP_ANIMATION, EDIT_CLEAN_UP_ANIMATION,
EDIT_CLEAN_UP_ANIMATION_CONFIRM EDIT_CLEAN_UP_ANIMATION_CONFIRM,
EDIT_GOTO_NEXT_KEYFRAME,
EDIT_GOTO_PREV_KEYFRAME,
}; };
void add_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin); void add_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin);