#![allow(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::as_conversions,
clippy::unnecessary_cast
)]
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 MouseButton {
Left = sys::ImGuiMouseButton_Left as i32,
Right = sys::ImGuiMouseButton_Right as i32,
Middle = sys::ImGuiMouseButton_Middle as i32,
Extra1 = 3,
Extra2 = 4,
}
#[repr(i32)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum MouseCursor {
None = sys::ImGuiMouseCursor_None as i32,
Arrow = sys::ImGuiMouseCursor_Arrow as i32,
TextInput = sys::ImGuiMouseCursor_TextInput as i32,
ResizeAll = sys::ImGuiMouseCursor_ResizeAll as i32,
ResizeNS = sys::ImGuiMouseCursor_ResizeNS as i32,
ResizeEW = sys::ImGuiMouseCursor_ResizeEW as i32,
ResizeNESW = sys::ImGuiMouseCursor_ResizeNESW as i32,
ResizeNWSE = sys::ImGuiMouseCursor_ResizeNWSE as i32,
Hand = sys::ImGuiMouseCursor_Hand as i32,
NotAllowed = sys::ImGuiMouseCursor_NotAllowed as i32,
}
#[repr(i32)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum MouseSource {
Mouse = sys::ImGuiMouseSource_Mouse as i32,
TouchScreen = sys::ImGuiMouseSource_TouchScreen as i32,
Pen = sys::ImGuiMouseSource_Pen as i32,
}
#[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<MouseButton> for sys::ImGuiMouseButton {
#[inline]
fn from(value: MouseButton) -> sys::ImGuiMouseButton {
value as sys::ImGuiMouseButton
}
}
impl From<MouseSource> for sys::ImGuiMouseSource {
#[inline]
fn from(value: MouseSource) -> sys::ImGuiMouseSource {
value as sys::ImGuiMouseSource
}
}
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)
}
}
bitflags! {
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ShortcutFlags: i32 {
const NONE = sys::ImGuiInputFlags_None as i32;
const REPEAT = sys::ImGuiInputFlags_Repeat as i32;
const ROUTE_FROM_ROOT_WINDOW = sys::ImGuiInputFlags_RouteFromRootWindow as i32;
}
}
impl Default for ShortcutFlags {
fn default() -> Self {
ShortcutFlags::NONE
}
}
bitflags! {
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ShortcutGlobalRouteFlags: i32 {
const NONE = sys::ImGuiInputFlags_None as i32;
const OVER_FOCUSED = sys::ImGuiInputFlags_RouteOverFocused as i32;
const OVER_ACTIVE = sys::ImGuiInputFlags_RouteOverActive as i32;
const UNLESS_BG_FOCUSED = sys::ImGuiInputFlags_RouteUnlessBgFocused as i32;
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ShortcutRoute {
Active,
Focused,
FocusedOverActive,
Global(ShortcutGlobalRouteFlags),
Always,
}
impl ShortcutRoute {
#[inline]
const fn raw(self) -> sys::ImGuiInputFlags {
match self {
Self::Active => sys::ImGuiInputFlags_RouteActive as sys::ImGuiInputFlags,
Self::Focused => sys::ImGuiInputFlags_RouteFocused as sys::ImGuiInputFlags,
Self::FocusedOverActive => {
sys::ImGuiInputFlags_RouteFocused as sys::ImGuiInputFlags
| sys::ImGuiInputFlags_RouteOverActive as sys::ImGuiInputFlags
}
Self::Global(flags) => {
sys::ImGuiInputFlags_RouteGlobal as sys::ImGuiInputFlags | flags.bits()
}
Self::Always => sys::ImGuiInputFlags_RouteAlways as sys::ImGuiInputFlags,
}
}
pub const fn bits(self) -> i32 {
self.raw()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ShortcutOptions {
pub flags: ShortcutFlags,
pub route: Option<ShortcutRoute>,
}
impl ShortcutOptions {
pub const fn new() -> Self {
Self {
flags: ShortcutFlags::NONE,
route: None,
}
}
pub fn flags(mut self, flags: ShortcutFlags) -> Self {
self.flags = flags;
self
}
pub fn route(mut self, route: ShortcutRoute) -> Self {
self.route = Some(route);
self
}
pub fn bits(self) -> i32 {
self.raw()
}
#[inline]
pub(crate) fn raw(self) -> sys::ImGuiInputFlags {
self.flags.bits() | self.route.map_or(0, ShortcutRoute::raw)
}
}
impl Default for ShortcutOptions {
fn default() -> Self {
Self::new()
}
}
impl From<ShortcutFlags> for ShortcutOptions {
fn from(flags: ShortcutFlags) -> Self {
Self::new().flags(flags)
}
}
impl From<ShortcutRoute> for ShortcutOptions {
fn from(route: ShortcutRoute) -> Self {
Self::new().route(route)
}
}
pub type InputFlags = ShortcutOptions;
bitflags! {
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NextItemShortcutFlags: i32 {
const NONE = sys::ImGuiInputFlags_None as i32;
const TOOLTIP = sys::ImGuiInputFlags_Tooltip as i32;
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NextItemShortcutOptions {
pub shortcut: ShortcutOptions,
pub flags: NextItemShortcutFlags,
}
impl NextItemShortcutOptions {
pub const fn new() -> Self {
Self {
shortcut: ShortcutOptions::new(),
flags: NextItemShortcutFlags::NONE,
}
}
pub fn shortcut(mut self, options: impl Into<ShortcutOptions>) -> Self {
self.shortcut = options.into();
self
}
pub fn flags(mut self, flags: ShortcutFlags) -> Self {
self.shortcut.flags = flags;
self
}
pub fn route(mut self, route: ShortcutRoute) -> Self {
self.shortcut.route = Some(route);
self
}
pub fn next_item_flags(mut self, flags: NextItemShortcutFlags) -> Self {
self.flags = flags;
self
}
pub fn tooltip(mut self, value: bool) -> Self {
self.flags.set(NextItemShortcutFlags::TOOLTIP, value);
self
}
pub fn bits(self) -> i32 {
self.raw()
}
#[inline]
pub(crate) fn raw(self) -> sys::ImGuiInputFlags {
self.shortcut.raw() | self.flags.bits()
}
}
impl Default for NextItemShortcutOptions {
fn default() -> Self {
Self::new()
}
}
impl From<ShortcutOptions> for NextItemShortcutOptions {
fn from(shortcut: ShortcutOptions) -> Self {
Self::new().shortcut(shortcut)
}
}
impl From<ShortcutFlags> for NextItemShortcutOptions {
fn from(flags: ShortcutFlags) -> Self {
Self::new().flags(flags)
}
}
impl From<ShortcutRoute> for NextItemShortcutOptions {
fn from(route: ShortcutRoute) -> Self {
Self::new().route(route)
}
}
impl From<NextItemShortcutFlags> for NextItemShortcutOptions {
fn from(flags: NextItemShortcutFlags) -> Self {
Self::new().next_item_flags(flags)
}
}
bitflags! {
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ItemKeyOwnerFlags: i32 {
const NONE = sys::ImGuiInputFlags_None as i32;
const LOCK_THIS_FRAME = sys::ImGuiInputFlags_LockThisFrame as i32;
const LOCK_UNTIL_RELEASE = sys::ImGuiInputFlags_LockUntilRelease as i32;
const COND_HOVERED = sys::ImGuiInputFlags_CondHovered as i32;
const COND_ACTIVE = sys::ImGuiInputFlags_CondActive as i32;
}
}
impl Default for ItemKeyOwnerFlags {
fn default() -> Self {
ItemKeyOwnerFlags::NONE
}
}
impl ItemKeyOwnerFlags {
#[inline]
pub(crate) fn raw(self) -> sys::ImGuiInputFlags {
self.bits() as sys::ImGuiInputFlags
}
}
impl Default for NextItemShortcutFlags {
fn default() -> Self {
NextItemShortcutFlags::NONE
}
}
bitflags! {
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct InputTextFlags: i32 {
const NONE = sys::ImGuiInputTextFlags_None as i32;
const CHARS_DECIMAL = sys::ImGuiInputTextFlags_CharsDecimal as i32;
const CHARS_HEXADECIMAL = sys::ImGuiInputTextFlags_CharsHexadecimal as i32;
const CHARS_UPPERCASE = sys::ImGuiInputTextFlags_CharsUppercase as i32;
const CHARS_NO_BLANK = sys::ImGuiInputTextFlags_CharsNoBlank as i32;
const AUTO_SELECT_ALL = sys::ImGuiInputTextFlags_AutoSelectAll as i32;
const ENTER_RETURNS_TRUE = sys::ImGuiInputTextFlags_EnterReturnsTrue as i32;
const CALLBACK_COMPLETION = sys::ImGuiInputTextFlags_CallbackCompletion as i32;
const CALLBACK_HISTORY = sys::ImGuiInputTextFlags_CallbackHistory as i32;
const CALLBACK_ALWAYS = sys::ImGuiInputTextFlags_CallbackAlways as i32;
const CALLBACK_CHAR_FILTER = sys::ImGuiInputTextFlags_CallbackCharFilter as i32;
const ALLOW_TAB_INPUT = sys::ImGuiInputTextFlags_AllowTabInput as i32;
const CTRL_ENTER_FOR_NEW_LINE = sys::ImGuiInputTextFlags_CtrlEnterForNewLine as i32;
const NO_HORIZONTAL_SCROLL = sys::ImGuiInputTextFlags_NoHorizontalScroll as i32;
const ALWAYS_OVERWRITE = sys::ImGuiInputTextFlags_AlwaysOverwrite as i32;
const READ_ONLY = sys::ImGuiInputTextFlags_ReadOnly as i32;
const PASSWORD = sys::ImGuiInputTextFlags_Password as i32;
const NO_UNDO_REDO = sys::ImGuiInputTextFlags_NoUndoRedo as i32;
const CHARS_SCIENTIFIC = sys::ImGuiInputTextFlags_CharsScientific as i32;
const CALLBACK_RESIZE = sys::ImGuiInputTextFlags_CallbackResize as i32;
const CALLBACK_EDIT = sys::ImGuiInputTextFlags_CallbackEdit as i32;
}
}
impl InputTextFlags {
#[inline]
pub(crate) fn raw(self) -> sys::ImGuiInputTextFlags {
self.bits() as sys::ImGuiInputTextFlags
}
}
#[cfg(feature = "serde")]
impl Serialize for InputTextFlags {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_i32(self.bits())
}
}
#[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for InputTextFlags {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let bits = i32::deserialize(deserializer)?;
Ok(InputTextFlags::from_bits_truncate(bits))
}
}
impl crate::Ui {
#[doc(alias = "IsKeyDown")]
pub fn is_key_down(&self, key: Key) -> bool {
unsafe { sys::igIsKeyDown_Nil(key as sys::ImGuiKey) }
}
#[doc(alias = "IsKeyPressed")]
pub fn is_key_pressed(&self, key: Key) -> bool {
unsafe { sys::igIsKeyPressed_Bool(key as sys::ImGuiKey, true) }
}
#[doc(alias = "IsKeyPressed")]
pub fn is_key_pressed_with_repeat(&self, key: Key, repeat: bool) -> bool {
unsafe { sys::igIsKeyPressed_Bool(key as sys::ImGuiKey, repeat) }
}
#[doc(alias = "IsKeyReleased")]
pub fn is_key_released(&self, key: Key) -> bool {
unsafe { sys::igIsKeyReleased_Nil(key as sys::ImGuiKey) }
}
#[doc(alias = "IsKeyChordPressed")]
pub fn is_key_chord_pressed(&self, key_chord: KeyChord) -> bool {
unsafe { sys::igIsKeyChordPressed_Nil(key_chord.raw()) }
}
#[doc(alias = "Shortcut")]
pub fn shortcut(&self, key_chord: KeyChord) -> bool {
self.shortcut_with_flags(key_chord, ShortcutOptions::new())
}
#[doc(alias = "Shortcut")]
pub fn shortcut_with_flags(
&self,
key_chord: KeyChord,
flags: impl Into<ShortcutOptions>,
) -> bool {
unsafe { sys::igShortcut_Nil(key_chord.raw(), flags.into().raw()) }
}
#[doc(alias = "SetNextItemShortcut")]
pub fn set_next_item_shortcut(&self, key_chord: KeyChord) {
self.set_next_item_shortcut_with_flags(key_chord, NextItemShortcutOptions::new());
}
#[doc(alias = "SetNextItemShortcut")]
pub fn set_next_item_shortcut_with_flags(
&self,
key_chord: KeyChord,
flags: impl Into<NextItemShortcutOptions>,
) {
let flags = flags.into();
unsafe { sys::igSetNextItemShortcut(key_chord.raw(), flags.raw()) }
}
#[doc(alias = "SetNextFrameWantCaptureKeyboard")]
pub fn set_next_frame_want_capture_keyboard(&self, want_capture_keyboard: bool) {
unsafe { sys::igSetNextFrameWantCaptureKeyboard(want_capture_keyboard) }
}
#[doc(alias = "SetNextFrameWantCaptureMouse")]
pub fn set_next_frame_want_capture_mouse(&self, want_capture_mouse: bool) {
unsafe { sys::igSetNextFrameWantCaptureMouse(want_capture_mouse) }
}
#[doc(alias = "IsMouseDown")]
pub fn is_mouse_down(&self, button: MouseButton) -> bool {
unsafe { sys::igIsMouseDown_Nil(button.into()) }
}
#[doc(alias = "IsMouseClicked")]
pub fn is_mouse_clicked(&self, button: MouseButton) -> bool {
unsafe { sys::igIsMouseClicked_Bool(button.into(), false) }
}
#[doc(alias = "IsMouseClicked")]
pub fn is_mouse_clicked_with_repeat(&self, button: MouseButton, repeat: bool) -> bool {
unsafe { sys::igIsMouseClicked_Bool(button.into(), repeat) }
}
#[doc(alias = "IsMouseReleased")]
pub fn is_mouse_released(&self, button: MouseButton) -> bool {
unsafe { sys::igIsMouseReleased_Nil(button.into()) }
}
#[doc(alias = "IsMouseDoubleClicked")]
pub fn is_mouse_double_clicked(&self, button: MouseButton) -> bool {
unsafe { sys::igIsMouseDoubleClicked_Nil(button.into()) }
}
#[doc(alias = "IsMousePosValid")]
pub fn is_mouse_pos_valid(&self) -> bool {
unsafe { sys::igIsMousePosValid(std::ptr::null()) }
}
#[doc(alias = "IsMousePosValid")]
pub fn is_mouse_pos_valid_at(&self, pos: [f32; 2]) -> bool {
let v = sys::ImVec2_c {
x: pos[0],
y: pos[1],
};
unsafe { sys::igIsMousePosValid(&v as *const sys::ImVec2_c) }
}
#[doc(alias = "IsMouseReleasedWithDelay")]
pub fn is_mouse_released_with_delay(&self, button: MouseButton, delay: f32) -> bool {
unsafe { sys::igIsMouseReleasedWithDelay(button.into(), delay) }
}
#[doc(alias = "GetMousePos")]
pub fn mouse_pos(&self) -> [f32; 2] {
let pos = unsafe { sys::igGetMousePos() };
[pos.x, pos.y]
}
#[doc(alias = "GetMousePosOnOpeningCurrentPopup")]
pub fn mouse_pos_on_opening_current_popup(&self) -> [f32; 2] {
let pos = unsafe { sys::igGetMousePosOnOpeningCurrentPopup() };
[pos.x, pos.y]
}
#[doc(alias = "IsMouseHoveringRect")]
pub fn is_mouse_hovering_rect(&self, r_min: [f32; 2], r_max: [f32; 2]) -> bool {
unsafe {
sys::igIsMouseHoveringRect(
sys::ImVec2::new(r_min[0], r_min[1]),
sys::ImVec2::new(r_max[0], r_max[1]),
true,
)
}
}
#[doc(alias = "IsMouseHoveringRect")]
pub fn is_mouse_hovering_rect_with_clip(
&self,
r_min: [f32; 2],
r_max: [f32; 2],
clip: bool,
) -> bool {
unsafe {
sys::igIsMouseHoveringRect(
sys::ImVec2::new(r_min[0], r_min[1]),
sys::ImVec2::new(r_max[0], r_max[1]),
clip,
)
}
}
#[doc(alias = "IsMouseDragging")]
pub fn is_mouse_dragging(&self, button: MouseButton) -> bool {
unsafe { sys::igIsMouseDragging(button as i32, -1.0) }
}
#[doc(alias = "IsMouseDragging")]
pub fn is_mouse_dragging_with_threshold(
&self,
button: MouseButton,
lock_threshold: f32,
) -> bool {
unsafe { sys::igIsMouseDragging(button as i32, lock_threshold) }
}
#[doc(alias = "GetMouseDragDelta")]
pub fn mouse_drag_delta(&self, button: MouseButton) -> [f32; 2] {
let delta = unsafe { sys::igGetMouseDragDelta(button as i32, -1.0) };
[delta.x, delta.y]
}
#[doc(alias = "GetMouseDragDelta")]
pub fn mouse_drag_delta_with_threshold(
&self,
button: MouseButton,
lock_threshold: f32,
) -> [f32; 2] {
let delta = unsafe { sys::igGetMouseDragDelta(button as i32, lock_threshold) };
[delta.x, delta.y]
}
#[doc(alias = "ResetMouseDragDelta")]
pub fn reset_mouse_drag_delta(&self, button: MouseButton) {
unsafe { sys::igResetMouseDragDelta(button as i32) }
}
#[doc(alias = "IsItemToggledSelection")]
pub fn is_item_toggled_selection(&self) -> bool {
unsafe { sys::igIsItemToggledSelection() }
}
}