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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#![allow(non_upper_case_globals)]
use bitflags::bitflags;
use std::os::raw::{c_char, c_int};
use crate::render::renderer::TextureId;
use crate::string::ImStr;
use crate::widget::color_editors::*;
use crate::widget::combo_box::*;
use crate::widget::image::{Image, ImageButton};
use crate::widget::menu::*;
use crate::widget::progress_bar::ProgressBar;
use crate::widget::selectable::*;
use crate::window::{Window, WindowFlags, WindowFocusedFlags};
use crate::{Id, Ui};
#[deprecated(since = "0.2.0", note = "use ColorEditFlags instead")]
pub type ImGuiColorEditFlags = ColorEditFlags;
#[deprecated(since = "0.2.0", note = "use ComboFlags instead")]
pub type ImGuiComboFlags = ComboBoxFlags;
bitflags!(
#[repr(C)]
pub struct ImGuiDragDropFlags: c_int {
const SourceNoPreviewTooltip = 1;
const SourceNoDisableHover = 1 << 1;
const SourceNoHoldToOpenOthers = 1 << 2;
const SourceAllowNullID = 1 << 3;
const SourceExtern = 1 << 4;
const SourceAutoExpirePayload = 1 << 5;
const AcceptBeforeDelivery = 1 << 10;
const AcceptNoDrawDefaultRect = 1 << 11;
const AcceptNoPreviewTooltip = 1 << 12;
const AcceptPeekOnly = ImGuiDragDropFlags::AcceptBeforeDelivery.bits
| ImGuiDragDropFlags::AcceptNoDrawDefaultRect.bits;
}
);
bitflags!(
#[repr(C)]
pub struct ImDrawCornerFlags: c_int {
const TopLeft = 1;
const TopRight = 1 << 1;
const BotLeft = 1 << 2;
const BotRight = 1 << 3;
const Top = ImDrawCornerFlags::TopLeft.bits
| ImDrawCornerFlags::TopRight.bits;
const Bot = ImDrawCornerFlags::BotLeft.bits
| ImDrawCornerFlags::BotRight.bits;
const Left = ImDrawCornerFlags::TopLeft.bits
| ImDrawCornerFlags::BotLeft.bits;
const Right = ImDrawCornerFlags::TopRight.bits
| ImDrawCornerFlags::BotRight.bits;
const All = 0xF;
}
);
bitflags!(
#[repr(C)]
pub struct ImDrawListFlags: c_int {
const AntiAliasedLines = 1;
const AntiAliasedFill = 1 << 1;
}
);
bitflags!(
#[repr(C)]
pub struct ImGuiInputTextFlags: c_int {
const CharsDecimal = 1;
const CharsHexadecimal = 1 << 1;
const CharsUppercase = 1 << 2;
const CharsNoBlank = 1 << 3;
const AutoSelectAll = 1 << 4;
const EnterReturnsTrue = 1 << 5;
const CallbackCompletion = 1 << 6;
const CallbackHistory = 1 << 7;
const CallbackAlways = 1 << 8;
const CallbackCharFilter = 1 << 9;
const AllowTabInput = 1 << 10;
const CtrlEnterForNewLine = 1 << 11;
const NoHorizontalScroll = 1 << 12;
const AlwaysInsertMode = 1 << 13;
const ReadOnly = 1 << 14;
const Password = 1 << 15;
const NoUndoRedo = 1 << 16;
const CharsScientific = 1 << 17;
const CallbackResize = 1 << 18;
}
);
#[deprecated(since = "0.2.0", note = "use SelectableFlags instead")]
pub type ImGuiSelectableFlags = SelectableFlags;
bitflags!(
#[repr(C)]
pub struct ImGuiTreeNodeFlags: c_int {
const Selected = 1;
const Framed = 1 << 1;
const AllowItemOverlap = 1 << 2;
const NoTreePushOnOpen = 1 << 3;
const NoAutoOpenOnLog = 1 << 4;
const DefaultOpen = 1 << 5;
const OpenOnDoubleClick = 1 << 6;
const OpenOnArrow = 1 << 7;
const Leaf = 1 << 8;
const Bullet = 1 << 9;
const FramePadding = 1 << 10;
const NavLeftJumpsBackHere = 1 << 13;
const CollapsingHeader =
ImGuiTreeNodeFlags::Framed.bits | ImGuiTreeNodeFlags::NoTreePushOnOpen.bits |
ImGuiTreeNodeFlags::NoAutoOpenOnLog.bits;
}
);
#[deprecated(since = "0.2.0", note = "use WindowFlags instead")]
pub type ImGuiWindowFlags = WindowFlags;
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use imgui::Window::new(...) instead")]
pub fn window<'p>(&self, name: &'p ImStr) -> Window<'p> {
Window::new(name)
}
#[deprecated(since = "0.2.0", note = "use Ui::window_size instead")]
pub fn get_window_size(&self) -> [f32; 2] {
let size = unsafe { sys::igGetWindowSize_nonUDT2() };
size.into()
}
#[deprecated(since = "0.2.0", note = "use Ui::window_pos instead")]
pub fn get_window_pos(&self) -> [f32; 2] {
let size = unsafe { sys::igGetWindowPos_nonUDT2() };
size.into()
}
#[deprecated(since = "0.2.0", note = "use Ui::content_region_max instead")]
pub fn get_content_region_max(&self) -> [f32; 2] {
let size = unsafe { sys::igGetContentRegionMax_nonUDT2() };
size.into()
}
#[deprecated(since = "0.2.0", note = "use Ui::content_region_avail instead")]
pub fn get_content_region_avail(&self) -> [f32; 2] {
let size = unsafe { sys::igGetContentRegionAvail_nonUDT2() };
size.into()
}
#[deprecated(since = "0.2.0", note = "use Ui::window_content_region_min instead")]
pub fn get_window_content_region_min(&self) -> [f32; 2] {
let size = unsafe { sys::igGetWindowContentRegionMin_nonUDT2() };
size.into()
}
#[deprecated(since = "0.2.0", note = "use Ui::window_content_region_max instead")]
pub fn get_window_content_region_max(&self) -> [f32; 2] {
let size = unsafe { sys::igGetWindowContentRegionMax_nonUDT2() };
size.into()
}
#[deprecated(
since = "0.2.0",
note = "use Ui::is_window_focused(WindowFlags::RootWindow) instead"
)]
pub fn is_root_window_focused(&self) -> bool {
unsafe { sys::igIsWindowFocused(WindowFocusedFlags::ROOT_WINDOW.bits() as i32) }
}
#[deprecated(
since = "0.2.0",
note = "use Ui::is_window_focused(WindowFlags::ChildWindows) instead"
)]
pub fn is_child_window_focused(&self) -> bool {
unsafe { sys::igIsWindowFocused(WindowFocusedFlags::CHILD_WINDOWS.bits() as i32) }
}
}
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use imgui::ProgressBar::new(...) instead")]
pub fn progress_bar<'p>(&self, fraction: f32) -> ProgressBar<'p> {
ProgressBar::new(fraction)
}
}
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use imgui::ColorEdit::new(...) instead")]
pub fn color_edit<'p, V: Into<EditableColor<'p>>>(
&self,
label: &'p ImStr,
value: V,
) -> ColorEdit<'p> {
ColorEdit::new(label, value.into())
}
#[deprecated(since = "0.2.0", note = "use imgui::ColorPicker::new(...) instead")]
pub fn color_picker<'p, V: Into<EditableColor<'p>>>(
&self,
label: &'p ImStr,
value: V,
) -> ColorPicker<'p> {
ColorPicker::new(label, value.into())
}
#[deprecated(since = "0.2.0", note = "use imgui::ColorButton::new(...) instead")]
pub fn color_button<'p>(&self, desc_id: &'p ImStr, color: [f32; 4]) -> ColorButton<'p> {
ColorButton::new(desc_id, color.into())
}
}
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use Ui::cursor_screen_pos instead")]
pub fn get_cursor_screen_pos(&self) -> [f32; 2] {
let size = unsafe { sys::igGetCursorScreenPos_nonUDT2() };
size.into()
}
#[deprecated(since = "0.2.0", note = "use Ui::cursor_pos instead")]
pub fn get_cursor_pos(&self) -> [f32; 2] {
let size = unsafe { sys::igGetCursorPos_nonUDT2() };
size.into()
}
#[deprecated(
since = "0.2.0",
note = "use Ui::text_line_height_with_spacing instead"
)]
pub fn get_text_line_height_with_spacing(&self) -> f32 {
unsafe { sys::igGetTextLineHeightWithSpacing() }
}
}
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use Ui::current_column_index instead")]
pub fn get_column_index(&self) -> i32 {
unsafe { sys::igGetColumnIndex() }
}
#[deprecated(since = "0.2.0", note = "use Ui::column_offset instead")]
pub fn get_column_offset(&self, column_index: i32) -> f32 {
unsafe { sys::igGetColumnOffset(column_index) }
}
#[deprecated(since = "0.2.0", note = "use Ui::column_width instead")]
pub fn get_column_width(&self, column_index: i32) -> f32 {
unsafe { sys::igGetColumnWidth(column_index) }
}
#[deprecated(since = "0.2.0", note = "use Ui::column_count instead")]
pub fn get_columns_count(&self) -> i32 {
unsafe { sys::igGetColumnsCount() }
}
}
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use Ui::push_id instead")]
pub fn with_id<'a, F, I>(&self, id: I, f: F)
where
F: FnOnce(),
I: Into<Id<'a>>,
{
let _token = self.push_id(id);
f();
}
}
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use Ui::item_rect_size instead")]
pub fn get_item_rect_size(&self) -> [f32; 2] {
let size = unsafe { sys::igGetItemRectSize_nonUDT2() };
size.into()
}
}
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use imgui::Image::new(...) instead")]
pub fn image(&self, texture: TextureId, size: [f32; 2]) -> Image {
Image::new(texture, size)
}
#[deprecated(since = "0.2.0", note = "use imgui::ImageButton::new(...) instead")]
pub fn image_button(&self, texture: TextureId, size: [f32; 2]) -> ImageButton {
ImageButton::new(texture, size)
}
}
impl<'ui> Ui<'ui> {
#[deprecated(
since = "0.2.0",
note = "use imgui::ComboBox::new(...), and either build_simple(), build_simple_string(), or custom rendering (e.g. selectables) instead"
)]
pub fn combo<'p, StringType: AsRef<ImStr> + ?Sized>(
&self,
label: &'p ImStr,
current_item: &mut i32,
items: &'p [&'p StringType],
height_in_items: i32,
) -> bool {
let items_inner: Vec<*const c_char> = items
.into_iter()
.map(|item| item.as_ref().as_ptr())
.collect();
unsafe {
sys::igCombo(
label.as_ptr(),
current_item,
items_inner.as_ptr() as *mut *const c_char,
items_inner.len() as i32,
height_in_items,
)
}
}
}
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use imgui::Selectable::new(...) instead")]
pub fn selectable(
&self,
label: &ImStr,
selected: bool,
flags: SelectableFlags,
size: [f32; 2],
) -> bool {
unsafe { sys::igSelectable(label.as_ptr(), selected, flags.bits() as i32, size.into()) }
}
}
impl<'ui> Ui<'ui> {
#[deprecated(since = "0.2.0", note = "use imgui::MenuItem::new(...) instead")]
pub fn menu_item<'a>(&self, label: &'a ImStr) -> MenuItem<'a> {
MenuItem::new(label)
}
}