Skip to main content

viewport_lib/interaction/input/
context.rs

1//! Per-frame viewport context for the new input pipeline.
2
3/// Per-frame viewport context passed to [`super::controller::OrbitCameraController::begin_frame`]
4/// (and the lower-level [`super::viewport_input::ViewportInput::begin_frame`]).
5///
6/// Makes viewport ownership explicit so the library can apply consistent
7/// hover / focus policies without each host app re-implementing them.
8#[derive(Debug, Clone, Copy)]
9pub struct ViewportContext {
10    /// Whether the pointer is currently hovering over the viewport.
11    pub hovered: bool,
12    /// Whether the viewport currently has keyboard focus.
13    pub focused: bool,
14    /// Viewport size in logical pixels `[width, height]`.
15    pub viewport_size: [f32; 2],
16}
17
18impl Default for ViewportContext {
19    fn default() -> Self {
20        Self {
21            hovered: false,
22            focused: false,
23            viewport_size: [1.0, 1.0],
24        }
25    }
26}