pub struct InputOwnership {
pub pointer: PointerOwnership,
pub keyboard: KeyboardOwnership,
}Expand description
Who owns the pointer and who owns the keyboard, as the application’s routing decided this frame.
The per-framework helpers (adapters::egui::ownership,
adapters::winit::ownership in viewport-lib-input) compute it from
framework state; a host that hit-tests its own widgets builds it directly.
Fields§
§pointer: PointerOwnershipWho owns the pointer.
keyboard: KeyboardOwnershipWho owns the keyboard.
Implementations§
Source§impl InputOwnership
impl InputOwnership
Sourcepub const NONE: InputOwnership
pub const NONE: InputOwnership
Neither the pointer nor the keyboard is the viewport’s.
Sourcepub const fn full_window() -> InputOwnership
pub const fn full_window() -> InputOwnership
A viewport that fills its window with nothing drawn over it: it owns both.
Examples found in repository?
examples/custom_controller.rs (line 42)
38fn main() {
39 // 1. RESOLVE: feed native-shaped events into ViewportInput for one frame.
40 let mut input = ViewportInput::from_preset(BindingPreset::Viewer);
41 input.begin_frame(ViewportContext::new(
42 InputOwnership::full_window(),
43 [800.0, 600.0],
44 ));
45
46 // In the primitives preset, plain left-drag (no modifiers) orbits. Drive it
47 // by hand: place the pointer, press the button there (that sets the drag
48 // origin), then move across the viewport to accumulate the drag delta.
49 input.push_event(ViewportEvent::PointerMoved {
50 position: [400.0, 300.0].into(),
51 });
52 input.push_event(ViewportEvent::MouseButton {
53 button: MouseButton::Left,
54 state: ButtonState::Pressed,
55 });
56 input.push_event(ViewportEvent::PointerMoved {
57 position: [460.0, 300.0].into(),
58 });
59
60 let frame: ActionFrame = input.resolve();
61
62 // 2. APPLY: hand the resolved frame to your controller.
63 let mut camera = Camera::default();
64 let before = camera.orientation();
65
66 let mut controller = HalfSpeedOrbit;
67 controller.apply(&mut camera, &frame, 1.0 / 60.0);
68
69 println!("resolved orbit delta : {:?}", frame.navigation.orbit);
70 println!("camera orientation before : {before:?}");
71 println!("camera orientation after : {:?}", camera.orientation());
72 println!(
73 "moved: {}",
74 before.abs_diff_eq(camera.orientation(), 1e-6) == false
75 );
76}Sourcepub const fn pointer_only(pointer: PointerOwnership) -> InputOwnership
pub const fn pointer_only(pointer: PointerOwnership) -> InputOwnership
Trait Implementations§
Source§impl Clone for InputOwnership
impl Clone for InputOwnership
Source§fn clone(&self) -> InputOwnership
fn clone(&self) -> InputOwnership
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for InputOwnership
Source§impl Debug for InputOwnership
impl Debug for InputOwnership
Source§impl Default for InputOwnership
impl Default for InputOwnership
Source§fn default() -> InputOwnership
fn default() -> InputOwnership
Returns the “default value” for a type. Read more
impl Eq for InputOwnership
Source§impl Hash for InputOwnership
impl Hash for InputOwnership
Source§impl PartialEq for InputOwnership
impl PartialEq for InputOwnership
impl StructuralPartialEq for InputOwnership
Auto Trait Implementations§
impl Forget for InputOwnership
impl Freeze for InputOwnership
impl Move for InputOwnership
impl RefUnwindSafe for InputOwnership
impl Send for InputOwnership
impl Sync for InputOwnership
impl Unpin for InputOwnership
impl UnsafeUnpin for InputOwnership
impl UnwindSafe for InputOwnership
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more