pub enum InputEvent {
Pan {
dx: f64,
dy: f64,
x: Option<f64>,
y: Option<f64>,
},
Zoom {
factor: f64,
x: Option<f64>,
y: Option<f64>,
},
Rotate {
delta_yaw: f64,
delta_pitch: f64,
},
Resize {
width: u32,
height: u32,
},
Touch(TouchContact),
}Expand description
An input event that can be dispatched to the engine.
All spatial values are in logical pixels unless otherwise noted. Rotation values are in radians.
§Examples
use rustial_engine::InputEvent;
// Drag the map 10 px right and 5 px down.
let pan = InputEvent::pan(10.0, 5.0);
// Zoom in by 10 %.
let zoom = InputEvent::zoom_in(1.1);
// Tilt the camera 5 degrees (? 0.087 rad).
let rotate = InputEvent::rotate(0.0, 0.087);
// Viewport resized.
let resize = InputEvent::resize(1920, 1080);Variants§
Pan
Pan the camera by a screen-space delta.
Positive dx moves the viewport to the right (map moves left).
Positive dy moves the viewport down (map moves up).
Fields
Zoom
Zoom by a multiplicative factor.
factor > 1.0zooms in (closer to the ground).0 < factor < 1.0zooms out.factor <= 0,NaN, or+/-Infare silently ignored by theCameraController.
Fields
Rotate
Rotate the camera by delta yaw and delta pitch.
delta_yawrotates the bearing (positive = clockwise when viewed from above).delta_pitchtilts the camera (positive = toward horizon).
Fields
Resize
Notify the engine of a viewport resize.
The engine uses logical pixel dimensions (not physical) so that zoom-level calculations match the standard slippy-map convention.
Fields
Touch(TouchContact)
A raw touch contact event.
The host application emits one Touch per finger per phase
change. The engine’s GestureRecognizer
accumulates these into high-level Pan / Zoom / Rotate
events.
Implementations§
Source§impl InputEvent
impl InputEvent
Sourcepub fn pan_at(dx: f64, dy: f64, x: f64, y: f64) -> Self
pub fn pan_at(dx: f64, dy: f64, x: f64, y: f64) -> Self
Create a Pan event at a specific cursor location.
Sourcepub fn zoom_in(factor: f64) -> Self
pub fn zoom_in(factor: f64) -> Self
Create a Zoom event that zooms in.
factor should be > 1.0. Values ? 0 will be ignored by the
controller.
Sourcepub fn zoom_at(factor: f64, x: f64, y: f64) -> Self
pub fn zoom_at(factor: f64, x: f64, y: f64) -> Self
Create a Zoom event around a specific cursor location.
Source§impl InputEvent
impl InputEvent
Trait Implementations§
Source§impl Clone for InputEvent
impl Clone for InputEvent
Source§fn clone(&self) -> InputEvent
fn clone(&self) -> InputEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for InputEvent
Source§impl Debug for InputEvent
impl Debug for InputEvent
Source§impl Display for InputEvent
impl Display for InputEvent
Source§impl PartialEq for InputEvent
impl PartialEq for InputEvent
Source§fn eq(&self, other: &InputEvent) -> bool
fn eq(&self, other: &InputEvent) -> bool
self and other values to be equal, and is used by ==.