mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Move to WindowEvent from DeviceEvent for zooming
This commit is contained in:
parent
d35f31b9b5
commit
58ec4760a5
@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
a projectile in very specific circumstances
|
||||
- Fixed a bug where buff/debuff UI elements would flicker when you had more than
|
||||
one of them active at the same time
|
||||
- Made zooming work on wayland
|
||||
|
||||
## [0.8.0] - 2020-11-28
|
||||
|
||||
|
@ -891,28 +891,6 @@ impl Window {
|
||||
self.events.push(Event::CursorMove(delta));
|
||||
}
|
||||
},
|
||||
DeviceEvent::MouseWheel { delta, .. } if self.cursor_grabbed && self.focused => {
|
||||
self.events.push(Event::Zoom({
|
||||
// Since scrolling apparently acts different depending on platform
|
||||
#[cfg(target_os = "windows")]
|
||||
const PLATFORM_FACTOR: f32 = -4.0;
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
const PLATFORM_FACTOR: f32 = 1.0;
|
||||
|
||||
let y = match delta {
|
||||
winit::event::MouseScrollDelta::LineDelta(_x, y) => y,
|
||||
// TODO: Check to see if there is a better way to find the "line
|
||||
// height" than just hardcoding 16.0 pixels. Alternately we could
|
||||
// get rid of this and have the user set zoom sensitivity, since
|
||||
// it's unlikely people would expect a configuration file to work
|
||||
// across operating systems.
|
||||
winit::event::MouseScrollDelta::PixelDelta(pos) => (pos.y / 16.0) as f32,
|
||||
};
|
||||
y * (self.zoom_sensitivity as f32 / 100.0)
|
||||
* if self.zoom_inversion { -1.0 } else { 1.0 }
|
||||
* PLATFORM_FACTOR
|
||||
}))
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
@ -1047,6 +1025,23 @@ impl Window {
|
||||
WindowEvent::CursorMoved { position, .. } => {
|
||||
self.cursor_position = position;
|
||||
},
|
||||
WindowEvent::MouseWheel { delta, .. } if self.cursor_grabbed && self.focused => {
|
||||
const DIFFERENCE_FROM_DEVICE_EVENT_ON_X11: f32 = -15.0;
|
||||
self.events.push(Event::Zoom({
|
||||
let y = match delta {
|
||||
winit::event::MouseScrollDelta::LineDelta(_x, y) => y,
|
||||
// TODO: Check to see if there is a better way to find the "line
|
||||
// height" than just hardcoding 16.0 pixels. Alternately we could
|
||||
// get rid of this and have the user set zoom sensitivity, since
|
||||
// it's unlikely people would expect a configuration file to work
|
||||
// across operating systems.
|
||||
winit::event::MouseScrollDelta::PixelDelta(pos) => (pos.y / 16.0) as f32,
|
||||
};
|
||||
y * (self.zoom_sensitivity as f32 / 100.0)
|
||||
* if self.zoom_inversion { -1.0 } else { 1.0 }
|
||||
* DIFFERENCE_FROM_DEVICE_EVENT_ON_X11
|
||||
}))
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user