Skip to content

Commit e9edff8

Browse files
committed
Fix scale from cursor in Animation Player
1 parent 931820d commit e9edff8

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
@@ -6538,7 +6538,6 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeli
65386538
}
65396539

65406540
void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
6541-
last_menu_track_opt = p_option;
65426541
switch (p_option) {
65436542
case EDIT_COPY_TRACKS: {
65446543
track_copy_select->clear();
@@ -6698,11 +6697,15 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
66986697

66996698
undo_redo->commit_action();
67006699
} break;
6701-
6702-
case EDIT_SCALE_SELECTION:
6700+
case EDIT_SCALE_SELECTION: {
6701+
scale_dialog->popup_centered(Size2(200, 100) * EDSCALE);
6702+
scale->get_line_edit()->grab_focus();
6703+
scale_from_cursor = false;
6704+
} break;
67036705
case EDIT_SCALE_FROM_CURSOR: {
67046706
scale_dialog->popup_centered(Size2(200, 100) * EDSCALE);
67056707
scale->get_line_edit()->grab_focus();
6708+
scale_from_cursor = true;
67066709
} break;
67076710
case EDIT_SCALE_CONFIRM: {
67086711
if (selection.is_empty()) {
@@ -6725,9 +6728,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
67256728
}
67266729

67276730
len = to_t - from_t;
6728-
if (last_menu_track_opt == EDIT_SCALE_FROM_CURSOR) {
6731+
if (scale_from_cursor) {
67296732
pivot = timeline->get_play_position();
6730-
67316733
} else {
67326734
pivot = from_t;
67336735
}
@@ -6769,7 +6771,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
67696771
to_restore.push_back(amr);
67706772
}
67716773

6772-
#define NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * Math::abs(s) + from_t
6774+
#define NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * Math::abs(s) + pivot
67736775
// 3 - Move the keys (re insert them).
67746776
for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
67756777
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
@@ -789,7 +789,7 @@ class AnimationTrackEditor : public VBoxContainer {
789789

790790
void _edit_menu_about_to_popup();
791791
void _edit_menu_pressed(int p_option);
792-
int last_menu_track_opt = 0;
792+
bool scale_from_cursor = false;
793793

794794
void _cleanup_animation(Ref<Animation> p_animation);
795795

0 commit comments

Comments
 (0)