use crate::{_impl_init, EventButton, EventButtonState, EventButtons, KeyMods, f32bits_niche};
#[doc = crate::_tags!(event interaction)]
#[doc = crate::_doc_meta!{
location("ui/event"),
test_size_of(EventMouse = 16|128; niche Option),
}]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct EventMouse {
pub x: i32,
pub y: i32,
pub button: Option<EventButton>,
pub state: EventButtonState,
pub buttons: EventButtons,
pub mods: KeyMods,
}
_impl_init! {
Self::new(0, 0, None, EventButtonState::INIT, EventButtons::INIT, KeyMods::INIT) => EventMouse
}
#[rustfmt::skip]
impl EventMouse {
pub const fn new(x: i32, y: i32, button: Option<EventButton>,
state: EventButtonState, buttons: EventButtons, mods: KeyMods) -> Self {
Self { x, y, button, state, buttons, mods }
}
}
#[doc = crate::_tags!(event interaction)]
#[doc = crate::_doc_meta!{
location("ui/event"),
test_size_of(EventPointer = 36|288; niche Option),
}]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct EventPointer {
pub kind: EventPointerKind,
pub id: u32,
pub x: i32,
pub y: i32,
pub dx: i32,
pub dy: i32,
pressure: f32bits_niche,
pub tilt_x: i8,
pub tilt_y: i8,
pub twist: u16,
pub button: Option<EventButton>,
pub state: EventButtonState,
pub buttons: EventButtons,
pub mods: KeyMods,
}
_impl_init! {
Self::new(EventPointerKind::INIT, 0, 0, 0, 0, 0, f32bits_niche::INIT, 0, 0, 0, None,
EventButtonState::INIT, EventButtons::INIT, KeyMods::INIT) => EventPointer
}
#[rustfmt::skip]
impl EventPointer {
#[allow(clippy::too_many_arguments)]
pub const fn new(kind: EventPointerKind, id: u32, x: i32, y: i32, dx: i32, dy: i32,
pressure: f32bits_niche, tilt_x: i8, tilt_y: i8, twist: u16, button: Option<EventButton>,
state: EventButtonState, buttons: EventButtons, mods: KeyMods) -> Self {
Self {
kind, id, x, y, dx, dy, pressure, tilt_x, tilt_y, twist, button, state, buttons, mods
}
}
pub const fn get_pressure(&self) -> f32 {
self.pressure.as_float()
}
pub const fn set_pressure(&mut self, pressure: f32) {
self.pressure = f32bits_niche::new(pressure);
}
}
#[doc = crate::_tags!(event interaction)]
#[doc = crate::_doc_meta!{location("ui/event")}]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum EventPointerKind {
Mouse,
Touch,
Pen,
}
_impl_init! { Self::Mouse => EventPointerKind }