2020-09-12 01:21:05 +10:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
pub enum KeyboardEvent {
|
|
|
|
KeyPressed(u32),
|
|
|
|
KeyReleased(u32),
|
|
|
|
CharacterInput(char),
|
|
|
|
}
|
|
|
|
|
2020-09-03 07:22:49 +10:00
|
|
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
2020-09-12 01:21:05 +10:00
|
|
|
pub enum MouseButton {
|
2020-09-03 07:22:49 +10:00
|
|
|
Left,
|
|
|
|
Middle,
|
|
|
|
Right,
|
|
|
|
Back,
|
|
|
|
Forward,
|
|
|
|
Other(u8),
|
|
|
|
}
|
|
|
|
|
2020-09-12 01:21:05 +10:00
|
|
|
/// A scroll movement.
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
pub enum ScrollDelta {
|
|
|
|
/// A line-based scroll movement
|
|
|
|
Lines {
|
|
|
|
/// The number of horizontal lines scrolled
|
|
|
|
x: f32,
|
|
|
|
|
|
|
|
/// The number of vertical lines scrolled
|
|
|
|
y: f32,
|
|
|
|
},
|
|
|
|
/// A pixel-based scroll movement
|
|
|
|
Pixels {
|
|
|
|
/// The number of horizontal pixels scrolled
|
|
|
|
x: f32,
|
|
|
|
/// The number of vertical pixels scrolled
|
|
|
|
y: f32,
|
|
|
|
},
|
2020-09-03 07:22:49 +10:00
|
|
|
}
|
|
|
|
|
2020-09-12 01:21:05 +10:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
2020-09-03 07:22:49 +10:00
|
|
|
pub struct MouseClick {
|
2020-09-12 01:21:05 +10:00
|
|
|
pub button: MouseButton,
|
2020-09-06 05:55:45 +10:00
|
|
|
pub click_count: usize,
|
2020-09-03 07:22:49 +10:00
|
|
|
pub x: i32,
|
|
|
|
pub y: i32,
|
|
|
|
}
|
|
|
|
|
2020-09-12 01:21:05 +10:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
pub enum MouseEvent {
|
|
|
|
/// The mouse cursor was moved
|
|
|
|
CursorMoved {
|
|
|
|
/// The X coordinate of the mouse position
|
|
|
|
x: i32,
|
|
|
|
/// The Y coordinate of the mouse position
|
|
|
|
y: i32,
|
|
|
|
},
|
|
|
|
|
|
|
|
/// A mouse button was pressed.
|
|
|
|
ButtonPressed(MouseButton),
|
|
|
|
|
|
|
|
/// A mouse button was released.
|
|
|
|
ButtonReleased(MouseButton),
|
|
|
|
|
|
|
|
/// A mouse button was clicked.
|
|
|
|
Click(MouseClick),
|
|
|
|
|
|
|
|
/// The mouse wheel was scrolled.
|
|
|
|
WheelScrolled(ScrollDelta),
|
|
|
|
|
|
|
|
/// The mouse cursor entered the window.
|
|
|
|
CursorEntered,
|
|
|
|
|
|
|
|
/// The mouse cursor left the window.
|
|
|
|
CursorLeft,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
2020-09-03 07:22:49 +10:00
|
|
|
pub struct WindowInfo {
|
|
|
|
pub width: u32,
|
|
|
|
pub height: u32,
|
2020-09-12 01:21:05 +10:00
|
|
|
pub scale_factor: f64,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
pub enum WindowEvent {
|
|
|
|
Resized(WindowInfo),
|
|
|
|
Focused,
|
|
|
|
Unfocused,
|
|
|
|
WillClose,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Debug)]
|
|
|
|
pub enum FileDropEvent {
|
|
|
|
/// A file is being hovered over the window.
|
|
|
|
FileHovered(PathBuf),
|
|
|
|
|
|
|
|
/// A file has beend dropped into the window.
|
|
|
|
FileDropped(PathBuf),
|
|
|
|
|
|
|
|
/// A file was hovered, but has exited the window.
|
|
|
|
FilesHoveredLeft,
|
2020-09-03 07:22:49 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2020-09-04 02:38:22 +10:00
|
|
|
pub enum Event {
|
2020-09-12 01:21:05 +10:00
|
|
|
Interval(f64), // delta time passed
|
|
|
|
Mouse(MouseEvent),
|
|
|
|
Keyboard(KeyboardEvent),
|
|
|
|
Window(WindowEvent),
|
|
|
|
FileDrop(FileDropEvent),
|
2020-09-03 07:23:03 +10:00
|
|
|
}
|