Skip to content

Commit 88c47c6

Browse files
committed
Merge pull request #105715 from Arnklit/animation-player-scale-from-cursor-fix
Fix scaling from cursor in AnimationPlayer
2 parents 2d8e408 + e9edff8 commit 88c47c6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

editor/animation_track_editor.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6681,7 +6681,6 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeli
66816681
}
66826682

66836683
void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
6684-
last_menu_track_opt = p_option;
66856684
switch (p_option) {
66866685
case EDIT_COPY_TRACKS: {
66876686
track_copy_select->clear();
@@ -6841,11 +6840,15 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
68416840

68426841
undo_redo->commit_action();
68436842
} break;
6844-
6845-
case EDIT_SCALE_SELECTION:
6843+
case EDIT_SCALE_SELECTION: {
6844+
scale_dialog->popup_centered(Size2(200, 100) * EDSCALE);
6845+
scale->get_line_edit()->grab_focus();
6846+
scale_from_cursor = false;
6847+
} break;
68466848
case EDIT_SCALE_FROM_CURSOR: {
68476849
scale_dialog->popup_centered(Size2(200, 100) * EDSCALE);
68486850
scale->get_line_edit()->grab_focus();
6851+
scale_from_cursor = true;
68496852
} break;
68506853
case EDIT_SCALE_CONFIRM: {
68516854
if (selection.is_empty()) {
@@ -6868,9 +6871,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
68686871
}
68696872

68706873
len = to_t - from_t;
6871-
if (last_menu_track_opt == EDIT_SCALE_FROM_CURSOR) {
6874+
if (scale_from_cursor) {
68726875
pivot = timeline->get_play_position();
6873-
68746876
} else {
68756877
pivot = from_t;
68766878
}
@@ -6912,7 +6914,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
69126914
to_restore.push_back(amr);
69136915
}
69146916

6915-
#define NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * Math::abs(s) + from_t
6917+
#define NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * Math::abs(s) + pivot
69166918
// 3 - Move the keys (re insert them).
69176919
for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
69186920
float newpos = NEW_POS(E->get().pos);

editor/animation_track_editor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ class AnimationTrackEditor : public VBoxContainer {
802802

803803
void _edit_menu_about_to_popup();
804804
void _edit_menu_pressed(int p_option);
805-
int last_menu_track_opt = 0;
805+
bool scale_from_cursor = false;
806806

807807
void _cleanup_animation(Ref<Animation> p_animation);
808808

0 commit comments

Comments
 (0)