1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use super::*;
impl Ui {
/// Returns the currently desired mouse cursor type
///
/// Returns `None` if no cursor should be displayed
#[doc(alias = "GetMouseCursor")]
pub fn mouse_cursor(&self) -> Option<MouseCursor> {
unsafe {
match sys::igGetMouseCursor() {
sys::ImGuiMouseCursor_Arrow => Some(MouseCursor::Arrow),
sys::ImGuiMouseCursor_TextInput => Some(MouseCursor::TextInput),
sys::ImGuiMouseCursor_ResizeAll => Some(MouseCursor::ResizeAll),
sys::ImGuiMouseCursor_ResizeNS => Some(MouseCursor::ResizeNS),
sys::ImGuiMouseCursor_ResizeEW => Some(MouseCursor::ResizeEW),
sys::ImGuiMouseCursor_ResizeNESW => Some(MouseCursor::ResizeNESW),
sys::ImGuiMouseCursor_ResizeNWSE => Some(MouseCursor::ResizeNWSE),
sys::ImGuiMouseCursor_Hand => Some(MouseCursor::Hand),
sys::ImGuiMouseCursor_NotAllowed => Some(MouseCursor::NotAllowed),
_ => None,
}
}
}
/// Sets the desired mouse cursor type
///
/// Passing `None` hides the mouse cursor
#[doc(alias = "SetMouseCursor")]
pub fn set_mouse_cursor(&self, cursor_type: Option<MouseCursor>) {
unsafe {
let val: sys::ImGuiMouseCursor = cursor_type
.map(|x| x as sys::ImGuiMouseCursor)
.unwrap_or(sys::ImGuiMouseCursor_None);
sys::igSetMouseCursor(val);
}
}
// ============================================================================
// Focus and Navigation
// ============================================================================
/// Focuses keyboard on the next widget.
///
/// This is the equivalent to [set_keyboard_focus_here_with_offset](Self::set_keyboard_focus_here_with_offset)
/// with `offset` set to 0.
#[doc(alias = "SetKeyboardFocusHere")]
pub fn set_keyboard_focus_here(&self) {
self.set_keyboard_focus_here_with_offset(0);
}
/// Focuses keyboard on a widget relative to current position.
///
/// Use positive offset to focus on next widgets, negative offset to focus on previous widgets.
#[doc(alias = "SetKeyboardFocusHere")]
pub fn set_keyboard_focus_here_with_offset(&self, offset: i32) {
unsafe {
sys::igSetKeyboardFocusHere(offset);
}
}
/// Shows or hides the navigation cursor (a small marker indicating nav focus).
#[doc(alias = "SetNavCursorVisible")]
pub fn set_nav_cursor_visible(&self, visible: bool) {
unsafe { sys::igSetNavCursorVisible(visible) }
}
}