pub struct ViewportInputEvent {
pub window: AppWindowId,
pub target: RenderTargetId,
pub pointer_id: PointerId,
pub pointer_type: PointerType,
pub geometry: ViewportInputGeometry,
pub cursor_px: Point,
pub uv: (f32, f32),
pub target_px: (u32, u32),
pub kind: ViewportInputKind,
}Fields§
§window: AppWindowId§target: RenderTargetId§pointer_id: PointerId§pointer_type: PointerType§geometry: ViewportInputGeometry§cursor_px: PointCursor position in window-local logical pixels (ADR 0017).
uv: (f32, f32)§target_px: (u32, u32)§kind: ViewportInputKindImplementations§
Source§impl ViewportInputEvent
impl ViewportInputEvent
Sourcepub fn target_px_per_screen_px(&self) -> Option<f32>
pub fn target_px_per_screen_px(&self) -> Option<f32>
Returns the scale from window-local logical pixels (“screen px”) to render-target pixels.
This is derived from self.geometry.draw_rect_px (logical pixels) and the backing render
target size self.geometry.target_px_size (physical pixels).
For ViewportFit::Contain/Cover this is uniform; for ViewportFit::Stretch the mapping
is non-uniform, so this returns the smaller axis scale as a conservative approximation for
isotropic thresholds (hit radii, click distances).
Sourcepub fn cursor_target_px_f32(&self) -> Option<(f32, f32)>
pub fn cursor_target_px_f32(&self) -> Option<(f32, f32)>
Computes the cursor position in the viewport render target’s pixel space (float).
- Input
self.cursor_pxis in window-local logical pixels (ADR 0017). - The mapping uses
self.geometry.draw_rect_px(logical pixels) as the area that maps to the full render target. - Output is expressed in physical target pixels (
self.geometry.target_px_size).
This is useful for editor tooling that operates directly on render-target pixel buffers.
Prefer this over reconstructing target coordinates from uv * target_px_size because uv
and target_px may be clamped when pointer capture is active.
Sourcepub fn cursor_target_px_f32_clamped(&self) -> (f32, f32)
pub fn cursor_target_px_f32_clamped(&self) -> (f32, f32)
Like Self::cursor_target_px_f32, but clamps the resulting coordinates to the render
target bounds.
pub fn from_mapping_window_point( window: AppWindowId, target: RenderTargetId, mapping: &ViewportMapping, pixels_per_point: f32, pointer_id: PointerId, pointer_type: PointerType, position: Point, kind: ViewportInputKind, ) -> Option<Self>
pub fn from_mapping_window_point_clamped( window: AppWindowId, target: RenderTargetId, mapping: &ViewportMapping, pixels_per_point: f32, pointer_id: PointerId, pointer_type: PointerType, position: Point, kind: ViewportInputKind, ) -> Self
pub fn from_mapping_window_point_maybe_clamped( window: AppWindowId, target: RenderTargetId, mapping: &ViewportMapping, pixels_per_point: f32, pointer_id: PointerId, pointer_type: PointerType, position: Point, kind: ViewportInputKind, clamped: bool, ) -> Option<Self>
Trait Implementations§
Source§impl Clone for ViewportInputEvent
impl Clone for ViewportInputEvent
Source§fn clone(&self) -> ViewportInputEvent
fn clone(&self) -> ViewportInputEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more