dear_imgui_rs/widget/input/
entry.rs1use super::multiline::{InputTextMultiline, InputTextMultilineImStr};
2use super::numeric::{
3 InputDouble, InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt, InputInt2, InputInt3,
4 InputInt4, InputScalar, InputScalarN,
5};
6use super::single_line::{InputText, InputTextImStr};
7use crate::internal::DataTypeKind;
8use crate::string::ImString;
9use crate::ui::Ui;
10use std::borrow::Cow;
11
12impl Ui {
14 #[doc(alias = "InputText", alias = "InputTextWithHint")]
28 pub fn input_text<'ui, 'p>(
29 &'ui self,
30 label: impl Into<Cow<'ui, str>>,
31 buf: &'p mut String,
32 ) -> InputText<'ui, 'p> {
33 InputText::new(self, label, buf)
34 }
35
36 pub fn input_text_imstr<'ui, 'p>(
38 &'ui self,
39 label: impl Into<Cow<'ui, str>>,
40 buf: &'p mut ImString,
41 ) -> InputTextImStr<'ui, 'p> {
42 InputTextImStr::new(self, label, buf)
43 }
44
45 #[doc(alias = "InputTextMultiline")]
59 pub fn input_text_multiline<'ui, 'p>(
60 &'ui self,
61 label: impl Into<Cow<'ui, str>>,
62 buf: &'p mut String,
63 size: impl Into<[f32; 2]>,
64 ) -> InputTextMultiline<'ui, 'p> {
65 InputTextMultiline::new(self, label, buf, size)
66 }
67
68 pub fn input_text_multiline_imstr<'ui, 'p>(
70 &'ui self,
71 label: impl Into<Cow<'ui, str>>,
72 buf: &'p mut ImString,
73 size: impl Into<[f32; 2]>,
74 ) -> InputTextMultilineImStr<'ui, 'p> {
75 InputTextMultilineImStr::new(self, label, buf, size)
76 }
77
78 #[doc(alias = "InputInt")]
82 pub fn input_int(&self, label: impl AsRef<str>, value: &mut i32) -> bool {
83 self.input_int_config(label.as_ref()).build(value)
84 }
85
86 #[doc(alias = "InputFloat")]
90 pub fn input_float(&self, label: impl AsRef<str>, value: &mut f32) -> bool {
91 self.input_float_config(label.as_ref()).build(value)
92 }
93
94 #[doc(alias = "InputDouble")]
98 pub fn input_double(&self, label: impl AsRef<str>, value: &mut f64) -> bool {
99 self.input_double_config(label.as_ref()).build(value)
100 }
101
102 pub fn input_int_config<'ui>(&'ui self, label: impl Into<Cow<'ui, str>>) -> InputInt<'ui> {
104 InputInt::new(self, label)
105 }
106
107 pub fn input_float_config<'ui>(&'ui self, label: impl Into<Cow<'ui, str>>) -> InputFloat<'ui> {
109 InputFloat::new(self, label)
110 }
111
112 pub fn input_double_config<'ui>(
114 &'ui self,
115 label: impl Into<Cow<'ui, str>>,
116 ) -> InputDouble<'ui> {
117 InputDouble::new(self, label)
118 }
119
120 #[doc(alias = "InputScalar")]
123 pub fn input_scalar<'p, L, T>(&self, label: L, value: &'p mut T) -> InputScalar<'_, 'p, T, L>
124 where
125 L: AsRef<str>,
126 T: DataTypeKind,
127 {
128 InputScalar::new(self, label, value)
129 }
130
131 #[doc(alias = "InputScalarN")]
135 pub fn input_scalar_n<'p, L, T>(
136 &self,
137 label: L,
138 values: &'p mut [T],
139 ) -> InputScalarN<'_, 'p, T, L>
140 where
141 L: AsRef<str>,
142 T: DataTypeKind,
143 {
144 InputScalarN::new(self, label, values)
145 }
146
147 #[doc(alias = "InputFloat2")]
149 pub fn input_float2<'p, L>(&self, label: L, value: &'p mut [f32; 2]) -> InputFloat2<'_, 'p, L>
150 where
151 L: AsRef<str>,
152 {
153 InputFloat2::new(self, label, value)
154 }
155
156 #[doc(alias = "InputFloat3")]
158 pub fn input_float3<'p, L>(&self, label: L, value: &'p mut [f32; 3]) -> InputFloat3<'_, 'p, L>
159 where
160 L: AsRef<str>,
161 {
162 InputFloat3::new(self, label, value)
163 }
164
165 #[doc(alias = "InputFloat4")]
167 pub fn input_float4<'p, L>(&self, label: L, value: &'p mut [f32; 4]) -> InputFloat4<'_, 'p, L>
168 where
169 L: AsRef<str>,
170 {
171 InputFloat4::new(self, label, value)
172 }
173
174 #[doc(alias = "InputInt2")]
176 pub fn input_int2<'p, L>(&self, label: L, value: &'p mut [i32; 2]) -> InputInt2<'_, 'p, L>
177 where
178 L: AsRef<str>,
179 {
180 InputInt2::new(self, label, value)
181 }
182
183 #[doc(alias = "InputInt3")]
185 pub fn input_int3<'p, L>(&self, label: L, value: &'p mut [i32; 3]) -> InputInt3<'_, 'p, L>
186 where
187 L: AsRef<str>,
188 {
189 InputInt3::new(self, label, value)
190 }
191
192 #[doc(alias = "InputInt4")]
194 pub fn input_int4<'p, L>(&self, label: L, value: &'p mut [i32; 4]) -> InputInt4<'_, 'p, L>
195 where
196 L: AsRef<str>,
197 {
198 InputInt4::new(self, label, value)
199 }
200}