Skip to content

Commit

Permalink
Fix horizontal mouse wheeling in 2D editor view
Browse files Browse the repository at this point in the history
  • Loading branch information
miv391 committed Nov 28, 2023
1 parent a0d7649 commit 187bb61
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions scene/gui/view_panner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ bool ViewPanner::gui_input(const Ref<InputEvent> &p_event, Rect2 p_canvas_rect)
if (scroll_vec != Vector2() && mb->is_pressed()) {
if (control_scheme == SCROLL_PANS) {
if (mb->is_ctrl_pressed()) {
// Compute the zoom factor.
float zoom_factor = mb->get_factor() <= 0 ? 1.0 : mb->get_factor();
zoom_factor = ((scroll_zoom_factor - 1.0) * zoom_factor) + 1.0;
float zoom = (scroll_vec.x + scroll_vec.y) > 0 ? 1.0 / scroll_zoom_factor : scroll_zoom_factor;
zoom_callback.call(zoom, mb->get_position(), p_event);
return true;
if (scroll_vec.y != 0) {
// Compute the zoom factor.
float zoom_factor = mb->get_factor() <= 0 ? 1.0 : mb->get_factor();
zoom_factor = ((scroll_zoom_factor - 1.0) * zoom_factor) + 1.0;
float zoom = scroll_vec.y > 0 ? 1.0 / scroll_zoom_factor : scroll_zoom_factor;
zoom_callback.call(zoom, mb->get_position(), p_event);
return true;
}
} else {
Vector2 panning = scroll_vec * mb->get_factor();
if (pan_axis == PAN_AXIS_HORIZONTAL) {
Expand All @@ -73,11 +75,11 @@ bool ViewPanner::gui_input(const Ref<InputEvent> &p_event, Rect2 p_canvas_rect)
}
pan_callback.call(-panning * scroll_speed, p_event);
return true;
} else if (!mb->is_shift_pressed()) {
} else if (!mb->is_shift_pressed() && scroll_vec.y != 0) {
// Compute the zoom factor.
float zoom_factor = mb->get_factor() <= 0 ? 1.0 : mb->get_factor();
zoom_factor = ((scroll_zoom_factor - 1.0) * zoom_factor) + 1.0;
float zoom = (scroll_vec.x + scroll_vec.y) > 0 ? 1.0 / scroll_zoom_factor : scroll_zoom_factor;
float zoom = scroll_vec.y > 0 ? 1.0 / scroll_zoom_factor : scroll_zoom_factor;
zoom_callback.call(zoom, mb->get_position(), p_event);
return true;
}
Expand Down

0 comments on commit 187bb61

Please sign in to comment.