1
0
Fork 0
baseview/src/event.rs

47 lines
946 B
Rust
Raw Normal View History

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum MouseButtonID {
Left,
Middle,
Right,
Back,
Forward,
Other(u8),
}
#[derive(Debug, Copy, Clone)]
pub struct MouseScroll {
pub x_delta: f64,
pub y_delta: f64,
}
#[derive(Debug, Copy, Clone)]
pub struct MouseClick {
pub id: MouseButtonID,
2020-09-06 05:55:45 +10:00
pub click_count: usize,
pub x: i32,
pub y: i32,
}
#[derive(Debug)]
pub struct WindowInfo {
pub width: u32,
pub height: u32,
2020-09-06 05:55:45 +10:00
pub scale: f64,
}
#[derive(Debug)]
pub enum Event {
CursorMotion(i32, i32), // new (x, y) relative to window
MouseDown(MouseButtonID),
MouseUp(MouseButtonID),
MouseScroll(MouseScroll),
MouseClick(MouseClick),
2020-09-03 07:23:03 +10:00
KeyDown(u8), // keycode
KeyUp(u8), // keycode
CharacterInput(u32), // character code
WindowResized(WindowInfo), // new (width, height)
WindowFocus,
WindowUnfocus,
WillClose,
2020-09-03 07:23:03 +10:00
}