dear_imgui_rs/ui/
navigation.rs1use super::*;
2
3impl Ui {
4 #[doc(alias = "GetMouseCursor")]
8 pub fn mouse_cursor(&self) -> Option<MouseCursor> {
9 unsafe {
10 match sys::igGetMouseCursor() {
11 sys::ImGuiMouseCursor_Arrow => Some(MouseCursor::Arrow),
12 sys::ImGuiMouseCursor_TextInput => Some(MouseCursor::TextInput),
13 sys::ImGuiMouseCursor_ResizeAll => Some(MouseCursor::ResizeAll),
14 sys::ImGuiMouseCursor_ResizeNS => Some(MouseCursor::ResizeNS),
15 sys::ImGuiMouseCursor_ResizeEW => Some(MouseCursor::ResizeEW),
16 sys::ImGuiMouseCursor_ResizeNESW => Some(MouseCursor::ResizeNESW),
17 sys::ImGuiMouseCursor_ResizeNWSE => Some(MouseCursor::ResizeNWSE),
18 sys::ImGuiMouseCursor_Hand => Some(MouseCursor::Hand),
19 sys::ImGuiMouseCursor_NotAllowed => Some(MouseCursor::NotAllowed),
20 _ => None,
21 }
22 }
23 }
24
25 #[doc(alias = "SetMouseCursor")]
29 pub fn set_mouse_cursor(&self, cursor_type: Option<MouseCursor>) {
30 self.run_with_bound_context(|| unsafe {
31 let val: sys::ImGuiMouseCursor = cursor_type
32 .map(|x| x as sys::ImGuiMouseCursor)
33 .unwrap_or(sys::ImGuiMouseCursor_None);
34 sys::igSetMouseCursor(val);
35 });
36 }
37
38 pub fn set_mouse_draw_cursor(&self, draw: bool) {
43 self.run_with_bound_context(|| unsafe {
44 let io = sys::igGetIO_Nil();
45 assert!(
46 !io.is_null(),
47 "Ui::set_mouse_draw_cursor() requires an active ImGui context"
48 );
49 (*io).MouseDrawCursor = draw;
50 });
51 }
52
53 #[doc(alias = "SetKeyboardFocusHere")]
62 pub fn set_keyboard_focus_here(&self) {
63 self.set_keyboard_focus_here_with_offset(0);
64 }
65
66 #[doc(alias = "SetKeyboardFocusHere")]
70 pub fn set_keyboard_focus_here_with_offset(&self, offset: i32) {
71 unsafe {
72 sys::igSetKeyboardFocusHere(offset);
73 }
74 }
75
76 #[doc(alias = "SetNavCursorVisible")]
78 pub fn set_nav_cursor_visible(&self, visible: bool) {
79 self.run_with_bound_context(|| unsafe { sys::igSetNavCursorVisible(visible) });
80 }
81}