1#![allow(
19 clippy::cast_possible_truncation,
20 clippy::cast_sign_loss,
21 clippy::as_conversions
22)]
23use bitflags::bitflags;
24
25use crate::sys;
26#[cfg(feature = "serde")]
27use serde::{Deserialize, Serialize};
28use std::ffi::{CStr, c_void};
29
30#[cfg(feature = "serde")]
31impl Serialize for ConfigFlags {
32 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
33 where
34 S: serde::Serializer,
35 {
36 serializer.serialize_i32(self.bits())
37 }
38}
39
40#[cfg(feature = "serde")]
41impl<'de> Deserialize<'de> for ConfigFlags {
42 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
43 where
44 D: serde::Deserializer<'de>,
45 {
46 let bits = i32::deserialize(deserializer)?;
47 Ok(ConfigFlags::from_bits_truncate(bits))
48 }
49}
50
51#[cfg(feature = "serde")]
52impl Serialize for BackendFlags {
53 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
54 where
55 S: serde::Serializer,
56 {
57 serializer.serialize_i32(self.bits())
58 }
59}
60
61#[cfg(feature = "serde")]
62impl<'de> Deserialize<'de> for BackendFlags {
63 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
64 where
65 D: serde::Deserializer<'de>,
66 {
67 let bits = i32::deserialize(deserializer)?;
68 Ok(BackendFlags::from_bits_truncate(bits))
69 }
70}
71
72#[cfg(all(feature = "serde", feature = "multi-viewport"))]
73impl Serialize for ViewportFlags {
74 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
75 where
76 S: serde::Serializer,
77 {
78 serializer.serialize_i32(self.bits())
79 }
80}
81
82#[cfg(all(feature = "serde", feature = "multi-viewport"))]
83impl<'de> Deserialize<'de> for ViewportFlags {
84 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
85 where
86 D: serde::Deserializer<'de>,
87 {
88 let bits = i32::deserialize(deserializer)?;
89 Ok(ViewportFlags::from_bits_truncate(bits))
90 }
91}
92
93bitflags! {
94 #[repr(transparent)]
96 pub struct ConfigFlags: i32 {
97 const NAV_ENABLE_KEYBOARD = sys::ImGuiConfigFlags_NavEnableKeyboard as i32;
99 const NAV_ENABLE_GAMEPAD = sys::ImGuiConfigFlags_NavEnableGamepad as i32;
101 const NO_MOUSE = sys::ImGuiConfigFlags_NoMouse as i32;
103 const NO_MOUSE_CURSOR_CHANGE = sys::ImGuiConfigFlags_NoMouseCursorChange as i32;
105 const IS_SRGB = sys::ImGuiConfigFlags_IsSRGB as i32;
107 const IS_TOUCH_SCREEN = sys::ImGuiConfigFlags_IsTouchScreen as i32;
109
110 const DOCKING_ENABLE = sys::ImGuiConfigFlags_DockingEnable as i32;
111
112 const VIEWPORTS_ENABLE = sys::ImGuiConfigFlags_ViewportsEnable as i32;
113 }
114}
115
116bitflags! {
117 #[repr(transparent)]
119 pub struct BackendFlags: i32 {
120 const HAS_GAMEPAD = sys::ImGuiBackendFlags_HasGamepad as i32;
122 const HAS_MOUSE_CURSORS = sys::ImGuiBackendFlags_HasMouseCursors as i32;
124 const HAS_SET_MOUSE_POS = sys::ImGuiBackendFlags_HasSetMousePos as i32;
126 const HAS_MOUSE_HOVERED_VIEWPORT =
128 sys::ImGuiBackendFlags_HasMouseHoveredViewport as i32;
129 const RENDERER_HAS_VTX_OFFSET = sys::ImGuiBackendFlags_RendererHasVtxOffset as i32;
131 const RENDERER_HAS_TEXTURES = sys::ImGuiBackendFlags_RendererHasTextures as i32;
133
134 #[cfg(feature = "multi-viewport")]
135 const PLATFORM_HAS_VIEWPORTS = sys::ImGuiBackendFlags_PlatformHasViewports as i32;
137 #[cfg(feature = "multi-viewport")]
138 const RENDERER_HAS_VIEWPORTS = sys::ImGuiBackendFlags_RendererHasViewports as i32;
140 }
141}
142
143#[cfg(feature = "multi-viewport")]
144bitflags! {
145 #[repr(transparent)]
147 pub struct ViewportFlags: i32 {
148 const NONE = 0;
150 const IS_PLATFORM_WINDOW = sys::ImGuiViewportFlags_IsPlatformWindow as i32;
152 const IS_PLATFORM_MONITOR = sys::ImGuiViewportFlags_IsPlatformMonitor as i32;
154 const OWNED_BY_APP = sys::ImGuiViewportFlags_OwnedByApp as i32;
156 const NO_DECORATION = sys::ImGuiViewportFlags_NoDecoration as i32;
158 const NO_TASK_BAR_ICON = sys::ImGuiViewportFlags_NoTaskBarIcon as i32;
160 const NO_FOCUS_ON_APPEARING = sys::ImGuiViewportFlags_NoFocusOnAppearing as i32;
162 const NO_FOCUS_ON_CLICK = sys::ImGuiViewportFlags_NoFocusOnClick as i32;
164 const NO_INPUTS = sys::ImGuiViewportFlags_NoInputs as i32;
166 const NO_RENDERER_CLEAR = sys::ImGuiViewportFlags_NoRendererClear as i32;
168 const NO_AUTO_MERGE = sys::ImGuiViewportFlags_NoAutoMerge as i32;
170 const TOP_MOST = sys::ImGuiViewportFlags_TopMost as i32;
172 const CAN_HOST_OTHER_WINDOWS = sys::ImGuiViewportFlags_CanHostOtherWindows as i32;
174 const IS_MINIMIZED = sys::ImGuiViewportFlags_IsMinimized as i32;
176 const IS_FOCUSED = sys::ImGuiViewportFlags_IsFocused as i32;
178 }
179}
180
181#[repr(transparent)]
184pub struct Io(sys::ImGuiIO);
185
186impl Io {
187 pub(crate) fn from_raw() -> &'static mut Self {
189 unsafe {
190 let io_ptr = sys::igGetIO_Nil();
193 &mut *(io_ptr as *mut Self)
194 }
195 }
196
197 pub fn display_size(&self) -> [f32; 2] {
199 [self.0.DisplaySize.x, self.0.DisplaySize.y]
200 }
201
202 pub fn set_display_size(&mut self, size: [f32; 2]) {
204 self.0.DisplaySize.x = size[0];
205 self.0.DisplaySize.y = size[1];
206 }
207
208 pub fn delta_time(&self) -> f32 {
210 self.0.DeltaTime
211 }
212
213 pub fn set_delta_time(&mut self, delta_time: f32) {
215 self.0.DeltaTime = delta_time;
216 }
217
218 #[doc(alias = "IniSavingRate")]
220 pub fn ini_saving_rate(&self) -> f32 {
221 self.0.IniSavingRate
222 }
223
224 #[doc(alias = "IniSavingRate")]
226 pub fn set_ini_saving_rate(&mut self, seconds: f32) {
227 self.0.IniSavingRate = seconds;
228 }
229
230 #[doc(alias = "IniFilename")]
234 pub fn ini_filename(&self) -> Option<&CStr> {
235 let ptr = self.0.IniFilename;
236 unsafe { (!ptr.is_null()).then(|| CStr::from_ptr(ptr)) }
237 }
238
239 #[doc(alias = "LogFilename")]
243 pub fn log_filename(&self) -> Option<&CStr> {
244 let ptr = self.0.LogFilename;
245 unsafe { (!ptr.is_null()).then(|| CStr::from_ptr(ptr)) }
246 }
247
248 #[doc(alias = "UserData")]
250 pub fn user_data(&self) -> *mut c_void {
251 self.0.UserData
252 }
253
254 #[doc(alias = "UserData")]
256 pub fn set_user_data(&mut self, user_data: *mut c_void) {
257 self.0.UserData = user_data;
258 }
259
260 #[doc(alias = "FontAllowUserScaling")]
262 pub fn font_allow_user_scaling(&self) -> bool {
263 self.0.FontAllowUserScaling
264 }
265
266 #[doc(alias = "FontAllowUserScaling")]
268 pub fn set_font_allow_user_scaling(&mut self, enabled: bool) {
269 self.0.FontAllowUserScaling = enabled;
270 }
271
272 pub fn mouse_pos(&self) -> [f32; 2] {
274 [self.0.MousePos.x, self.0.MousePos.y]
275 }
276
277 pub fn set_mouse_pos(&mut self, pos: [f32; 2]) {
279 self.0.MousePos.x = pos[0];
280 self.0.MousePos.y = pos[1];
281 }
282
283 pub fn mouse_wheel(&self) -> f32 {
285 self.0.MouseWheel
286 }
287
288 pub fn set_mouse_wheel(&mut self, wheel: f32) {
290 self.0.MouseWheel = wheel;
291 }
292
293 pub fn mouse_wheel_h(&self) -> f32 {
295 self.0.MouseWheelH
296 }
297
298 pub fn set_mouse_wheel_h(&mut self, wheel_h: f32) {
300 self.0.MouseWheelH = wheel_h;
301 }
302
303 pub fn mouse_down(&self, button: usize) -> bool {
305 if button < 5 {
306 self.0.MouseDown[button]
307 } else {
308 false
309 }
310 }
311
312 pub fn set_mouse_down(&mut self, button: usize, down: bool) {
314 if button < 5 {
315 self.0.MouseDown[button] = down;
316 }
317 }
318
319 pub fn want_capture_mouse(&self) -> bool {
321 self.0.WantCaptureMouse
322 }
323
324 #[doc(alias = "WantCaptureMouseUnlessPopupClose")]
326 pub fn want_capture_mouse_unless_popup_close(&self) -> bool {
327 self.0.WantCaptureMouseUnlessPopupClose
328 }
329
330 pub fn want_capture_keyboard(&self) -> bool {
332 self.0.WantCaptureKeyboard
333 }
334
335 pub fn want_text_input(&self) -> bool {
337 self.0.WantTextInput
338 }
339
340 pub fn want_set_mouse_pos(&self) -> bool {
342 self.0.WantSetMousePos
343 }
344 pub fn mouse_draw_cursor(&self) -> bool {
346 self.0.MouseDrawCursor
347 }
348 pub fn set_mouse_draw_cursor(&mut self, draw: bool) {
350 self.0.MouseDrawCursor = draw;
351 }
352
353 pub fn want_save_ini_settings(&self) -> bool {
355 self.0.WantSaveIniSettings
356 }
357
358 pub fn framerate(&self) -> f32 {
360 self.0.Framerate
361 }
362
363 pub fn metrics_render_vertices(&self) -> i32 {
365 self.0.MetricsRenderVertices
366 }
367
368 pub fn metrics_render_indices(&self) -> i32 {
370 self.0.MetricsRenderIndices
371 }
372
373 pub fn metrics_render_windows(&self) -> i32 {
375 self.0.MetricsRenderWindows
376 }
377
378 pub fn metrics_active_windows(&self) -> i32 {
380 self.0.MetricsActiveWindows
381 }
382
383 pub fn config_flags(&self) -> ConfigFlags {
385 ConfigFlags::from_bits_truncate(self.0.ConfigFlags)
386 }
387
388 pub fn set_config_flags(&mut self, flags: ConfigFlags) {
390 self.0.ConfigFlags = flags.bits();
391 }
392
393 #[doc(alias = "ConfigNavSwapGamepadButtons")]
395 pub fn config_nav_swap_gamepad_buttons(&self) -> bool {
396 self.0.ConfigNavSwapGamepadButtons
397 }
398
399 #[doc(alias = "ConfigNavSwapGamepadButtons")]
401 pub fn set_config_nav_swap_gamepad_buttons(&mut self, enabled: bool) {
402 self.0.ConfigNavSwapGamepadButtons = enabled;
403 }
404
405 #[doc(alias = "ConfigNavMoveSetMousePos")]
407 pub fn config_nav_move_set_mouse_pos(&self) -> bool {
408 self.0.ConfigNavMoveSetMousePos
409 }
410
411 #[doc(alias = "ConfigNavMoveSetMousePos")]
413 pub fn set_config_nav_move_set_mouse_pos(&mut self, enabled: bool) {
414 self.0.ConfigNavMoveSetMousePos = enabled;
415 }
416
417 #[doc(alias = "ConfigNavCaptureKeyboard")]
419 pub fn config_nav_capture_keyboard(&self) -> bool {
420 self.0.ConfigNavCaptureKeyboard
421 }
422
423 #[doc(alias = "ConfigNavCaptureKeyboard")]
425 pub fn set_config_nav_capture_keyboard(&mut self, enabled: bool) {
426 self.0.ConfigNavCaptureKeyboard = enabled;
427 }
428
429 #[doc(alias = "ConfigNavEscapeClearFocusItem")]
431 pub fn config_nav_escape_clear_focus_item(&self) -> bool {
432 self.0.ConfigNavEscapeClearFocusItem
433 }
434
435 #[doc(alias = "ConfigNavEscapeClearFocusItem")]
437 pub fn set_config_nav_escape_clear_focus_item(&mut self, enabled: bool) {
438 self.0.ConfigNavEscapeClearFocusItem = enabled;
439 }
440
441 #[doc(alias = "ConfigNavEscapeClearFocusWindow")]
443 pub fn config_nav_escape_clear_focus_window(&self) -> bool {
444 self.0.ConfigNavEscapeClearFocusWindow
445 }
446
447 #[doc(alias = "ConfigNavEscapeClearFocusWindow")]
449 pub fn set_config_nav_escape_clear_focus_window(&mut self, enabled: bool) {
450 self.0.ConfigNavEscapeClearFocusWindow = enabled;
451 }
452
453 #[doc(alias = "ConfigNavCursorVisibleAuto")]
455 pub fn config_nav_cursor_visible_auto(&self) -> bool {
456 self.0.ConfigNavCursorVisibleAuto
457 }
458
459 #[doc(alias = "ConfigNavCursorVisibleAuto")]
461 pub fn set_config_nav_cursor_visible_auto(&mut self, enabled: bool) {
462 self.0.ConfigNavCursorVisibleAuto = enabled;
463 }
464
465 #[doc(alias = "ConfigNavCursorVisibleAlways")]
467 pub fn config_nav_cursor_visible_always(&self) -> bool {
468 self.0.ConfigNavCursorVisibleAlways
469 }
470
471 #[doc(alias = "ConfigNavCursorVisibleAlways")]
473 pub fn set_config_nav_cursor_visible_always(&mut self, enabled: bool) {
474 self.0.ConfigNavCursorVisibleAlways = enabled;
475 }
476
477 #[doc(alias = "ConfigDockingNoSplit")]
479 pub fn config_docking_no_split(&self) -> bool {
480 self.0.ConfigDockingNoSplit
481 }
482
483 #[doc(alias = "ConfigDockingNoSplit")]
485 pub fn set_config_docking_no_split(&mut self, enabled: bool) {
486 self.0.ConfigDockingNoSplit = enabled;
487 }
488
489 #[doc(alias = "ConfigDockingNoDockingOver")]
491 pub fn config_docking_no_docking_over(&self) -> bool {
492 self.0.ConfigDockingNoDockingOver
493 }
494
495 #[doc(alias = "ConfigDockingNoDockingOver")]
497 pub fn set_config_docking_no_docking_over(&mut self, enabled: bool) {
498 self.0.ConfigDockingNoDockingOver = enabled;
499 }
500
501 #[doc(alias = "ConfigDockingWithShift")]
503 pub fn config_docking_with_shift(&self) -> bool {
504 self.0.ConfigDockingWithShift
505 }
506
507 #[doc(alias = "ConfigDockingWithShift")]
509 pub fn set_config_docking_with_shift(&mut self, enabled: bool) {
510 self.0.ConfigDockingWithShift = enabled;
511 }
512
513 #[doc(alias = "ConfigDockingAlwaysTabBar")]
515 pub fn config_docking_always_tab_bar(&self) -> bool {
516 self.0.ConfigDockingAlwaysTabBar
517 }
518
519 #[doc(alias = "ConfigDockingAlwaysTabBar")]
521 pub fn set_config_docking_always_tab_bar(&mut self, enabled: bool) {
522 self.0.ConfigDockingAlwaysTabBar = enabled;
523 }
524
525 #[doc(alias = "ConfigDockingTransparentPayload")]
527 pub fn config_docking_transparent_payload(&self) -> bool {
528 self.0.ConfigDockingTransparentPayload
529 }
530
531 #[doc(alias = "ConfigDockingTransparentPayload")]
533 pub fn set_config_docking_transparent_payload(&mut self, enabled: bool) {
534 self.0.ConfigDockingTransparentPayload = enabled;
535 }
536
537 #[doc(alias = "ConfigViewportsNoAutoMerge")]
539 pub fn config_viewports_no_auto_merge(&self) -> bool {
540 self.0.ConfigViewportsNoAutoMerge
541 }
542
543 #[doc(alias = "ConfigViewportsNoAutoMerge")]
545 pub fn set_config_viewports_no_auto_merge(&mut self, enabled: bool) {
546 self.0.ConfigViewportsNoAutoMerge = enabled;
547 }
548
549 #[doc(alias = "ConfigViewportsNoTaskBarIcon")]
551 pub fn config_viewports_no_task_bar_icon(&self) -> bool {
552 self.0.ConfigViewportsNoTaskBarIcon
553 }
554
555 #[doc(alias = "ConfigViewportsNoTaskBarIcon")]
557 pub fn set_config_viewports_no_task_bar_icon(&mut self, enabled: bool) {
558 self.0.ConfigViewportsNoTaskBarIcon = enabled;
559 }
560
561 #[doc(alias = "ConfigViewportsNoDecoration")]
563 pub fn config_viewports_no_decoration(&self) -> bool {
564 self.0.ConfigViewportsNoDecoration
565 }
566
567 #[doc(alias = "ConfigViewportsNoDecoration")]
569 pub fn set_config_viewports_no_decoration(&mut self, enabled: bool) {
570 self.0.ConfigViewportsNoDecoration = enabled;
571 }
572
573 #[doc(alias = "ConfigViewportsNoDefaultParent")]
575 pub fn config_viewports_no_default_parent(&self) -> bool {
576 self.0.ConfigViewportsNoDefaultParent
577 }
578
579 #[doc(alias = "ConfigViewportsNoDefaultParent")]
581 pub fn set_config_viewports_no_default_parent(&mut self, enabled: bool) {
582 self.0.ConfigViewportsNoDefaultParent = enabled;
583 }
584
585 #[doc(alias = "ConfigViewportsPlatformFocusSetsImGuiFocus")]
587 pub fn config_viewports_platform_focus_sets_imgui_focus(&self) -> bool {
588 self.0.ConfigViewportsPlatformFocusSetsImGuiFocus
589 }
590
591 #[doc(alias = "ConfigViewportsPlatformFocusSetsImGuiFocus")]
593 pub fn set_config_viewports_platform_focus_sets_imgui_focus(&mut self, enabled: bool) {
594 self.0.ConfigViewportsPlatformFocusSetsImGuiFocus = enabled;
595 }
596
597 #[doc(alias = "ConfigDpiScaleFonts")]
599 pub fn config_dpi_scale_fonts(&self) -> bool {
600 self.0.ConfigDpiScaleFonts
601 }
602
603 #[doc(alias = "ConfigDpiScaleFonts")]
605 pub fn set_config_dpi_scale_fonts(&mut self, enabled: bool) {
606 self.0.ConfigDpiScaleFonts = enabled;
607 }
608
609 #[doc(alias = "ConfigDpiScaleViewports")]
611 pub fn config_dpi_scale_viewports(&self) -> bool {
612 self.0.ConfigDpiScaleViewports
613 }
614
615 #[doc(alias = "ConfigDpiScaleViewports")]
617 pub fn set_config_dpi_scale_viewports(&mut self, enabled: bool) {
618 self.0.ConfigDpiScaleViewports = enabled;
619 }
620
621 #[doc(alias = "ConfigMacOSXBehaviors")]
623 pub fn config_macosx_behaviors(&self) -> bool {
624 self.0.ConfigMacOSXBehaviors
625 }
626
627 #[doc(alias = "ConfigMacOSXBehaviors")]
629 pub fn set_config_macosx_behaviors(&mut self, enabled: bool) {
630 self.0.ConfigMacOSXBehaviors = enabled;
631 }
632
633 #[doc(alias = "ConfigInputTrickleEventQueue")]
635 pub fn config_input_trickle_event_queue(&self) -> bool {
636 self.0.ConfigInputTrickleEventQueue
637 }
638
639 #[doc(alias = "ConfigInputTrickleEventQueue")]
641 pub fn set_config_input_trickle_event_queue(&mut self, enabled: bool) {
642 self.0.ConfigInputTrickleEventQueue = enabled;
643 }
644
645 #[doc(alias = "ConfigInputTextCursorBlink")]
647 pub fn config_input_text_cursor_blink(&self) -> bool {
648 self.0.ConfigInputTextCursorBlink
649 }
650
651 #[doc(alias = "ConfigInputTextCursorBlink")]
653 pub fn set_config_input_text_cursor_blink(&mut self, enabled: bool) {
654 self.0.ConfigInputTextCursorBlink = enabled;
655 }
656
657 #[doc(alias = "ConfigInputTextEnterKeepActive")]
659 pub fn config_input_text_enter_keep_active(&self) -> bool {
660 self.0.ConfigInputTextEnterKeepActive
661 }
662
663 #[doc(alias = "ConfigInputTextEnterKeepActive")]
665 pub fn set_config_input_text_enter_keep_active(&mut self, enabled: bool) {
666 self.0.ConfigInputTextEnterKeepActive = enabled;
667 }
668
669 #[doc(alias = "ConfigDragClickToInputText")]
671 pub fn config_drag_click_to_input_text(&self) -> bool {
672 self.0.ConfigDragClickToInputText
673 }
674
675 #[doc(alias = "ConfigDragClickToInputText")]
677 pub fn set_config_drag_click_to_input_text(&mut self, enabled: bool) {
678 self.0.ConfigDragClickToInputText = enabled;
679 }
680
681 #[doc(alias = "ConfigWindowsMoveFromTitleBarOnly")]
687 pub fn config_windows_move_from_title_bar_only(&self) -> bool {
688 self.0.ConfigWindowsMoveFromTitleBarOnly
689 }
690
691 #[doc(alias = "ConfigWindowsMoveFromTitleBarOnly")]
696 pub fn set_config_windows_move_from_title_bar_only(&mut self, enabled: bool) {
697 self.0.ConfigWindowsMoveFromTitleBarOnly = enabled;
698 }
699
700 #[doc(alias = "ConfigWindowsResizeFromEdges")]
702 pub fn config_windows_resize_from_edges(&self) -> bool {
703 self.0.ConfigWindowsResizeFromEdges
704 }
705
706 #[doc(alias = "ConfigWindowsResizeFromEdges")]
708 pub fn set_config_windows_resize_from_edges(&mut self, enabled: bool) {
709 self.0.ConfigWindowsResizeFromEdges = enabled;
710 }
711
712 #[doc(alias = "ConfigWindowsCopyContentsWithCtrlC")]
714 pub fn config_windows_copy_contents_with_ctrl_c(&self) -> bool {
715 self.0.ConfigWindowsCopyContentsWithCtrlC
716 }
717
718 #[doc(alias = "ConfigWindowsCopyContentsWithCtrlC")]
720 pub fn set_config_windows_copy_contents_with_ctrl_c(&mut self, enabled: bool) {
721 self.0.ConfigWindowsCopyContentsWithCtrlC = enabled;
722 }
723
724 #[doc(alias = "ConfigScrollbarScrollByPage")]
726 pub fn config_scrollbar_scroll_by_page(&self) -> bool {
727 self.0.ConfigScrollbarScrollByPage
728 }
729
730 #[doc(alias = "ConfigScrollbarScrollByPage")]
732 pub fn set_config_scrollbar_scroll_by_page(&mut self, enabled: bool) {
733 self.0.ConfigScrollbarScrollByPage = enabled;
734 }
735
736 #[doc(alias = "ConfigMemoryCompactTimer")]
738 pub fn config_memory_compact_timer(&self) -> f32 {
739 self.0.ConfigMemoryCompactTimer
740 }
741
742 #[doc(alias = "ConfigMemoryCompactTimer")]
744 pub fn set_config_memory_compact_timer(&mut self, seconds: f32) {
745 self.0.ConfigMemoryCompactTimer = seconds;
746 }
747
748 #[doc(alias = "MouseDoubleClickTime")]
750 pub fn mouse_double_click_time(&self) -> f32 {
751 self.0.MouseDoubleClickTime
752 }
753
754 #[doc(alias = "MouseDoubleClickTime")]
756 pub fn set_mouse_double_click_time(&mut self, seconds: f32) {
757 self.0.MouseDoubleClickTime = seconds;
758 }
759
760 #[doc(alias = "MouseDoubleClickMaxDist")]
762 pub fn mouse_double_click_max_dist(&self) -> f32 {
763 self.0.MouseDoubleClickMaxDist
764 }
765
766 #[doc(alias = "MouseDoubleClickMaxDist")]
768 pub fn set_mouse_double_click_max_dist(&mut self, pixels: f32) {
769 self.0.MouseDoubleClickMaxDist = pixels;
770 }
771
772 #[doc(alias = "MouseDragThreshold")]
774 pub fn mouse_drag_threshold(&self) -> f32 {
775 self.0.MouseDragThreshold
776 }
777
778 #[doc(alias = "MouseDragThreshold")]
780 pub fn set_mouse_drag_threshold(&mut self, pixels: f32) {
781 self.0.MouseDragThreshold = pixels;
782 }
783
784 #[doc(alias = "KeyRepeatDelay")]
786 pub fn key_repeat_delay(&self) -> f32 {
787 self.0.KeyRepeatDelay
788 }
789
790 #[doc(alias = "KeyRepeatDelay")]
792 pub fn set_key_repeat_delay(&mut self, seconds: f32) {
793 self.0.KeyRepeatDelay = seconds;
794 }
795
796 #[doc(alias = "KeyRepeatRate")]
798 pub fn key_repeat_rate(&self) -> f32 {
799 self.0.KeyRepeatRate
800 }
801
802 #[doc(alias = "KeyRepeatRate")]
804 pub fn set_key_repeat_rate(&mut self, seconds: f32) {
805 self.0.KeyRepeatRate = seconds;
806 }
807
808 #[doc(alias = "ConfigErrorRecovery")]
810 pub fn config_error_recovery(&self) -> bool {
811 self.0.ConfigErrorRecovery
812 }
813
814 #[doc(alias = "ConfigErrorRecovery")]
816 pub fn set_config_error_recovery(&mut self, enabled: bool) {
817 self.0.ConfigErrorRecovery = enabled;
818 }
819
820 #[doc(alias = "ConfigErrorRecoveryEnableAssert")]
822 pub fn config_error_recovery_enable_assert(&self) -> bool {
823 self.0.ConfigErrorRecoveryEnableAssert
824 }
825
826 #[doc(alias = "ConfigErrorRecoveryEnableAssert")]
828 pub fn set_config_error_recovery_enable_assert(&mut self, enabled: bool) {
829 self.0.ConfigErrorRecoveryEnableAssert = enabled;
830 }
831
832 #[doc(alias = "ConfigErrorRecoveryEnableDebugLog")]
834 pub fn config_error_recovery_enable_debug_log(&self) -> bool {
835 self.0.ConfigErrorRecoveryEnableDebugLog
836 }
837
838 #[doc(alias = "ConfigErrorRecoveryEnableDebugLog")]
840 pub fn set_config_error_recovery_enable_debug_log(&mut self, enabled: bool) {
841 self.0.ConfigErrorRecoveryEnableDebugLog = enabled;
842 }
843
844 #[doc(alias = "ConfigErrorRecoveryEnableTooltip")]
846 pub fn config_error_recovery_enable_tooltip(&self) -> bool {
847 self.0.ConfigErrorRecoveryEnableTooltip
848 }
849
850 #[doc(alias = "ConfigErrorRecoveryEnableTooltip")]
852 pub fn set_config_error_recovery_enable_tooltip(&mut self, enabled: bool) {
853 self.0.ConfigErrorRecoveryEnableTooltip = enabled;
854 }
855
856 #[doc(alias = "ConfigDebugIsDebuggerPresent")]
858 pub fn config_debug_is_debugger_present(&self) -> bool {
859 self.0.ConfigDebugIsDebuggerPresent
860 }
861
862 #[doc(alias = "ConfigDebugIsDebuggerPresent")]
864 pub fn set_config_debug_is_debugger_present(&mut self, enabled: bool) {
865 self.0.ConfigDebugIsDebuggerPresent = enabled;
866 }
867
868 #[doc(alias = "ConfigDebugHighlightIdConflicts")]
870 pub fn config_debug_highlight_id_conflicts(&self) -> bool {
871 self.0.ConfigDebugHighlightIdConflicts
872 }
873
874 #[doc(alias = "ConfigDebugHighlightIdConflicts")]
876 pub fn set_config_debug_highlight_id_conflicts(&mut self, enabled: bool) {
877 self.0.ConfigDebugHighlightIdConflicts = enabled;
878 }
879
880 #[doc(alias = "ConfigDebugHighlightIdConflictsShowItemPicker")]
882 pub fn config_debug_highlight_id_conflicts_show_item_picker(&self) -> bool {
883 self.0.ConfigDebugHighlightIdConflictsShowItemPicker
884 }
885
886 #[doc(alias = "ConfigDebugHighlightIdConflictsShowItemPicker")]
888 pub fn set_config_debug_highlight_id_conflicts_show_item_picker(&mut self, enabled: bool) {
889 self.0.ConfigDebugHighlightIdConflictsShowItemPicker = enabled;
890 }
891
892 #[doc(alias = "ConfigDebugBeginReturnValueOnce")]
894 pub fn config_debug_begin_return_value_once(&self) -> bool {
895 self.0.ConfigDebugBeginReturnValueOnce
896 }
897
898 #[doc(alias = "ConfigDebugBeginReturnValueOnce")]
900 pub fn set_config_debug_begin_return_value_once(&mut self, enabled: bool) {
901 self.0.ConfigDebugBeginReturnValueOnce = enabled;
902 }
903
904 #[doc(alias = "ConfigDebugBeginReturnValueLoop")]
906 pub fn config_debug_begin_return_value_loop(&self) -> bool {
907 self.0.ConfigDebugBeginReturnValueLoop
908 }
909
910 #[doc(alias = "ConfigDebugBeginReturnValueLoop")]
912 pub fn set_config_debug_begin_return_value_loop(&mut self, enabled: bool) {
913 self.0.ConfigDebugBeginReturnValueLoop = enabled;
914 }
915
916 #[doc(alias = "ConfigDebugIgnoreFocusLoss")]
918 pub fn config_debug_ignore_focus_loss(&self) -> bool {
919 self.0.ConfigDebugIgnoreFocusLoss
920 }
921
922 #[doc(alias = "ConfigDebugIgnoreFocusLoss")]
924 pub fn set_config_debug_ignore_focus_loss(&mut self, enabled: bool) {
925 self.0.ConfigDebugIgnoreFocusLoss = enabled;
926 }
927
928 #[doc(alias = "ConfigDebugIniSettings")]
930 pub fn config_debug_ini_settings(&self) -> bool {
931 self.0.ConfigDebugIniSettings
932 }
933
934 #[doc(alias = "ConfigDebugIniSettings")]
936 pub fn set_config_debug_ini_settings(&mut self, enabled: bool) {
937 self.0.ConfigDebugIniSettings = enabled;
938 }
939
940 #[doc(alias = "BackendPlatformName")]
944 pub fn backend_platform_name(&self) -> Option<&CStr> {
945 let ptr = self.0.BackendPlatformName;
946 unsafe { (!ptr.is_null()).then(|| CStr::from_ptr(ptr)) }
947 }
948
949 #[doc(alias = "BackendRendererName")]
953 pub fn backend_renderer_name(&self) -> Option<&CStr> {
954 let ptr = self.0.BackendRendererName;
955 unsafe { (!ptr.is_null()).then(|| CStr::from_ptr(ptr)) }
956 }
957
958 #[doc(alias = "BackendPlatformUserData")]
960 pub fn backend_platform_user_data(&self) -> *mut c_void {
961 self.0.BackendPlatformUserData
962 }
963
964 #[doc(alias = "BackendPlatformUserData")]
966 pub fn set_backend_platform_user_data(&mut self, user_data: *mut c_void) {
967 self.0.BackendPlatformUserData = user_data;
968 }
969
970 #[doc(alias = "BackendRendererUserData")]
972 pub fn backend_renderer_user_data(&self) -> *mut c_void {
973 self.0.BackendRendererUserData
974 }
975
976 #[doc(alias = "BackendRendererUserData")]
978 pub fn set_backend_renderer_user_data(&mut self, user_data: *mut c_void) {
979 self.0.BackendRendererUserData = user_data;
980 }
981
982 #[doc(alias = "BackendLanguageUserData")]
984 pub fn backend_language_user_data(&self) -> *mut c_void {
985 self.0.BackendLanguageUserData
986 }
987
988 #[doc(alias = "BackendLanguageUserData")]
990 pub fn set_backend_language_user_data(&mut self, user_data: *mut c_void) {
991 self.0.BackendLanguageUserData = user_data;
992 }
993
994 pub fn backend_flags(&self) -> BackendFlags {
996 BackendFlags::from_bits_truncate(self.0.BackendFlags)
997 }
998
999 pub fn set_backend_flags(&mut self, flags: BackendFlags) {
1001 self.0.BackendFlags = flags.bits();
1002 }
1003
1004 pub fn add_key_event(&mut self, key: crate::Key, down: bool) {
1006 unsafe {
1007 sys::ImGuiIO_AddKeyEvent(&mut self.0 as *mut _, key.into(), down);
1008 }
1009 }
1010
1011 pub fn add_input_character(&mut self, character: char) {
1013 unsafe {
1014 sys::ImGuiIO_AddInputCharacter(&mut self.0 as *mut _, character as u32);
1015 }
1016 }
1017
1018 pub fn add_mouse_pos_event(&mut self, pos: [f32; 2]) {
1020 unsafe {
1021 sys::ImGuiIO_AddMousePosEvent(&mut self.0 as *mut _, pos[0], pos[1]);
1022 }
1023 }
1024
1025 pub fn add_mouse_button_event(&mut self, button: crate::input::MouseButton, down: bool) {
1027 unsafe {
1028 sys::ImGuiIO_AddMouseButtonEvent(&mut self.0 as *mut _, button.into(), down);
1029 }
1030 }
1031
1032 pub fn add_mouse_wheel_event(&mut self, wheel: [f32; 2]) {
1034 unsafe {
1035 sys::ImGuiIO_AddMouseWheelEvent(&mut self.0 as *mut _, wheel[0], wheel[1]);
1036 }
1037 }
1038
1039 pub fn add_mouse_source_event(&mut self, source: crate::input::MouseSource) {
1045 unsafe {
1046 sys::ImGuiIO_AddMouseSourceEvent(&mut self.0 as *mut _, source.into());
1047 }
1048 }
1049
1050 pub fn add_mouse_viewport_event(&mut self, viewport_id: crate::Id) {
1057 unsafe {
1058 sys::ImGuiIO_AddMouseViewportEvent(&mut self.0 as *mut _, viewport_id.raw());
1059 }
1060 }
1061
1062 pub fn add_focus_event(&mut self, focused: bool) {
1065 unsafe {
1066 sys::ImGuiIO_AddFocusEvent(&mut self.0 as *mut _, focused);
1067 }
1068 }
1069
1070 pub fn font_global_scale(&self) -> f32 {
1073 unsafe { (*sys::igGetStyle()).FontScaleMain }
1074 }
1075
1076 pub fn set_font_global_scale(&mut self, _scale: f32) {
1079 unsafe {
1080 (*sys::igGetStyle()).FontScaleMain = _scale;
1081 }
1082 }
1083
1084 pub fn display_framebuffer_scale(&self) -> [f32; 2] {
1086 let scale = self.0.DisplayFramebufferScale;
1087 [scale.x, scale.y]
1088 }
1089
1090 #[doc(alias = "MouseDelta")]
1092 pub fn mouse_delta(&self) -> [f32; 2] {
1093 let delta = self.0.MouseDelta;
1094 [delta.x, delta.y]
1095 }
1096
1097 #[doc(alias = "KeyCtrl")]
1099 pub fn key_ctrl(&self) -> bool {
1100 self.0.KeyCtrl
1101 }
1102
1103 #[doc(alias = "KeyShift")]
1105 pub fn key_shift(&self) -> bool {
1106 self.0.KeyShift
1107 }
1108
1109 #[doc(alias = "KeyAlt")]
1111 pub fn key_alt(&self) -> bool {
1112 self.0.KeyAlt
1113 }
1114
1115 #[doc(alias = "KeySuper")]
1117 pub fn key_super(&self) -> bool {
1118 self.0.KeySuper
1119 }
1120
1121 #[doc(alias = "MouseSource")]
1123 pub fn mouse_source(&self) -> crate::input::MouseSource {
1124 match self.0.MouseSource {
1125 sys::ImGuiMouseSource_Mouse => crate::input::MouseSource::Mouse,
1126 sys::ImGuiMouseSource_TouchScreen => crate::input::MouseSource::TouchScreen,
1127 sys::ImGuiMouseSource_Pen => crate::input::MouseSource::Pen,
1128 _ => crate::input::MouseSource::Mouse,
1129 }
1130 }
1131
1132 #[doc(alias = "MouseHoveredViewport")]
1134 pub fn mouse_hovered_viewport(&self) -> crate::Id {
1135 crate::Id::from(self.0.MouseHoveredViewport)
1136 }
1137
1138 #[doc(alias = "MouseCtrlLeftAsRightClick")]
1140 pub fn mouse_ctrl_left_as_right_click(&self) -> bool {
1141 self.0.MouseCtrlLeftAsRightClick
1142 }
1143
1144 #[doc(alias = "MouseCtrlLeftAsRightClick")]
1146 pub fn set_mouse_ctrl_left_as_right_click(&mut self, enabled: bool) {
1147 self.0.MouseCtrlLeftAsRightClick = enabled;
1148 }
1149
1150 pub fn set_display_framebuffer_scale(&mut self, scale: [f32; 2]) {
1153 self.0.DisplayFramebufferScale.x = scale[0];
1154 self.0.DisplayFramebufferScale.y = scale[1];
1155 }
1156}