dear_imgui_rs/widget/drag/
ui.rs1use std::ptr;
2
3use crate::Ui;
4use crate::internal::DataTypeKind;
5use crate::sys;
6
7use super::Drag;
8
9impl Ui {
10 pub fn drag<T: AsRef<str>, K: DataTypeKind>(&self, label: T, value: &mut K) -> bool {
12 Drag::new(label).build(self, value)
13 }
14
15 pub fn drag_config<T: AsRef<str>, K: DataTypeKind>(&self, label: T) -> Drag<K, T> {
17 Drag::new(label)
18 }
19
20 #[doc(alias = "DragFloat2")]
22 pub fn drag_float2(&self, label: impl AsRef<str>, values: &mut [f32; 2]) -> bool {
23 unsafe {
24 let label_cstr = self.scratch_txt(label);
25 sys::igDragFloat2(
26 label_cstr,
27 values.as_mut_ptr(),
28 1.0,
29 0.0,
30 0.0,
31 ptr::null(),
32 0,
33 )
34 }
35 }
36
37 #[doc(alias = "DragFloat3")]
39 pub fn drag_float3(&self, label: impl AsRef<str>, values: &mut [f32; 3]) -> bool {
40 unsafe {
41 let label_cstr = self.scratch_txt(label);
42 sys::igDragFloat3(
43 label_cstr,
44 values.as_mut_ptr(),
45 1.0,
46 0.0,
47 0.0,
48 ptr::null(),
49 0,
50 )
51 }
52 }
53
54 #[doc(alias = "DragFloat4")]
56 pub fn drag_float4(&self, label: impl AsRef<str>, values: &mut [f32; 4]) -> bool {
57 unsafe {
58 let label_cstr = self.scratch_txt(label);
59 sys::igDragFloat4(
60 label_cstr,
61 values.as_mut_ptr(),
62 1.0,
63 0.0,
64 0.0,
65 ptr::null(),
66 0,
67 )
68 }
69 }
70
71 #[doc(alias = "DragInt2")]
73 pub fn drag_int2(&self, label: impl AsRef<str>, values: &mut [i32; 2]) -> bool {
74 unsafe {
75 let label_cstr = self.scratch_txt(label);
76 sys::igDragInt2(label_cstr, values.as_mut_ptr(), 1.0, 0, 0, ptr::null(), 0)
77 }
78 }
79
80 #[doc(alias = "DragInt3")]
82 pub fn drag_int3(&self, label: impl AsRef<str>, values: &mut [i32; 3]) -> bool {
83 unsafe {
84 let label_cstr = self.scratch_txt(label);
85 sys::igDragInt3(label_cstr, values.as_mut_ptr(), 1.0, 0, 0, ptr::null(), 0)
86 }
87 }
88
89 #[doc(alias = "DragInt4")]
91 pub fn drag_int4(&self, label: impl AsRef<str>, values: &mut [i32; 4]) -> bool {
92 unsafe {
93 let label_cstr = self.scratch_txt(label);
94 sys::igDragInt4(label_cstr, values.as_mut_ptr(), 1.0, 0, 0, ptr::null(), 0)
95 }
96 }
97}