From 63c945b598c8239a135470e16b33bcb375ec32cc Mon Sep 17 00:00:00 2001 From: Yeedo Date: Sat, 2 Feb 2019 20:18:40 +0000 Subject: [PATCH 1/2] Updated mouse wheel zooming to use WindowEvent Former-commit-id: fabe382516fd65eb76043b7d6ada87cf20f53590 --- voxygen/src/scene/mod.rs | 2 +- voxygen/src/window.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 3a8e772c00..e687bfc536 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -128,7 +128,7 @@ impl Scene { }, // Zoom the camera when a zoom event occurs Event::Zoom(delta) => { - self.camera.zoom_by(delta); + self.camera.zoom_by(-delta); true }, // All other events are unhandled diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index da6f086813..f37a55b6fc 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -92,15 +92,15 @@ impl Window { }), _ => {}, }, + glutin::WindowEvent::MouseWheel { + delta: glutin::MouseScrollDelta::LineDelta(_x, y), + .. + } => events.push(Event::Zoom(y as f32)), _ => {}, }, glutin::Event::DeviceEvent { event, .. } => match event { glutin::DeviceEvent::MouseMotion { delta: (dx, dy), .. } if cursor_grabbed => events.push(Event::CursorPan(Vec2::new(dx as f32, dy as f32))), - glutin::DeviceEvent::MouseWheel { - delta: glutin::MouseScrollDelta::LineDelta(_x, y), - .. - } if cursor_grabbed => events.push(Event::Zoom(y as f32)), _ => {}, }, _ => {}, From b88dc1bbde3fa3196f5521900e6e831783b096d7 Mon Sep 17 00:00:00 2001 From: Yeedo Date: Sat, 2 Feb 2019 20:18:40 +0000 Subject: [PATCH 2/2] Updated mouse wheel zooming to use WindowEvent Former-commit-id: 700fa66382f3a8e0fd738a8ce14fb44bc211b5fe --- voxygen/src/scene/mod.rs | 2 +- voxygen/src/window.rs | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 364c80f0b0..9513b6f602 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -124,7 +124,7 @@ impl Scene { }, // Zoom the camera when a zoom event occurs Event::Zoom(delta) => { - self.camera.zoom_by(delta); + self.camera.zoom_by(-delta); true }, // All other events are unhandled diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index 81395e23d4..eee2b3dd90 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -113,21 +113,18 @@ impl Window { }, _ => {} }, - _ => {} - }, - glutin::Event::DeviceEvent { event, .. } => match event { - glutin::DeviceEvent::MouseMotion { - delta: (dx, dy), .. - } if cursor_grabbed => { - events.push(Event::CursorPan(Vec2::new(dx as f32, dy as f32))) - } - glutin::DeviceEvent::MouseWheel { + glutin::WindowEvent::MouseWheel { delta: glutin::MouseScrollDelta::LineDelta(_x, y), .. - } if cursor_grabbed => events.push(Event::Zoom(y as f32)), - _ => {} + } => events.push(Event::Zoom(y as f32)), + _ => {}, }, - _ => {} + glutin::Event::DeviceEvent { event, .. } => match event { + glutin::DeviceEvent::MouseMotion { delta: (dx, dy), .. } if cursor_grabbed => + events.push(Event::CursorPan(Vec2::new(dx as f32, dy as f32))), + _ => {}, + }, + _ => {}, } }); events