summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorAndy Maloney <asmaloney@gmail.com>2020-06-12 12:28:23 -0400
committerAndy Maloney <asmaloney@gmail.com>2020-06-18 10:20:20 -0400
commit031165b345002eef3b2451d944fe286b12915850 (patch)
tree6abd04d86f52090b313e1a506cf303c2c89fb67a /editor/plugins
parent4e0f31a67cb757f95a658a02ac28afcdda40b299 (diff)
[macOS] Control key + scroll wheel should zoom not pan
Together with godotengine/godot#39395 for 3.2.x, this fixes godotengine/godot#32520
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 2f7080b1a5..7a80279866 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1325,6 +1325,18 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid() && !p_already_accepted) {
+ // If control key pressed, then zoom instead of pan
+ if (pan_gesture->get_control()) {
+ const float factor = pan_gesture->get_delta().y;
+ float new_zoom = _get_next_zoom_value(-1);
+
+ if (factor != 1.f) {
+ new_zoom = zoom * ((new_zoom / zoom - 1.f) * factor + 1.f);
+ }
+ _zoom_on_position(new_zoom, pan_gesture->get_position());
+ return true;
+ }
+
// Pan gesture
const Vector2 delta = (int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom) * pan_gesture->get_delta();
view_offset.x += delta.x;