1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! Viewport events for the new input pipeline.
use super::binding::{KeyCode, Modifiers, MouseButton};
/// Button press or release state.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ButtonState {
/// Button was pressed.
Pressed,
/// Button was released.
Released,
}
/// Scroll delta units.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ScrollUnits {
/// Delta in logical line units (one notch ~ 1.0).
Lines,
/// Delta in physical pixels.
Pixels,
/// Delta in viewport pages (one unit = viewport height).
Pages,
}
/// An event delivered to the viewport input pipeline.
///
/// Host applications translate their native windowing events into
/// `ViewportEvent` values and push them to [`super::controller::OrbitCameraController`]
/// (or [`super::viewport_input::ViewportInput`] for direct input handling).
#[non_exhaustive]
#[derive(Debug, Clone)]
pub enum ViewportEvent {
/// The pointer moved to the given viewport-local position.
PointerMoved {
/// Viewport-local position in logical pixels, origin at top-left.
position: glam::Vec2,
},
/// A mouse button was pressed or released.
MouseButton {
/// Which button changed state.
button: MouseButton,
/// New button state.
state: ButtonState,
},
/// The scroll wheel moved.
Wheel {
/// Scroll delta. Positive Y = scroll up / zoom in (conventional).
delta: glam::Vec2,
/// Whether the delta is in lines or pixels.
units: ScrollUnits,
},
/// A keyboard key changed state.
Key {
/// Which key changed state.
key: KeyCode,
/// New key state.
state: ButtonState,
/// True if the event is a key-repeat (key held down).
repeat: bool,
},
/// Modifier key state changed.
ModifiersChanged(Modifiers),
/// The pointer left the viewport area.
PointerLeft,
/// The viewport lost keyboard focus.
FocusLost,
/// A character was typed (Unicode).
///
/// Only push this event when the manipulation controller is active
/// (`ManipulationController::is_active()`) to avoid swallowing other keypresses.
/// The library filters the character stream to digits, `.`, and `-` before
/// passing it to the numeric input buffer.
Character(char),
/// Two-finger trackpad rotation gesture.
///
/// `delta` is the change in angle this event, in radians.
/// Positive = counter-clockwise (matches winit's `RotationGesture` convention,
/// converted from degrees to radians by the host).
///
/// ## Platform-specific
/// Only emitted on macOS (and iOS). Silently unused on Windows and Linux.
TrackpadRotate(f32),
}