1#![allow(
10 clippy::cast_possible_truncation,
11 clippy::cast_sign_loss,
12 clippy::as_conversions,
13 clippy::unnecessary_cast
14)]
15use crate::sys;
16use bitflags::bitflags;
17#[cfg(feature = "serde")]
18use serde::{Deserialize, Serialize};
19
20#[repr(i32)]
22#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
23#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
24pub enum MouseButton {
25 Left = sys::ImGuiMouseButton_Left as i32,
27 Right = sys::ImGuiMouseButton_Right as i32,
29 Middle = sys::ImGuiMouseButton_Middle as i32,
31 Extra1 = 3,
33 Extra2 = 4,
35}
36
37#[repr(i32)]
39#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
40#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
41pub enum MouseCursor {
42 None = sys::ImGuiMouseCursor_None as i32,
44 Arrow = sys::ImGuiMouseCursor_Arrow as i32,
46 TextInput = sys::ImGuiMouseCursor_TextInput as i32,
48 ResizeAll = sys::ImGuiMouseCursor_ResizeAll as i32,
50 ResizeNS = sys::ImGuiMouseCursor_ResizeNS as i32,
52 ResizeEW = sys::ImGuiMouseCursor_ResizeEW as i32,
54 ResizeNESW = sys::ImGuiMouseCursor_ResizeNESW as i32,
56 ResizeNWSE = sys::ImGuiMouseCursor_ResizeNWSE as i32,
58 Hand = sys::ImGuiMouseCursor_Hand as i32,
60 NotAllowed = sys::ImGuiMouseCursor_NotAllowed as i32,
62}
63
64#[repr(i32)]
70#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
71#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
72pub enum MouseSource {
73 Mouse = sys::ImGuiMouseSource_Mouse as i32,
75 TouchScreen = sys::ImGuiMouseSource_TouchScreen as i32,
77 Pen = sys::ImGuiMouseSource_Pen as i32,
79}
80
81#[repr(i32)]
83#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
84#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
85pub enum Key {
86 None = sys::ImGuiKey_None as i32,
88 Tab = sys::ImGuiKey_Tab as i32,
90 LeftArrow = sys::ImGuiKey_LeftArrow as i32,
92 RightArrow = sys::ImGuiKey_RightArrow as i32,
94 UpArrow = sys::ImGuiKey_UpArrow as i32,
96 DownArrow = sys::ImGuiKey_DownArrow as i32,
98 PageUp = sys::ImGuiKey_PageUp as i32,
100 PageDown = sys::ImGuiKey_PageDown as i32,
102 Home = sys::ImGuiKey_Home as i32,
104 End = sys::ImGuiKey_End as i32,
106 Insert = sys::ImGuiKey_Insert as i32,
108 Delete = sys::ImGuiKey_Delete as i32,
110 Backspace = sys::ImGuiKey_Backspace as i32,
112 Space = sys::ImGuiKey_Space as i32,
114 Enter = sys::ImGuiKey_Enter as i32,
116 Escape = sys::ImGuiKey_Escape as i32,
118 LeftCtrl = sys::ImGuiKey_LeftCtrl as i32,
120 LeftShift = sys::ImGuiKey_LeftShift as i32,
122 LeftAlt = sys::ImGuiKey_LeftAlt as i32,
124 LeftSuper = sys::ImGuiKey_LeftSuper as i32,
126 RightCtrl = sys::ImGuiKey_RightCtrl as i32,
128 RightShift = sys::ImGuiKey_RightShift as i32,
130 RightAlt = sys::ImGuiKey_RightAlt as i32,
132 RightSuper = sys::ImGuiKey_RightSuper as i32,
134 ModCtrl = sys::ImGuiMod_Ctrl as i32,
136 ModShift = sys::ImGuiMod_Shift as i32,
138 ModAlt = sys::ImGuiMod_Alt as i32,
140 ModSuper = sys::ImGuiMod_Super as i32,
142 Menu = sys::ImGuiKey_Menu as i32,
144 Key0 = sys::ImGuiKey_0 as i32,
146 Key1 = sys::ImGuiKey_1 as i32,
148 Key2 = sys::ImGuiKey_2 as i32,
150 Key3 = sys::ImGuiKey_3 as i32,
152 Key4 = sys::ImGuiKey_4 as i32,
154 Key5 = sys::ImGuiKey_5 as i32,
156 Key6 = sys::ImGuiKey_6 as i32,
158 Key7 = sys::ImGuiKey_7 as i32,
160 Key8 = sys::ImGuiKey_8 as i32,
162 Key9 = sys::ImGuiKey_9 as i32,
164 A = sys::ImGuiKey_A as i32,
166 B = sys::ImGuiKey_B as i32,
168 C = sys::ImGuiKey_C as i32,
170 D = sys::ImGuiKey_D as i32,
172 E = sys::ImGuiKey_E as i32,
174 F = sys::ImGuiKey_F as i32,
176 G = sys::ImGuiKey_G as i32,
178 H = sys::ImGuiKey_H as i32,
180 I = sys::ImGuiKey_I as i32,
182 J = sys::ImGuiKey_J as i32,
184 K = sys::ImGuiKey_K as i32,
186 L = sys::ImGuiKey_L as i32,
188 M = sys::ImGuiKey_M as i32,
190 N = sys::ImGuiKey_N as i32,
192 O = sys::ImGuiKey_O as i32,
194 P = sys::ImGuiKey_P as i32,
196 Q = sys::ImGuiKey_Q as i32,
198 R = sys::ImGuiKey_R as i32,
200 S = sys::ImGuiKey_S as i32,
202 T = sys::ImGuiKey_T as i32,
204 U = sys::ImGuiKey_U as i32,
206 V = sys::ImGuiKey_V as i32,
208 W = sys::ImGuiKey_W as i32,
210 X = sys::ImGuiKey_X as i32,
212 Y = sys::ImGuiKey_Y as i32,
214 Z = sys::ImGuiKey_Z as i32,
216 F1 = sys::ImGuiKey_F1 as i32,
218 F2 = sys::ImGuiKey_F2 as i32,
220 F3 = sys::ImGuiKey_F3 as i32,
222 F4 = sys::ImGuiKey_F4 as i32,
224 F5 = sys::ImGuiKey_F5 as i32,
226 F6 = sys::ImGuiKey_F6 as i32,
228 F7 = sys::ImGuiKey_F7 as i32,
230 F8 = sys::ImGuiKey_F8 as i32,
232 F9 = sys::ImGuiKey_F9 as i32,
234 F10 = sys::ImGuiKey_F10 as i32,
236 F11 = sys::ImGuiKey_F11 as i32,
238 F12 = sys::ImGuiKey_F12 as i32,
240
241 Apostrophe = sys::ImGuiKey_Apostrophe as i32,
244 Comma = sys::ImGuiKey_Comma as i32,
246 Minus = sys::ImGuiKey_Minus as i32,
248 Period = sys::ImGuiKey_Period as i32,
250 Slash = sys::ImGuiKey_Slash as i32,
252 Semicolon = sys::ImGuiKey_Semicolon as i32,
254 Equal = sys::ImGuiKey_Equal as i32,
256 LeftBracket = sys::ImGuiKey_LeftBracket as i32,
258 Backslash = sys::ImGuiKey_Backslash as i32,
260 RightBracket = sys::ImGuiKey_RightBracket as i32,
262 GraveAccent = sys::ImGuiKey_GraveAccent as i32,
264 CapsLock = sys::ImGuiKey_CapsLock as i32,
266 ScrollLock = sys::ImGuiKey_ScrollLock as i32,
268 NumLock = sys::ImGuiKey_NumLock as i32,
270 PrintScreen = sys::ImGuiKey_PrintScreen as i32,
272 Pause = sys::ImGuiKey_Pause as i32,
274
275 Keypad0 = sys::ImGuiKey_Keypad0 as i32,
278 Keypad1 = sys::ImGuiKey_Keypad1 as i32,
280 Keypad2 = sys::ImGuiKey_Keypad2 as i32,
282 Keypad3 = sys::ImGuiKey_Keypad3 as i32,
284 Keypad4 = sys::ImGuiKey_Keypad4 as i32,
286 Keypad5 = sys::ImGuiKey_Keypad5 as i32,
288 Keypad6 = sys::ImGuiKey_Keypad6 as i32,
290 Keypad7 = sys::ImGuiKey_Keypad7 as i32,
292 Keypad8 = sys::ImGuiKey_Keypad8 as i32,
294 Keypad9 = sys::ImGuiKey_Keypad9 as i32,
296 KeypadDecimal = sys::ImGuiKey_KeypadDecimal as i32,
298 KeypadDivide = sys::ImGuiKey_KeypadDivide as i32,
300 KeypadMultiply = sys::ImGuiKey_KeypadMultiply as i32,
302 KeypadSubtract = sys::ImGuiKey_KeypadSubtract as i32,
304 KeypadAdd = sys::ImGuiKey_KeypadAdd as i32,
306 KeypadEnter = sys::ImGuiKey_KeypadEnter as i32,
308 KeypadEqual = sys::ImGuiKey_KeypadEqual as i32,
310
311 Oem102 = sys::ImGuiKey_Oem102 as i32,
313}
314
315impl From<MouseButton> for sys::ImGuiMouseButton {
316 #[inline]
317 fn from(value: MouseButton) -> sys::ImGuiMouseButton {
318 value as sys::ImGuiMouseButton
319 }
320}
321
322impl From<MouseSource> for sys::ImGuiMouseSource {
323 #[inline]
324 fn from(value: MouseSource) -> sys::ImGuiMouseSource {
325 value as sys::ImGuiMouseSource
326 }
327}
328
329impl From<Key> for sys::ImGuiKey {
330 #[inline]
331 fn from(value: Key) -> sys::ImGuiKey {
332 value as sys::ImGuiKey
333 }
334}
335
336bitflags! {
340 #[repr(transparent)]
342 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
343 pub struct KeyMods: i32 {
344 const CTRL = sys::ImGuiMod_Ctrl as i32;
346 const SHIFT = sys::ImGuiMod_Shift as i32;
348 const ALT = sys::ImGuiMod_Alt as i32;
350 const SUPER = sys::ImGuiMod_Super as i32;
352 }
353}
354
355impl Default for KeyMods {
356 fn default() -> Self {
357 KeyMods::empty()
358 }
359}
360
361impl KeyMods {
362 #[inline]
363 pub(crate) fn raw(self) -> sys::ImGuiKeyChord {
364 self.bits() as sys::ImGuiKeyChord
365 }
366}
367
368#[repr(transparent)]
372#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
373pub struct KeyChord(sys::ImGuiKeyChord);
374
375impl KeyChord {
376 pub fn new(key: Key) -> Self {
378 Self(key as sys::ImGuiKeyChord)
379 }
380
381 pub fn with_mods(self, mods: KeyMods) -> Self {
383 Self(self.0 | mods.raw())
384 }
385
386 pub fn raw(self) -> sys::ImGuiKeyChord {
388 self.0
389 }
390}
391
392impl From<Key> for KeyChord {
393 fn from(value: Key) -> Self {
394 Self::new(value)
395 }
396}
397
398bitflags! {
399 #[repr(transparent)]
404 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
405 pub struct ShortcutFlags: i32 {
406 const NONE = sys::ImGuiInputFlags_None as i32;
407 const REPEAT = sys::ImGuiInputFlags_Repeat as i32;
408 const ROUTE_FROM_ROOT_WINDOW = sys::ImGuiInputFlags_RouteFromRootWindow as i32;
409 }
410}
411
412impl Default for ShortcutFlags {
413 fn default() -> Self {
414 ShortcutFlags::NONE
415 }
416}
417
418bitflags! {
419 #[repr(transparent)]
421 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
422 pub struct ShortcutGlobalRouteFlags: i32 {
423 const NONE = sys::ImGuiInputFlags_None as i32;
424 const OVER_FOCUSED = sys::ImGuiInputFlags_RouteOverFocused as i32;
425 const OVER_ACTIVE = sys::ImGuiInputFlags_RouteOverActive as i32;
426 const UNLESS_BG_FOCUSED = sys::ImGuiInputFlags_RouteUnlessBgFocused as i32;
427 }
428}
429
430#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
432pub enum ShortcutRoute {
433 Active,
435 Focused,
438 FocusedOverActive,
440 Global(ShortcutGlobalRouteFlags),
442 Always,
444}
445
446impl ShortcutRoute {
447 #[inline]
448 const fn raw(self) -> sys::ImGuiInputFlags {
449 match self {
450 Self::Active => sys::ImGuiInputFlags_RouteActive as sys::ImGuiInputFlags,
451 Self::Focused => sys::ImGuiInputFlags_RouteFocused as sys::ImGuiInputFlags,
452 Self::FocusedOverActive => {
453 sys::ImGuiInputFlags_RouteFocused as sys::ImGuiInputFlags
454 | sys::ImGuiInputFlags_RouteOverActive as sys::ImGuiInputFlags
455 }
456 Self::Global(flags) => {
457 sys::ImGuiInputFlags_RouteGlobal as sys::ImGuiInputFlags | flags.bits()
458 }
459 Self::Always => sys::ImGuiInputFlags_RouteAlways as sys::ImGuiInputFlags,
460 }
461 }
462
463 pub const fn bits(self) -> i32 {
465 self.raw()
466 }
467}
468
469#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
472pub struct ShortcutOptions {
473 pub flags: ShortcutFlags,
474 pub route: Option<ShortcutRoute>,
475}
476
477impl ShortcutOptions {
478 pub const fn new() -> Self {
479 Self {
480 flags: ShortcutFlags::NONE,
481 route: None,
482 }
483 }
484
485 pub fn flags(mut self, flags: ShortcutFlags) -> Self {
486 self.flags = flags;
487 self
488 }
489
490 pub fn route(mut self, route: ShortcutRoute) -> Self {
491 self.route = Some(route);
492 self
493 }
494
495 pub fn bits(self) -> i32 {
497 self.raw()
498 }
499
500 #[inline]
501 pub(crate) fn raw(self) -> sys::ImGuiInputFlags {
502 self.flags.bits() | self.route.map_or(0, ShortcutRoute::raw)
503 }
504}
505
506impl Default for ShortcutOptions {
507 fn default() -> Self {
508 Self::new()
509 }
510}
511
512impl From<ShortcutFlags> for ShortcutOptions {
513 fn from(flags: ShortcutFlags) -> Self {
514 Self::new().flags(flags)
515 }
516}
517
518impl From<ShortcutRoute> for ShortcutOptions {
519 fn from(route: ShortcutRoute) -> Self {
520 Self::new().route(route)
521 }
522}
523
524pub type InputFlags = ShortcutOptions;
526
527bitflags! {
528 #[repr(transparent)]
530 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
531 pub struct NextItemShortcutFlags: i32 {
532 const NONE = sys::ImGuiInputFlags_None as i32;
533 const TOOLTIP = sys::ImGuiInputFlags_Tooltip as i32;
534 }
535}
536
537#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
539pub struct NextItemShortcutOptions {
540 pub shortcut: ShortcutOptions,
541 pub flags: NextItemShortcutFlags,
542}
543
544impl NextItemShortcutOptions {
545 pub const fn new() -> Self {
546 Self {
547 shortcut: ShortcutOptions::new(),
548 flags: NextItemShortcutFlags::NONE,
549 }
550 }
551
552 pub fn shortcut(mut self, options: impl Into<ShortcutOptions>) -> Self {
553 self.shortcut = options.into();
554 self
555 }
556
557 pub fn flags(mut self, flags: ShortcutFlags) -> Self {
558 self.shortcut.flags = flags;
559 self
560 }
561
562 pub fn route(mut self, route: ShortcutRoute) -> Self {
563 self.shortcut.route = Some(route);
564 self
565 }
566
567 pub fn next_item_flags(mut self, flags: NextItemShortcutFlags) -> Self {
568 self.flags = flags;
569 self
570 }
571
572 pub fn tooltip(mut self, value: bool) -> Self {
573 self.flags.set(NextItemShortcutFlags::TOOLTIP, value);
574 self
575 }
576
577 pub fn bits(self) -> i32 {
579 self.raw()
580 }
581
582 #[inline]
583 pub(crate) fn raw(self) -> sys::ImGuiInputFlags {
584 self.shortcut.raw() | self.flags.bits()
585 }
586}
587
588impl Default for NextItemShortcutOptions {
589 fn default() -> Self {
590 Self::new()
591 }
592}
593
594impl From<ShortcutOptions> for NextItemShortcutOptions {
595 fn from(shortcut: ShortcutOptions) -> Self {
596 Self::new().shortcut(shortcut)
597 }
598}
599
600impl From<ShortcutFlags> for NextItemShortcutOptions {
601 fn from(flags: ShortcutFlags) -> Self {
602 Self::new().flags(flags)
603 }
604}
605
606impl From<ShortcutRoute> for NextItemShortcutOptions {
607 fn from(route: ShortcutRoute) -> Self {
608 Self::new().route(route)
609 }
610}
611
612impl From<NextItemShortcutFlags> for NextItemShortcutOptions {
613 fn from(flags: NextItemShortcutFlags) -> Self {
614 Self::new().next_item_flags(flags)
615 }
616}
617
618bitflags! {
619 #[repr(transparent)]
621 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
622 pub struct ItemKeyOwnerFlags: i32 {
623 const NONE = sys::ImGuiInputFlags_None as i32;
624
625 const LOCK_THIS_FRAME = sys::ImGuiInputFlags_LockThisFrame as i32;
626 const LOCK_UNTIL_RELEASE = sys::ImGuiInputFlags_LockUntilRelease as i32;
627
628 const COND_HOVERED = sys::ImGuiInputFlags_CondHovered as i32;
629 const COND_ACTIVE = sys::ImGuiInputFlags_CondActive as i32;
630 }
631}
632
633impl Default for ItemKeyOwnerFlags {
634 fn default() -> Self {
635 ItemKeyOwnerFlags::NONE
636 }
637}
638
639impl ItemKeyOwnerFlags {
640 #[inline]
641 pub(crate) fn raw(self) -> sys::ImGuiInputFlags {
642 self.bits() as sys::ImGuiInputFlags
643 }
644}
645
646impl Default for NextItemShortcutFlags {
647 fn default() -> Self {
648 NextItemShortcutFlags::NONE
649 }
650}
651
652bitflags! {
653 #[repr(transparent)]
655 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
656 pub struct InputTextFlags: i32 {
657 const NONE = sys::ImGuiInputTextFlags_None as i32;
659 const CHARS_DECIMAL = sys::ImGuiInputTextFlags_CharsDecimal as i32;
661 const CHARS_HEXADECIMAL = sys::ImGuiInputTextFlags_CharsHexadecimal as i32;
663 const CHARS_UPPERCASE = sys::ImGuiInputTextFlags_CharsUppercase as i32;
665 const CHARS_NO_BLANK = sys::ImGuiInputTextFlags_CharsNoBlank as i32;
667 const AUTO_SELECT_ALL = sys::ImGuiInputTextFlags_AutoSelectAll as i32;
669 const ENTER_RETURNS_TRUE = sys::ImGuiInputTextFlags_EnterReturnsTrue as i32;
671 const CALLBACK_COMPLETION = sys::ImGuiInputTextFlags_CallbackCompletion as i32;
673 const CALLBACK_HISTORY = sys::ImGuiInputTextFlags_CallbackHistory as i32;
675 const CALLBACK_ALWAYS = sys::ImGuiInputTextFlags_CallbackAlways as i32;
677 const CALLBACK_CHAR_FILTER = sys::ImGuiInputTextFlags_CallbackCharFilter as i32;
679 const ALLOW_TAB_INPUT = sys::ImGuiInputTextFlags_AllowTabInput as i32;
681 const CTRL_ENTER_FOR_NEW_LINE = sys::ImGuiInputTextFlags_CtrlEnterForNewLine as i32;
683 const NO_HORIZONTAL_SCROLL = sys::ImGuiInputTextFlags_NoHorizontalScroll as i32;
685 const ALWAYS_OVERWRITE = sys::ImGuiInputTextFlags_AlwaysOverwrite as i32;
687 const READ_ONLY = sys::ImGuiInputTextFlags_ReadOnly as i32;
689 const PASSWORD = sys::ImGuiInputTextFlags_Password as i32;
691 const NO_UNDO_REDO = sys::ImGuiInputTextFlags_NoUndoRedo as i32;
693 const CHARS_SCIENTIFIC = sys::ImGuiInputTextFlags_CharsScientific as i32;
695 const CALLBACK_RESIZE = sys::ImGuiInputTextFlags_CallbackResize as i32;
697 const CALLBACK_EDIT = sys::ImGuiInputTextFlags_CallbackEdit as i32;
699 }
700}
701
702impl InputTextFlags {
703 #[inline]
704 pub(crate) fn raw(self) -> sys::ImGuiInputTextFlags {
705 self.bits() as sys::ImGuiInputTextFlags
706 }
707}
708
709#[cfg(feature = "serde")]
710impl Serialize for InputTextFlags {
711 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
712 where
713 S: serde::Serializer,
714 {
715 serializer.serialize_i32(self.bits())
716 }
717}
718
719#[cfg(feature = "serde")]
720impl<'de> Deserialize<'de> for InputTextFlags {
721 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
722 where
723 D: serde::Deserializer<'de>,
724 {
725 let bits = i32::deserialize(deserializer)?;
726 Ok(InputTextFlags::from_bits_truncate(bits))
727 }
728}
729
730impl crate::Ui {
733 #[doc(alias = "IsKeyDown")]
735 pub fn is_key_down(&self, key: Key) -> bool {
736 unsafe { sys::igIsKeyDown_Nil(key as sys::ImGuiKey) }
737 }
738
739 #[doc(alias = "IsKeyPressed")]
741 pub fn is_key_pressed(&self, key: Key) -> bool {
742 unsafe { sys::igIsKeyPressed_Bool(key as sys::ImGuiKey, true) }
743 }
744
745 #[doc(alias = "IsKeyPressed")]
747 pub fn is_key_pressed_with_repeat(&self, key: Key, repeat: bool) -> bool {
748 unsafe { sys::igIsKeyPressed_Bool(key as sys::ImGuiKey, repeat) }
749 }
750
751 #[doc(alias = "IsKeyReleased")]
753 pub fn is_key_released(&self, key: Key) -> bool {
754 unsafe { sys::igIsKeyReleased_Nil(key as sys::ImGuiKey) }
755 }
756
757 #[doc(alias = "IsKeyChordPressed")]
759 pub fn is_key_chord_pressed(&self, key_chord: KeyChord) -> bool {
760 unsafe { sys::igIsKeyChordPressed_Nil(key_chord.raw()) }
761 }
762
763 #[doc(alias = "Shortcut")]
765 pub fn shortcut(&self, key_chord: KeyChord) -> bool {
766 self.shortcut_with_flags(key_chord, ShortcutOptions::new())
767 }
768
769 #[doc(alias = "Shortcut")]
771 pub fn shortcut_with_flags(
772 &self,
773 key_chord: KeyChord,
774 flags: impl Into<ShortcutOptions>,
775 ) -> bool {
776 unsafe { sys::igShortcut_Nil(key_chord.raw(), flags.into().raw()) }
777 }
778
779 #[doc(alias = "SetNextItemShortcut")]
781 pub fn set_next_item_shortcut(&self, key_chord: KeyChord) {
782 self.set_next_item_shortcut_with_flags(key_chord, NextItemShortcutOptions::new());
783 }
784
785 #[doc(alias = "SetNextItemShortcut")]
787 pub fn set_next_item_shortcut_with_flags(
788 &self,
789 key_chord: KeyChord,
790 flags: impl Into<NextItemShortcutOptions>,
791 ) {
792 let flags = flags.into();
793 unsafe { sys::igSetNextItemShortcut(key_chord.raw(), flags.raw()) }
794 }
795
796 #[doc(alias = "SetNextFrameWantCaptureKeyboard")]
798 pub fn set_next_frame_want_capture_keyboard(&self, want_capture_keyboard: bool) {
799 unsafe { sys::igSetNextFrameWantCaptureKeyboard(want_capture_keyboard) }
800 }
801
802 #[doc(alias = "SetNextFrameWantCaptureMouse")]
804 pub fn set_next_frame_want_capture_mouse(&self, want_capture_mouse: bool) {
805 unsafe { sys::igSetNextFrameWantCaptureMouse(want_capture_mouse) }
806 }
807
808 #[doc(alias = "IsMouseDown")]
810 pub fn is_mouse_down(&self, button: MouseButton) -> bool {
811 unsafe { sys::igIsMouseDown_Nil(button.into()) }
812 }
813
814 #[doc(alias = "IsMouseClicked")]
816 pub fn is_mouse_clicked(&self, button: MouseButton) -> bool {
817 unsafe { sys::igIsMouseClicked_Bool(button.into(), false) }
818 }
819
820 #[doc(alias = "IsMouseClicked")]
822 pub fn is_mouse_clicked_with_repeat(&self, button: MouseButton, repeat: bool) -> bool {
823 unsafe { sys::igIsMouseClicked_Bool(button.into(), repeat) }
824 }
825
826 #[doc(alias = "IsMouseReleased")]
828 pub fn is_mouse_released(&self, button: MouseButton) -> bool {
829 unsafe { sys::igIsMouseReleased_Nil(button.into()) }
830 }
831
832 #[doc(alias = "IsMouseDoubleClicked")]
834 pub fn is_mouse_double_clicked(&self, button: MouseButton) -> bool {
835 unsafe { sys::igIsMouseDoubleClicked_Nil(button.into()) }
836 }
837
838 #[doc(alias = "IsMousePosValid")]
842 pub fn is_mouse_pos_valid(&self) -> bool {
843 unsafe { sys::igIsMousePosValid(std::ptr::null()) }
844 }
845
846 #[doc(alias = "IsMousePosValid")]
848 pub fn is_mouse_pos_valid_at(&self, pos: [f32; 2]) -> bool {
849 let v = sys::ImVec2_c {
850 x: pos[0],
851 y: pos[1],
852 };
853 unsafe { sys::igIsMousePosValid(&v as *const sys::ImVec2_c) }
854 }
855
856 #[doc(alias = "IsMouseReleasedWithDelay")]
858 pub fn is_mouse_released_with_delay(&self, button: MouseButton, delay: f32) -> bool {
859 unsafe { sys::igIsMouseReleasedWithDelay(button.into(), delay) }
860 }
861
862 #[doc(alias = "GetMousePos")]
864 pub fn mouse_pos(&self) -> [f32; 2] {
865 let pos = unsafe { sys::igGetMousePos() };
866 [pos.x, pos.y]
867 }
868
869 #[doc(alias = "GetMousePosOnOpeningCurrentPopup")]
871 pub fn mouse_pos_on_opening_current_popup(&self) -> [f32; 2] {
872 let pos = unsafe { sys::igGetMousePosOnOpeningCurrentPopup() };
873 [pos.x, pos.y]
874 }
875
876 #[doc(alias = "IsMouseHoveringRect")]
878 pub fn is_mouse_hovering_rect(&self, r_min: [f32; 2], r_max: [f32; 2]) -> bool {
879 unsafe {
880 sys::igIsMouseHoveringRect(
881 sys::ImVec2::new(r_min[0], r_min[1]),
882 sys::ImVec2::new(r_max[0], r_max[1]),
883 true,
884 )
885 }
886 }
887
888 #[doc(alias = "IsMouseHoveringRect")]
890 pub fn is_mouse_hovering_rect_with_clip(
891 &self,
892 r_min: [f32; 2],
893 r_max: [f32; 2],
894 clip: bool,
895 ) -> bool {
896 unsafe {
897 sys::igIsMouseHoveringRect(
898 sys::ImVec2::new(r_min[0], r_min[1]),
899 sys::ImVec2::new(r_max[0], r_max[1]),
900 clip,
901 )
902 }
903 }
904
905 #[doc(alias = "IsMouseDragging")]
907 pub fn is_mouse_dragging(&self, button: MouseButton) -> bool {
908 unsafe { sys::igIsMouseDragging(button as i32, -1.0) }
909 }
910
911 #[doc(alias = "IsMouseDragging")]
913 pub fn is_mouse_dragging_with_threshold(
914 &self,
915 button: MouseButton,
916 lock_threshold: f32,
917 ) -> bool {
918 unsafe { sys::igIsMouseDragging(button as i32, lock_threshold) }
919 }
920
921 #[doc(alias = "GetMouseDragDelta")]
923 pub fn mouse_drag_delta(&self, button: MouseButton) -> [f32; 2] {
924 let delta = unsafe { sys::igGetMouseDragDelta(button as i32, -1.0) };
925 [delta.x, delta.y]
926 }
927
928 #[doc(alias = "GetMouseDragDelta")]
930 pub fn mouse_drag_delta_with_threshold(
931 &self,
932 button: MouseButton,
933 lock_threshold: f32,
934 ) -> [f32; 2] {
935 let delta = unsafe { sys::igGetMouseDragDelta(button as i32, lock_threshold) };
936 [delta.x, delta.y]
937 }
938
939 #[doc(alias = "ResetMouseDragDelta")]
941 pub fn reset_mouse_drag_delta(&self, button: MouseButton) {
942 unsafe { sys::igResetMouseDragDelta(button as i32) }
943 }
944
945 #[doc(alias = "IsItemToggledSelection")]
950 pub fn is_item_toggled_selection(&self) -> bool {
951 unsafe { sys::igIsItemToggledSelection() }
952 }
953}