Fix zoom in callback for CanvasItemEditor to use correct numeric sign

This commit is contained in:
Andy Gainey 2022-06-04 18:11:19 +02:00
parent ecde7ce834
commit bb07c6a7d0

View file

@ -1284,8 +1284,8 @@ void CanvasItemEditor::_pan_callback(Vector2 p_scroll_vec) {
}
void CanvasItemEditor::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt) {
zoom_widget->set_zoom_by_increments(-1, p_alt);
if (!Math::is_equal_approx(p_scroll_vec.y, (real_t)1.0)) {
zoom_widget->set_zoom_by_increments((int)SIGN(p_scroll_vec.y), p_alt);
if (!Math::is_equal_approx(ABS(p_scroll_vec.y), (real_t)1.0)) {
// Handle high-precision (analog) scrolling.
zoom_widget->set_zoom(zoom * ((zoom_widget->get_zoom() / zoom - 1.f) * p_scroll_vec.y + 1.f));
}