aboutsummaryrefslogtreecommitdiffstats
path: root/src/events.rs
diff options
context:
space:
mode:
authorRobert Knight <robert.knight@mendeley.com>2015-06-12 15:32:11 +0100
committerRobert Knight <robert.knight@mendeley.com>2015-06-13 23:19:31 +0100
commitf0bab95c4dc13c1989979c611a4663eb5d590a0d (patch)
tree62fc80f471dae8fbb99f8f791c8d08fb91d7b4d8 /src/events.rs
parenta0e29d9410181368eee1e0b6db1bbbf11abf45f8 (diff)
downloadglutin-f0bab95c4dc13c1989979c611a4663eb5d590a0d.tar.gz
glutin-f0bab95c4dc13c1989979c611a4663eb5d590a0d.zip
Express scroll deltas as either line or pixel deltas
Depending on the platform and device, scroll deltas may either be represented as pixel deltas specifying the amount in pixels to scroll or they may be expressed in 'lines' or 'chunks' for low resolution devices (eg. a traditional mouse wheel). Pixel deltas are currently available on OS X. X11 currently supports only integer line deltas, though pixel deltas are available via XInput2. Windows supports fractional line deltas.
Diffstat (limited to 'src/events.rs')
-rw-r--r--src/events.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/events.rs b/src/events.rs
index 7962706..1103452 100644
--- a/src/events.rs
+++ b/src/events.rs
@@ -25,11 +25,11 @@ pub enum Event {
/// The parameter are the (x,y) coords in pixels relative to the top-left corner of the window.
MouseMoved((i32, i32)),
- /// Returns the horizontal and vertical mouse scrolling.
+ /// A mouse wheel or touchpad scroll occurred. Depending on whether the
///
/// A positive value indicates that the wheel was rotated forward, away from the user;
/// a negative value indicates that the wheel was rotated backward, toward the user.
- MouseWheel(f64, f64),
+ MouseWheel(MouseScrollDelta),
/// An event from the mouse has been received.
MouseInput(ElementState, MouseButton),
@@ -57,6 +57,23 @@ pub enum MouseButton {
Other(u8),
}
+#[derive(Debug, Clone, Copy)]
+pub enum MouseScrollDelta {
+ /// Amount in lines or rows to scroll in the horizontal
+ /// and vertical directions.
+ ///
+ /// Positive values indicate movement forward
+ /// (away from the user) or righwards.
+ LineDelta(f32, f32),
+ /// Amount in pixels to scroll in the horizontal and
+ /// vertical direction.
+ ///
+ /// Scroll events are expressed as a PixelDelta if
+ /// supported by the device (eg. a touchpad) and
+ /// platform.
+ PixelDelta(f32, f32)
+}
+
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
pub enum VirtualKeyCode {
/// The '1' key over the letters.