summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-02-13 08:27:27 +0100
committerGitHub <noreply@github.com>2022-02-13 08:27:27 +0100
commitaa069a4d31c3eda2a5e194d825e2da795f2cca60 (patch)
tree22a9f3c4a053e8c96761c65683fa1c48281ff79d /editor
parent26b21dc0cb517f9baacdaceafe09285952540d6a (diff)
parent64ca6a0696c83dc1536d78709caee532a3be4811 (diff)
Merge pull request #58033 from jmb462/fix-mouse-wheel-animation-track-zoom
Fix AnimationTrack mouse wheel zooming at low zoom level
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 961eb907bb..fdeee32849 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -1844,11 +1844,14 @@ void AnimationTimelineEdit::_pan_callback(Vector2 p_scroll_vec) {
}
void AnimationTimelineEdit::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt) {
- if (p_scroll_vec.y < 0) {
- get_zoom()->set_value(get_zoom()->get_value() * 1.05);
+ double new_zoom_value;
+ double current_zoom_value = get_zoom()->get_value();
+ if (current_zoom_value <= 0.1) {
+ new_zoom_value = MAX(0.01, current_zoom_value - 0.01 * SIGN(p_scroll_vec.y));
} else {
- get_zoom()->set_value(get_zoom()->get_value() / 1.05);
+ new_zoom_value = p_scroll_vec.y > 0 ? MAX(0.01, current_zoom_value / 1.05) : current_zoom_value * 1.05;
}
+ get_zoom()->set_value(new_zoom_value);
}
void AnimationTimelineEdit::set_use_fps(bool p_use_fps) {
@@ -5332,11 +5335,14 @@ void AnimationTrackEditor::_pan_callback(Vector2 p_scroll_vec) {
}
void AnimationTrackEditor::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt) {
- if (p_scroll_vec.y < 0) {
- timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() * 1.05);
+ double new_zoom_value;
+ double current_zoom_value = timeline->get_zoom()->get_value();
+ if (current_zoom_value <= 0.1) {
+ new_zoom_value = MAX(0.01, current_zoom_value - 0.01 * SIGN(p_scroll_vec.y));
} else {
- timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() / 1.05);
+ new_zoom_value = p_scroll_vec.y > 0 ? MAX(0.01, current_zoom_value / 1.05) : current_zoom_value * 1.05;
}
+ timeline->get_zoom()->set_value(new_zoom_value);
}
void AnimationTrackEditor::_cancel_bezier_edit() {