mirror of
https://github.com/godotengine/godot
synced 2024-09-05 05:38:35 +00:00
Merge pull request #85473 from miv391/fix-horizontal-mouse-wheeling-in-2d-view
Fix horizontal scroll in editor's 2D view
This commit is contained in:
commit
547374b07a
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue