Skip to content

Fix Scale from Cursor in Animation Player #105715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6538,7 +6538,6 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeli
}

void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
last_menu_track_opt = p_option;
switch (p_option) {
case EDIT_COPY_TRACKS: {
track_copy_select->clear();
Expand Down Expand Up @@ -6698,11 +6697,15 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {

undo_redo->commit_action();
} break;

case EDIT_SCALE_SELECTION:
case EDIT_SCALE_SELECTION: {
scale_dialog->popup_centered(Size2(200, 100) * EDSCALE);
scale->get_line_edit()->grab_focus();
scale_from_cursor = false;
} break;
case EDIT_SCALE_FROM_CURSOR: {
scale_dialog->popup_centered(Size2(200, 100) * EDSCALE);
scale->get_line_edit()->grab_focus();
scale_from_cursor = true;
} break;
case EDIT_SCALE_CONFIRM: {
if (selection.is_empty()) {
Expand All @@ -6725,9 +6728,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
}

len = to_t - from_t;
if (last_menu_track_opt == EDIT_SCALE_FROM_CURSOR) {
if (scale_from_cursor) {
pivot = timeline->get_play_position();

} else {
pivot = from_t;
}
Expand Down Expand Up @@ -6769,7 +6771,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
to_restore.push_back(amr);
}

#define NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * Math::abs(s) + from_t
#define NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * Math::abs(s) + pivot
// 3 - Move the keys (re insert them).
for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
float newpos = NEW_POS(E->get().pos);
Expand Down
2 changes: 1 addition & 1 deletion editor/animation_track_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ class AnimationTrackEditor : public VBoxContainer {

void _edit_menu_about_to_popup();
void _edit_menu_pressed(int p_option);
int last_menu_track_opt = 0;
bool scale_from_cursor = false;

void _cleanup_animation(Ref<Animation> p_animation);

Expand Down