dear_imgui_rs/utils/
item.rs1use crate::input::MouseButton;
2use crate::sys;
3use crate::utils::non_negative_count_from_i32;
4
5impl crate::ui::Ui {
6 #[doc(alias = "GetItemClickedCountWithSingleClickDelay")]
10 pub fn item_clicked_count_with_single_click_delay(&self) -> usize {
11 self.item_clicked_count_with_single_click_delay_for(MouseButton::Left)
12 }
13
14 #[doc(alias = "GetItemClickedCountWithSingleClickDelay")]
16 pub fn item_clicked_count_with_single_click_delay_for(&self, button: MouseButton) -> usize {
17 non_negative_count_from_i32(
18 "Ui::item_clicked_count_with_single_click_delay_for()",
19 self.run_with_bound_context(|| unsafe {
20 sys::igGetItemClickedCountWithSingleClickDelay(button.into(), -1.0)
21 }),
22 )
23 }
24
25 #[doc(alias = "GetItemClickedCountWithSingleClickDelay")]
29 pub fn item_clicked_count_with_delay(&self, button: MouseButton, delay: f32) -> usize {
30 assert!(
31 delay.is_finite() && delay >= 0.0,
32 "Ui::item_clicked_count_with_delay() delay must be finite and non-negative"
33 );
34 non_negative_count_from_i32(
35 "Ui::item_clicked_count_with_delay()",
36 self.run_with_bound_context(|| unsafe {
37 sys::igGetItemClickedCountWithSingleClickDelay(button.into(), delay)
38 }),
39 )
40 }
41
42 #[doc(alias = "IsItemToggledOpen")]
44 pub fn is_item_toggled_open(&self) -> bool {
45 self.run_with_bound_context(|| unsafe { sys::igIsItemToggledOpen() })
46 }
47
48 #[doc(alias = "GetItemRectMin")]
50 pub fn item_rect_min(&self) -> [f32; 2] {
51 let rect = self.run_with_bound_context(|| unsafe { sys::igGetItemRectMin() });
52 [rect.x, rect.y]
53 }
54
55 #[doc(alias = "GetItemRectMax")]
57 pub fn item_rect_max(&self) -> [f32; 2] {
58 let rect = self.run_with_bound_context(|| unsafe { sys::igGetItemRectMax() });
59 [rect.x, rect.y]
60 }
61
62 #[doc(alias = "SetNextItemAllowOverlap")]
64 pub fn set_next_item_allow_overlap(&self) {
65 self.run_with_bound_context(|| unsafe { sys::igSetNextItemAllowOverlap() });
66 }
67}