2015-01-04 09:11:59 +11:00
|
|
|
#[derive(Clone, Show, Copy)]
|
2014-07-27 20:59:45 +10:00
|
|
|
pub enum Event {
|
|
|
|
/// The size of the window has changed.
|
2015-01-13 23:21:36 +11:00
|
|
|
Resized(u32, u32),
|
2014-07-27 20:59:45 +10:00
|
|
|
|
2014-07-28 04:08:31 +10:00
|
|
|
/// The position of the window has changed.
|
2015-01-13 23:21:36 +11:00
|
|
|
Moved(i32, i32),
|
2014-07-28 04:08:31 +10:00
|
|
|
|
2014-07-27 20:59:45 +10:00
|
|
|
/// The window has been closed.
|
|
|
|
Closed,
|
|
|
|
|
2014-07-28 01:06:03 +10:00
|
|
|
/// The window received a unicode character.
|
|
|
|
ReceivedCharacter(char),
|
|
|
|
|
2014-07-27 20:59:45 +10:00
|
|
|
/// The window gained or lost focus.
|
2014-10-11 21:04:48 +11:00
|
|
|
///
|
2014-07-27 20:59:45 +10:00
|
|
|
/// The parameter is true if the window has gained focus, and false if it has lost focus.
|
|
|
|
Focused(bool),
|
|
|
|
|
2014-08-14 01:04:57 +10:00
|
|
|
/// An event from the keyboard has been received.
|
2014-10-31 00:01:52 +11:00
|
|
|
KeyboardInput(ElementState, ScanCode, Option<VirtualKeyCode>),
|
2014-08-14 01:04:57 +10:00
|
|
|
|
|
|
|
/// The cursor has moved on the window.
|
2014-10-11 21:04:48 +11:00
|
|
|
///
|
2014-08-14 01:04:57 +10:00
|
|
|
/// The parameter are the (x,y) coords in pixels relative to the top-left corner of the window.
|
2015-01-13 23:21:36 +11:00
|
|
|
MouseMoved((i32, i32)),
|
2014-08-14 01:04:57 +10:00
|
|
|
|
|
|
|
/// A positive value indicates that the wheel was rotated forward, away from the user;
|
|
|
|
/// a negative value indicates that the wheel was rotated backward, toward the user.
|
|
|
|
MouseWheel(i32),
|
|
|
|
|
|
|
|
/// An event from the mouse has been received.
|
|
|
|
MouseInput(ElementState, MouseButton),
|
2014-12-17 15:49:11 +11:00
|
|
|
|
2014-12-18 11:57:12 +11:00
|
|
|
/// The event loop was woken up by another thread.
|
|
|
|
Awakened,
|
2014-08-14 01:04:57 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
pub type ScanCode = u8;
|
|
|
|
|
2015-01-04 09:11:59 +11:00
|
|
|
#[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
2014-08-14 01:04:57 +10:00
|
|
|
pub enum ElementState {
|
|
|
|
Pressed,
|
|
|
|
Released,
|
|
|
|
}
|
2014-07-28 01:06:03 +10:00
|
|
|
|
2015-01-04 09:11:59 +11:00
|
|
|
#[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
2014-08-14 01:04:57 +10:00
|
|
|
pub enum MouseButton {
|
|
|
|
LeftMouseButton,
|
|
|
|
RightMouseButton,
|
|
|
|
MiddleMouseButton,
|
|
|
|
OtherMouseButton(u8),
|
2014-07-28 01:06:03 +10:00
|
|
|
}
|
|
|
|
|
2015-01-04 09:11:59 +11:00
|
|
|
#[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
2014-08-14 01:04:57 +10:00
|
|
|
pub enum VirtualKeyCode {
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '1' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key1,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '2' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key2,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '3' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key3,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '4' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key4,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '5' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key5,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '6' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key6,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '7' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key7,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '8' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key8,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '9' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key9,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '0' key over the 'O' and 'P' keys.
|
|
|
|
Key0,
|
|
|
|
|
2014-07-28 01:06:03 +10:00
|
|
|
A,
|
|
|
|
B,
|
|
|
|
C,
|
|
|
|
D,
|
|
|
|
E,
|
|
|
|
F,
|
2014-11-06 23:26:42 +11:00
|
|
|
G,
|
|
|
|
H,
|
|
|
|
I,
|
|
|
|
J,
|
|
|
|
K,
|
|
|
|
L,
|
|
|
|
M,
|
|
|
|
N,
|
|
|
|
O,
|
|
|
|
P,
|
|
|
|
Q,
|
|
|
|
R,
|
|
|
|
S,
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
V,
|
|
|
|
W,
|
|
|
|
X,
|
|
|
|
Y,
|
|
|
|
Z,
|
|
|
|
|
|
|
|
/// The Escape key, next to F1.
|
|
|
|
Escape,
|
|
|
|
|
2014-07-28 01:06:03 +10:00
|
|
|
F1,
|
|
|
|
F2,
|
|
|
|
F3,
|
|
|
|
F4,
|
|
|
|
F5,
|
|
|
|
F6,
|
|
|
|
F7,
|
|
|
|
F8,
|
|
|
|
F9,
|
|
|
|
F10,
|
|
|
|
F11,
|
|
|
|
F12,
|
|
|
|
F13,
|
|
|
|
F14,
|
|
|
|
F15,
|
2014-11-06 23:26:42 +11:00
|
|
|
|
|
|
|
/// Print Screen/SysRq.
|
|
|
|
Snapshot,
|
|
|
|
/// Scroll Lock.
|
|
|
|
Scroll,
|
|
|
|
/// Pause/Break key, next to Scroll lock.
|
|
|
|
Pause,
|
|
|
|
|
|
|
|
/// `Insert`, next to Backspace.
|
2014-07-28 01:06:03 +10:00
|
|
|
Insert,
|
2014-11-06 23:26:42 +11:00
|
|
|
Home,
|
|
|
|
Delete,
|
|
|
|
End,
|
|
|
|
PageDown,
|
|
|
|
PageUp,
|
|
|
|
|
|
|
|
Left,
|
|
|
|
Up,
|
|
|
|
Right,
|
|
|
|
Down,
|
|
|
|
|
|
|
|
/// The Backspace key, right over Enter.
|
|
|
|
// TODO: rename
|
|
|
|
Back,
|
|
|
|
/// The Enter key.
|
|
|
|
Return,
|
|
|
|
/// The space bar.
|
|
|
|
Space,
|
|
|
|
|
|
|
|
Numlock,
|
|
|
|
Numpad0,
|
|
|
|
Numpad1,
|
|
|
|
Numpad2,
|
|
|
|
Numpad3,
|
|
|
|
Numpad4,
|
|
|
|
Numpad5,
|
|
|
|
Numpad6,
|
|
|
|
Numpad7,
|
|
|
|
Numpad8,
|
|
|
|
Numpad9,
|
|
|
|
|
|
|
|
AbntC1,
|
|
|
|
AbntC2,
|
|
|
|
Add,
|
|
|
|
Apostrophe,
|
|
|
|
Apps,
|
|
|
|
At,
|
|
|
|
Ax,
|
|
|
|
Backslash,
|
|
|
|
Calculator,
|
|
|
|
Capital,
|
|
|
|
Colon,
|
|
|
|
Comma,
|
|
|
|
Convert,
|
|
|
|
Decimal,
|
|
|
|
Divide,
|
|
|
|
Equals,
|
|
|
|
Grave,
|
2014-07-28 01:06:03 +10:00
|
|
|
Kana,
|
|
|
|
Kanji,
|
2014-10-24 03:01:09 +11:00
|
|
|
LAlt,
|
2014-10-15 20:49:10 +11:00
|
|
|
LBracket,
|
2014-07-28 01:06:03 +10:00
|
|
|
LControl,
|
|
|
|
LMenu,
|
|
|
|
LShift,
|
|
|
|
LWin,
|
|
|
|
Mail,
|
|
|
|
MediaSelect,
|
|
|
|
MediaStop,
|
|
|
|
Minus,
|
|
|
|
Multiply,
|
|
|
|
Mute,
|
|
|
|
MyComputer,
|
|
|
|
NextTrack,
|
|
|
|
NoConvert,
|
|
|
|
NumpadComma,
|
|
|
|
NumpadEnter,
|
|
|
|
NumpadEquals,
|
|
|
|
OEM102,
|
|
|
|
Period,
|
|
|
|
Playpause,
|
|
|
|
Power,
|
|
|
|
Prevtrack,
|
2014-10-24 03:01:09 +11:00
|
|
|
RAlt,
|
2014-07-28 01:06:03 +10:00
|
|
|
RBracket,
|
|
|
|
RControl,
|
|
|
|
RMenu,
|
|
|
|
RShift,
|
|
|
|
RWin,
|
|
|
|
Semicolon,
|
|
|
|
Slash,
|
|
|
|
Sleep,
|
|
|
|
Stop,
|
|
|
|
Subtract,
|
|
|
|
Sysrq,
|
|
|
|
Tab,
|
|
|
|
Underline,
|
|
|
|
Unlabeled,
|
|
|
|
VolumeDown,
|
|
|
|
VolumeUp,
|
|
|
|
Wake,
|
|
|
|
Webback,
|
|
|
|
WebFavorites,
|
|
|
|
WebForward,
|
|
|
|
WebHome,
|
|
|
|
WebRefresh,
|
|
|
|
WebSearch,
|
|
|
|
WebStop,
|
|
|
|
Yen,
|
2014-07-27 20:59:45 +10:00
|
|
|
}
|