Fix vertical zoom factor in Animation Bezier Editor

This commit is contained in:
emild 2024-02-12 14:28:13 +01:00 committed by Rémi Verschelde
parent 9272f7b53d
commit b66b188cf9
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 6 additions and 5 deletions

View file

@ -1548,7 +1548,8 @@ void AnimationBezierTrackEdit::_zoom_callback(float p_zoom_factor, Vector2 p_ori
// Alternate zoom (doesn't affect timeline).
timeline_v_zoom = CLAMP(timeline_v_zoom * p_zoom_factor, 0.000001, 100000);
} else {
timeline->_zoom_callback(p_zoom_factor, p_origin, p_event);
float zoom_factor = p_zoom_factor > 1.0 ? AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_IN : AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_OUT;
timeline->_zoom_callback(zoom_factor, p_origin, p_event);
}
timeline_v_scroll = timeline_v_scroll + (p_origin.y - get_size().y / 2.0) * (timeline_v_zoom - v_zoom_orig);
queue_redraw();
@ -1823,7 +1824,6 @@ void AnimationBezierTrackEdit::_bind_methods() {
AnimationBezierTrackEdit::AnimationBezierTrackEdit() {
panner.instantiate();
panner->set_callbacks(callable_mp(this, &AnimationBezierTrackEdit::_pan_callback), callable_mp(this, &AnimationBezierTrackEdit::_zoom_callback));
panner->set_scroll_zoom_factor(AnimationTimelineEdit::SCROLL_ZOOM_FACTOR);
play_position = memnew(Control);
play_position->set_mouse_filter(MOUSE_FILTER_PASS);

View file

@ -1868,7 +1868,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
len_hb->hide();
panner.instantiate();
panner->set_scroll_zoom_factor(SCROLL_ZOOM_FACTOR);
panner->set_scroll_zoom_factor(SCROLL_ZOOM_FACTOR_IN);
panner->set_callbacks(callable_mp(this, &AnimationTimelineEdit::_pan_callback), callable_mp(this, &AnimationTimelineEdit::_zoom_callback));
panner->set_pan_axis(ViewPanner::PAN_AXIS_HORIZONTAL);
@ -6837,7 +6837,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
timeline->connect("length_changed", callable_mp(this, &AnimationTrackEditor::_update_length));
panner.instantiate();
panner->set_scroll_zoom_factor(AnimationTimelineEdit::SCROLL_ZOOM_FACTOR);
panner->set_scroll_zoom_factor(AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_IN);
panner->set_callbacks(callable_mp(this, &AnimationTrackEditor::_pan_callback), callable_mp(this, &AnimationTrackEditor::_zoom_callback));
scroll = memnew(ScrollContainer);

View file

@ -134,7 +134,8 @@ class AnimationTimelineEdit : public Range {
friend class AnimationBezierTrackEdit;
friend class AnimationTrackEditor;
static constexpr float SCROLL_ZOOM_FACTOR = 1.02f; // Zoom factor per mouse scroll in the animation editor. The closer to 1.0, the finer the control.
static constexpr float SCROLL_ZOOM_FACTOR_IN = 1.02f; // Zoom factor per mouse scroll in the animation editor when zooming in. The closer to 1.0, the finer the control.
static constexpr float SCROLL_ZOOM_FACTOR_OUT = 0.98f; // Zoom factor when zooming out. Similar to SCROLL_ZOOM_FACTOR_IN but less than 1.0.
Ref<Animation> animation;
bool read_only = false;