use crate::sys;
use bitflags::bitflags;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[repr(i32)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum Key {
None = sys::ImGuiKey_None as i32,
Tab = sys::ImGuiKey_Tab as i32,
LeftArrow = sys::ImGuiKey_LeftArrow as i32,
RightArrow = sys::ImGuiKey_RightArrow as i32,
UpArrow = sys::ImGuiKey_UpArrow as i32,
DownArrow = sys::ImGuiKey_DownArrow as i32,
PageUp = sys::ImGuiKey_PageUp as i32,
PageDown = sys::ImGuiKey_PageDown as i32,
Home = sys::ImGuiKey_Home as i32,
End = sys::ImGuiKey_End as i32,
Insert = sys::ImGuiKey_Insert as i32,
Delete = sys::ImGuiKey_Delete as i32,
Backspace = sys::ImGuiKey_Backspace as i32,
Space = sys::ImGuiKey_Space as i32,
Enter = sys::ImGuiKey_Enter as i32,
Escape = sys::ImGuiKey_Escape as i32,
LeftCtrl = sys::ImGuiKey_LeftCtrl as i32,
LeftShift = sys::ImGuiKey_LeftShift as i32,
LeftAlt = sys::ImGuiKey_LeftAlt as i32,
LeftSuper = sys::ImGuiKey_LeftSuper as i32,
RightCtrl = sys::ImGuiKey_RightCtrl as i32,
RightShift = sys::ImGuiKey_RightShift as i32,
RightAlt = sys::ImGuiKey_RightAlt as i32,
RightSuper = sys::ImGuiKey_RightSuper as i32,
ModCtrl = sys::ImGuiMod_Ctrl as i32,
ModShift = sys::ImGuiMod_Shift as i32,
ModAlt = sys::ImGuiMod_Alt as i32,
ModSuper = sys::ImGuiMod_Super as i32,
Menu = sys::ImGuiKey_Menu as i32,
Key0 = sys::ImGuiKey_0 as i32,
Key1 = sys::ImGuiKey_1 as i32,
Key2 = sys::ImGuiKey_2 as i32,
Key3 = sys::ImGuiKey_3 as i32,
Key4 = sys::ImGuiKey_4 as i32,
Key5 = sys::ImGuiKey_5 as i32,
Key6 = sys::ImGuiKey_6 as i32,
Key7 = sys::ImGuiKey_7 as i32,
Key8 = sys::ImGuiKey_8 as i32,
Key9 = sys::ImGuiKey_9 as i32,
A = sys::ImGuiKey_A as i32,
B = sys::ImGuiKey_B as i32,
C = sys::ImGuiKey_C as i32,
D = sys::ImGuiKey_D as i32,
E = sys::ImGuiKey_E as i32,
F = sys::ImGuiKey_F as i32,
G = sys::ImGuiKey_G as i32,
H = sys::ImGuiKey_H as i32,
I = sys::ImGuiKey_I as i32,
J = sys::ImGuiKey_J as i32,
K = sys::ImGuiKey_K as i32,
L = sys::ImGuiKey_L as i32,
M = sys::ImGuiKey_M as i32,
N = sys::ImGuiKey_N as i32,
O = sys::ImGuiKey_O as i32,
P = sys::ImGuiKey_P as i32,
Q = sys::ImGuiKey_Q as i32,
R = sys::ImGuiKey_R as i32,
S = sys::ImGuiKey_S as i32,
T = sys::ImGuiKey_T as i32,
U = sys::ImGuiKey_U as i32,
V = sys::ImGuiKey_V as i32,
W = sys::ImGuiKey_W as i32,
X = sys::ImGuiKey_X as i32,
Y = sys::ImGuiKey_Y as i32,
Z = sys::ImGuiKey_Z as i32,
F1 = sys::ImGuiKey_F1 as i32,
F2 = sys::ImGuiKey_F2 as i32,
F3 = sys::ImGuiKey_F3 as i32,
F4 = sys::ImGuiKey_F4 as i32,
F5 = sys::ImGuiKey_F5 as i32,
F6 = sys::ImGuiKey_F6 as i32,
F7 = sys::ImGuiKey_F7 as i32,
F8 = sys::ImGuiKey_F8 as i32,
F9 = sys::ImGuiKey_F9 as i32,
F10 = sys::ImGuiKey_F10 as i32,
F11 = sys::ImGuiKey_F11 as i32,
F12 = sys::ImGuiKey_F12 as i32,
Apostrophe = sys::ImGuiKey_Apostrophe as i32,
Comma = sys::ImGuiKey_Comma as i32,
Minus = sys::ImGuiKey_Minus as i32,
Period = sys::ImGuiKey_Period as i32,
Slash = sys::ImGuiKey_Slash as i32,
Semicolon = sys::ImGuiKey_Semicolon as i32,
Equal = sys::ImGuiKey_Equal as i32,
LeftBracket = sys::ImGuiKey_LeftBracket as i32,
Backslash = sys::ImGuiKey_Backslash as i32,
RightBracket = sys::ImGuiKey_RightBracket as i32,
GraveAccent = sys::ImGuiKey_GraveAccent as i32,
CapsLock = sys::ImGuiKey_CapsLock as i32,
ScrollLock = sys::ImGuiKey_ScrollLock as i32,
NumLock = sys::ImGuiKey_NumLock as i32,
PrintScreen = sys::ImGuiKey_PrintScreen as i32,
Pause = sys::ImGuiKey_Pause as i32,
Keypad0 = sys::ImGuiKey_Keypad0 as i32,
Keypad1 = sys::ImGuiKey_Keypad1 as i32,
Keypad2 = sys::ImGuiKey_Keypad2 as i32,
Keypad3 = sys::ImGuiKey_Keypad3 as i32,
Keypad4 = sys::ImGuiKey_Keypad4 as i32,
Keypad5 = sys::ImGuiKey_Keypad5 as i32,
Keypad6 = sys::ImGuiKey_Keypad6 as i32,
Keypad7 = sys::ImGuiKey_Keypad7 as i32,
Keypad8 = sys::ImGuiKey_Keypad8 as i32,
Keypad9 = sys::ImGuiKey_Keypad9 as i32,
KeypadDecimal = sys::ImGuiKey_KeypadDecimal as i32,
KeypadDivide = sys::ImGuiKey_KeypadDivide as i32,
KeypadMultiply = sys::ImGuiKey_KeypadMultiply as i32,
KeypadSubtract = sys::ImGuiKey_KeypadSubtract as i32,
KeypadAdd = sys::ImGuiKey_KeypadAdd as i32,
KeypadEnter = sys::ImGuiKey_KeypadEnter as i32,
KeypadEqual = sys::ImGuiKey_KeypadEqual as i32,
Oem102 = sys::ImGuiKey_Oem102 as i32,
}
impl From<Key> for sys::ImGuiKey {
#[inline]
fn from(value: Key) -> sys::ImGuiKey {
value as sys::ImGuiKey
}
}
bitflags! {
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct KeyMods: i32 {
const CTRL = sys::ImGuiMod_Ctrl as i32;
const SHIFT = sys::ImGuiMod_Shift as i32;
const ALT = sys::ImGuiMod_Alt as i32;
const SUPER = sys::ImGuiMod_Super as i32;
}
}
impl Default for KeyMods {
fn default() -> Self {
KeyMods::empty()
}
}
impl KeyMods {
#[inline]
pub(crate) fn raw(self) -> sys::ImGuiKeyChord {
self.bits() as sys::ImGuiKeyChord
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct KeyChord(sys::ImGuiKeyChord);
impl KeyChord {
pub fn new(key: Key) -> Self {
Self(key as sys::ImGuiKeyChord)
}
pub fn with_mods(self, mods: KeyMods) -> Self {
Self(self.0 | mods.raw())
}
pub fn raw(self) -> sys::ImGuiKeyChord {
self.0
}
}
impl From<Key> for KeyChord {
fn from(value: Key) -> Self {
Self::new(value)
}
}