dear_imgui_rs/
io.rs

1//! IO: inputs, configuration and backend capabilities
2//!
3//! This module wraps Dear ImGui's `ImGuiIO` and related flag types. Access the
4//! per-frame IO object via [`Ui::io`], then read inputs or tweak configuration
5//! and backend capability flags.
6//!
7//! Example: enable docking and multi-viewports, and set renderer flags.
8//! ```no_run
9//! # use dear_imgui_rs::*;
10//! # let mut ctx = Context::create();
11//! // Configure IO before starting a frame
12//! let io = ctx.io_mut();
13//! io.set_config_flags(io.config_flags() | ConfigFlags::DOCKING_ENABLE | ConfigFlags::VIEWPORTS_ENABLE);
14//! io.set_backend_flags(io.backend_flags() | BackendFlags::RENDERER_HAS_TEXTURES);
15//! # let _ = ctx.frame();
16//! ```
17//!
18#![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    /// Configuration flags
95    #[repr(transparent)]
96    pub struct ConfigFlags: i32 {
97        /// Master keyboard navigation enable flag.
98        const NAV_ENABLE_KEYBOARD = sys::ImGuiConfigFlags_NavEnableKeyboard as i32;
99        /// Master gamepad navigation enable flag.
100        const NAV_ENABLE_GAMEPAD = sys::ImGuiConfigFlags_NavEnableGamepad as i32;
101        /// Instruction imgui-rs to clear mouse position/buttons in `frame()`.
102        const NO_MOUSE = sys::ImGuiConfigFlags_NoMouse as i32;
103        /// Instruction backend to not alter mouse cursor shape and visibility.
104        const NO_MOUSE_CURSOR_CHANGE = sys::ImGuiConfigFlags_NoMouseCursorChange as i32;
105        /// Application is SRGB-aware.
106        const IS_SRGB = sys::ImGuiConfigFlags_IsSRGB as i32;
107        /// Application is using a touch screen instead of a mouse.
108        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    /// Backend capabilities
118    #[repr(transparent)]
119    pub struct BackendFlags: i32 {
120        /// Backend supports gamepad and currently has one connected
121        const HAS_GAMEPAD = sys::ImGuiBackendFlags_HasGamepad as i32;
122        /// Backend supports honoring `get_mouse_cursor` value to change the OS cursor shape
123        const HAS_MOUSE_CURSORS = sys::ImGuiBackendFlags_HasMouseCursors as i32;
124        /// Backend supports `io.want_set_mouse_pos` requests to reposition the OS mouse position.
125        const HAS_SET_MOUSE_POS = sys::ImGuiBackendFlags_HasSetMousePos as i32;
126        /// Backend can report which viewport the OS mouse is hovering via `add_mouse_viewport_event`
127        const HAS_MOUSE_HOVERED_VIEWPORT =
128            sys::ImGuiBackendFlags_HasMouseHoveredViewport as i32;
129        /// Backend renderer supports DrawCmd::vtx_offset.
130        const RENDERER_HAS_VTX_OFFSET = sys::ImGuiBackendFlags_RendererHasVtxOffset as i32;
131        /// Backend renderer supports ImTextureData requests to create/update/destroy textures.
132        const RENDERER_HAS_TEXTURES = sys::ImGuiBackendFlags_RendererHasTextures as i32;
133
134        #[cfg(feature = "multi-viewport")]
135        /// Set if the platform backend supports viewports.
136        const PLATFORM_HAS_VIEWPORTS = sys::ImGuiBackendFlags_PlatformHasViewports as i32;
137        #[cfg(feature = "multi-viewport")]
138        /// Set if the renderer backend supports viewports.
139        const RENDERER_HAS_VIEWPORTS = sys::ImGuiBackendFlags_RendererHasViewports as i32;
140    }
141}
142
143#[cfg(feature = "multi-viewport")]
144bitflags! {
145    /// Viewport flags for multi-viewport support
146    #[repr(transparent)]
147    pub struct ViewportFlags: i32 {
148        /// No flags
149        const NONE = 0;
150        /// Represent a Platform Window
151        const IS_PLATFORM_WINDOW = sys::ImGuiViewportFlags_IsPlatformWindow as i32;
152        /// Represent a Platform Monitor (unused in our implementation)
153        const IS_PLATFORM_MONITOR = sys::ImGuiViewportFlags_IsPlatformMonitor as i32;
154        /// Platform Window: is created/managed by the application (rather than a dear imgui backend)
155        const OWNED_BY_APP = sys::ImGuiViewportFlags_OwnedByApp as i32;
156        /// Platform Window: Disable platform decorations: title bar, borders, etc.
157        const NO_DECORATION = sys::ImGuiViewportFlags_NoDecoration as i32;
158        /// Platform Window: Disable platform task bar icon (generally set on popups/tooltips, or all windows if ImGuiConfigFlags_ViewportsNoTaskBarIcon is set)
159        const NO_TASK_BAR_ICON = sys::ImGuiViewportFlags_NoTaskBarIcon as i32;
160        /// Platform Window: Don't take focus when created.
161        const NO_FOCUS_ON_APPEARING = sys::ImGuiViewportFlags_NoFocusOnAppearing as i32;
162        /// Platform Window: Don't take focus when clicked on.
163        const NO_FOCUS_ON_CLICK = sys::ImGuiViewportFlags_NoFocusOnClick as i32;
164        /// Platform Window: Make mouse pass through so we can drag this window while peaking behind it.
165        const NO_INPUTS = sys::ImGuiViewportFlags_NoInputs as i32;
166        /// Platform Window: Renderer doesn't need to clear the framebuffer ahead (because we will fill it entirely).
167        const NO_RENDERER_CLEAR = sys::ImGuiViewportFlags_NoRendererClear as i32;
168        /// Platform Window: Avoid merging this window into another host window. This can only be set via ImGuiWindowClass viewport flags override (because we need to now ahead if we are going to create a viewport in the first place!).
169        const NO_AUTO_MERGE = sys::ImGuiViewportFlags_NoAutoMerge as i32;
170        /// Platform Window: Display on top (for tooltips only).
171        const TOP_MOST = sys::ImGuiViewportFlags_TopMost as i32;
172        /// Viewport can host multiple imgui windows (secondary viewports are associated to a single window).
173        const CAN_HOST_OTHER_WINDOWS = sys::ImGuiViewportFlags_CanHostOtherWindows as i32;
174        /// Platform Window: Window is minimized, can skip render. When minimized we tend to avoid using the viewport pos/size for clipping rectangle computation.
175        const IS_MINIMIZED = sys::ImGuiViewportFlags_IsMinimized as i32;
176        /// Platform Window: Window is focused (last call to Platform_GetWindowFocus() returned true)
177        const IS_FOCUSED = sys::ImGuiViewportFlags_IsFocused as i32;
178    }
179}
180
181/// Settings and inputs/outputs for imgui-rs
182/// This is a transparent wrapper around ImGuiIO
183#[repr(transparent)]
184pub struct Io(sys::ImGuiIO);
185
186impl Io {
187    /// Creates a new Io instance from the current context
188    pub(crate) fn from_raw() -> &'static mut Self {
189        unsafe {
190            // Note: our bindings expose igGetIO_Nil which resolves against the
191            // current context. Keep using _Nil variant until regular symbol is exported.
192            let io_ptr = sys::igGetIO_Nil();
193            &mut *(io_ptr as *mut Self)
194        }
195    }
196
197    /// Main display size in pixels
198    pub fn display_size(&self) -> [f32; 2] {
199        [self.0.DisplaySize.x, self.0.DisplaySize.y]
200    }
201
202    /// Set main display size in pixels
203    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    /// Time elapsed since last frame, in seconds
209    pub fn delta_time(&self) -> f32 {
210        self.0.DeltaTime
211    }
212
213    /// Set time elapsed since last frame, in seconds
214    pub fn set_delta_time(&mut self, delta_time: f32) {
215        self.0.DeltaTime = delta_time;
216    }
217
218    /// Auto-save interval for `.ini` settings, in seconds.
219    #[doc(alias = "IniSavingRate")]
220    pub fn ini_saving_rate(&self) -> f32 {
221        self.0.IniSavingRate
222    }
223
224    /// Set auto-save interval for `.ini` settings, in seconds.
225    #[doc(alias = "IniSavingRate")]
226    pub fn set_ini_saving_rate(&mut self, seconds: f32) {
227        self.0.IniSavingRate = seconds;
228    }
229
230    /// Returns the current `.ini` filename, or `None` if disabled.
231    ///
232    /// Note: to set this safely, use `Context::set_ini_filename()`.
233    #[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    /// Returns the current `.log` filename, or `None` if disabled.
240    ///
241    /// Note: to set this safely, use `Context::set_log_filename()`.
242    #[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    /// Returns user data pointer stored in `ImGuiIO`.
249    #[doc(alias = "UserData")]
250    pub fn user_data(&self) -> *mut c_void {
251        self.0.UserData
252    }
253
254    /// Set user data pointer stored in `ImGuiIO`.
255    #[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    /// Returns whether font scaling via Ctrl+MouseWheel is enabled.
261    #[doc(alias = "FontAllowUserScaling")]
262    pub fn font_allow_user_scaling(&self) -> bool {
263        self.0.FontAllowUserScaling
264    }
265
266    /// Set whether font scaling via Ctrl+MouseWheel is enabled.
267    #[doc(alias = "FontAllowUserScaling")]
268    pub fn set_font_allow_user_scaling(&mut self, enabled: bool) {
269        self.0.FontAllowUserScaling = enabled;
270    }
271
272    /// Mouse position, in pixels
273    pub fn mouse_pos(&self) -> [f32; 2] {
274        [self.0.MousePos.x, self.0.MousePos.y]
275    }
276
277    /// Set mouse position, in pixels
278    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    /// Mouse wheel vertical scrolling
284    pub fn mouse_wheel(&self) -> f32 {
285        self.0.MouseWheel
286    }
287
288    /// Set mouse wheel vertical scrolling
289    pub fn set_mouse_wheel(&mut self, wheel: f32) {
290        self.0.MouseWheel = wheel;
291    }
292
293    /// Mouse wheel horizontal scrolling
294    pub fn mouse_wheel_h(&self) -> f32 {
295        self.0.MouseWheelH
296    }
297
298    /// Set mouse wheel horizontal scrolling
299    pub fn set_mouse_wheel_h(&mut self, wheel_h: f32) {
300        self.0.MouseWheelH = wheel_h;
301    }
302
303    /// Check if a mouse button is down
304    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    /// Set mouse button state
313    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    /// Check if imgui wants to capture mouse input
320    pub fn want_capture_mouse(&self) -> bool {
321        self.0.WantCaptureMouse
322    }
323
324    /// Returns whether ImGui wants to capture mouse, unless a popup is closing.
325    #[doc(alias = "WantCaptureMouseUnlessPopupClose")]
326    pub fn want_capture_mouse_unless_popup_close(&self) -> bool {
327        self.0.WantCaptureMouseUnlessPopupClose
328    }
329
330    /// Check if imgui wants to capture keyboard input
331    pub fn want_capture_keyboard(&self) -> bool {
332        self.0.WantCaptureKeyboard
333    }
334
335    /// Check if imgui wants to use text input
336    pub fn want_text_input(&self) -> bool {
337        self.0.WantTextInput
338    }
339
340    /// Check if imgui wants to set mouse position
341    pub fn want_set_mouse_pos(&self) -> bool {
342        self.0.WantSetMousePos
343    }
344    /// Whether ImGui requests software-drawn mouse cursor
345    pub fn mouse_draw_cursor(&self) -> bool {
346        self.0.MouseDrawCursor
347    }
348    /// Enable or disable software-drawn mouse cursor
349    pub fn set_mouse_draw_cursor(&mut self, draw: bool) {
350        self.0.MouseDrawCursor = draw;
351    }
352
353    /// Check if imgui wants to save ini settings
354    pub fn want_save_ini_settings(&self) -> bool {
355        self.0.WantSaveIniSettings
356    }
357
358    /// Framerate estimation, in frames per second
359    pub fn framerate(&self) -> f32 {
360        self.0.Framerate
361    }
362
363    /// Vertices output during last call to render
364    pub fn metrics_render_vertices(&self) -> i32 {
365        self.0.MetricsRenderVertices
366    }
367
368    /// Indices output during last call to render
369    pub fn metrics_render_indices(&self) -> i32 {
370        self.0.MetricsRenderIndices
371    }
372
373    /// Number of visible windows
374    pub fn metrics_render_windows(&self) -> i32 {
375        self.0.MetricsRenderWindows
376    }
377
378    /// Number of active windows
379    pub fn metrics_active_windows(&self) -> i32 {
380        self.0.MetricsActiveWindows
381    }
382
383    /// Configuration flags
384    pub fn config_flags(&self) -> ConfigFlags {
385        ConfigFlags::from_bits_truncate(self.0.ConfigFlags)
386    }
387
388    /// Set configuration flags
389    pub fn set_config_flags(&mut self, flags: ConfigFlags) {
390        self.0.ConfigFlags = flags.bits();
391    }
392
393    /// Returns whether to swap gamepad buttons for navigation.
394    #[doc(alias = "ConfigNavSwapGamepadButtons")]
395    pub fn config_nav_swap_gamepad_buttons(&self) -> bool {
396        self.0.ConfigNavSwapGamepadButtons
397    }
398
399    /// Set whether to swap gamepad buttons for navigation.
400    #[doc(alias = "ConfigNavSwapGamepadButtons")]
401    pub fn set_config_nav_swap_gamepad_buttons(&mut self, enabled: bool) {
402        self.0.ConfigNavSwapGamepadButtons = enabled;
403    }
404
405    /// Returns whether navigation can move the mouse cursor.
406    #[doc(alias = "ConfigNavMoveSetMousePos")]
407    pub fn config_nav_move_set_mouse_pos(&self) -> bool {
408        self.0.ConfigNavMoveSetMousePos
409    }
410
411    /// Set whether navigation can move the mouse cursor.
412    #[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    /// Returns whether to capture keyboard inputs during navigation.
418    #[doc(alias = "ConfigNavCaptureKeyboard")]
419    pub fn config_nav_capture_keyboard(&self) -> bool {
420        self.0.ConfigNavCaptureKeyboard
421    }
422
423    /// Set whether to capture keyboard inputs during navigation.
424    #[doc(alias = "ConfigNavCaptureKeyboard")]
425    pub fn set_config_nav_capture_keyboard(&mut self, enabled: bool) {
426        self.0.ConfigNavCaptureKeyboard = enabled;
427    }
428
429    /// Returns whether Escape clears the focused item.
430    #[doc(alias = "ConfigNavEscapeClearFocusItem")]
431    pub fn config_nav_escape_clear_focus_item(&self) -> bool {
432        self.0.ConfigNavEscapeClearFocusItem
433    }
434
435    /// Set whether Escape clears the focused item.
436    #[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    /// Returns whether Escape clears the focused window.
442    #[doc(alias = "ConfigNavEscapeClearFocusWindow")]
443    pub fn config_nav_escape_clear_focus_window(&self) -> bool {
444        self.0.ConfigNavEscapeClearFocusWindow
445    }
446
447    /// Set whether Escape clears the focused window.
448    #[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    /// Returns whether the navigation cursor visibility is automatically managed.
454    #[doc(alias = "ConfigNavCursorVisibleAuto")]
455    pub fn config_nav_cursor_visible_auto(&self) -> bool {
456        self.0.ConfigNavCursorVisibleAuto
457    }
458
459    /// Set whether the navigation cursor visibility is automatically managed.
460    #[doc(alias = "ConfigNavCursorVisibleAuto")]
461    pub fn set_config_nav_cursor_visible_auto(&mut self, enabled: bool) {
462        self.0.ConfigNavCursorVisibleAuto = enabled;
463    }
464
465    /// Returns whether the navigation cursor is always visible.
466    #[doc(alias = "ConfigNavCursorVisibleAlways")]
467    pub fn config_nav_cursor_visible_always(&self) -> bool {
468        self.0.ConfigNavCursorVisibleAlways
469    }
470
471    /// Set whether the navigation cursor is always visible.
472    #[doc(alias = "ConfigNavCursorVisibleAlways")]
473    pub fn set_config_nav_cursor_visible_always(&mut self, enabled: bool) {
474        self.0.ConfigNavCursorVisibleAlways = enabled;
475    }
476
477    /// Returns whether docking is prevented from splitting nodes.
478    #[doc(alias = "ConfigDockingNoSplit")]
479    pub fn config_docking_no_split(&self) -> bool {
480        self.0.ConfigDockingNoSplit
481    }
482
483    /// Set whether docking is prevented from splitting nodes.
484    #[doc(alias = "ConfigDockingNoSplit")]
485    pub fn set_config_docking_no_split(&mut self, enabled: bool) {
486        self.0.ConfigDockingNoSplit = enabled;
487    }
488
489    /// Returns whether docking over other windows is disabled.
490    #[doc(alias = "ConfigDockingNoDockingOver")]
491    pub fn config_docking_no_docking_over(&self) -> bool {
492        self.0.ConfigDockingNoDockingOver
493    }
494
495    /// Set whether docking over other windows is disabled.
496    #[doc(alias = "ConfigDockingNoDockingOver")]
497    pub fn set_config_docking_no_docking_over(&mut self, enabled: bool) {
498        self.0.ConfigDockingNoDockingOver = enabled;
499    }
500
501    /// Returns whether docking requires holding Shift.
502    #[doc(alias = "ConfigDockingWithShift")]
503    pub fn config_docking_with_shift(&self) -> bool {
504        self.0.ConfigDockingWithShift
505    }
506
507    /// Set whether docking requires holding Shift.
508    #[doc(alias = "ConfigDockingWithShift")]
509    pub fn set_config_docking_with_shift(&mut self, enabled: bool) {
510        self.0.ConfigDockingWithShift = enabled;
511    }
512
513    /// Returns whether docking uses a tab bar when possible.
514    #[doc(alias = "ConfigDockingAlwaysTabBar")]
515    pub fn config_docking_always_tab_bar(&self) -> bool {
516        self.0.ConfigDockingAlwaysTabBar
517    }
518
519    /// Set whether docking uses a tab bar when possible.
520    #[doc(alias = "ConfigDockingAlwaysTabBar")]
521    pub fn set_config_docking_always_tab_bar(&mut self, enabled: bool) {
522        self.0.ConfigDockingAlwaysTabBar = enabled;
523    }
524
525    /// Returns whether docking payloads are rendered transparently.
526    #[doc(alias = "ConfigDockingTransparentPayload")]
527    pub fn config_docking_transparent_payload(&self) -> bool {
528        self.0.ConfigDockingTransparentPayload
529    }
530
531    /// Set whether docking payloads are rendered transparently.
532    #[doc(alias = "ConfigDockingTransparentPayload")]
533    pub fn set_config_docking_transparent_payload(&mut self, enabled: bool) {
534        self.0.ConfigDockingTransparentPayload = enabled;
535    }
536
537    /// Returns whether viewports should avoid auto-merging.
538    #[doc(alias = "ConfigViewportsNoAutoMerge")]
539    pub fn config_viewports_no_auto_merge(&self) -> bool {
540        self.0.ConfigViewportsNoAutoMerge
541    }
542
543    /// Set whether viewports should avoid auto-merging.
544    #[doc(alias = "ConfigViewportsNoAutoMerge")]
545    pub fn set_config_viewports_no_auto_merge(&mut self, enabled: bool) {
546        self.0.ConfigViewportsNoAutoMerge = enabled;
547    }
548
549    /// Returns whether viewports should avoid task bar icons.
550    #[doc(alias = "ConfigViewportsNoTaskBarIcon")]
551    pub fn config_viewports_no_task_bar_icon(&self) -> bool {
552        self.0.ConfigViewportsNoTaskBarIcon
553    }
554
555    /// Set whether viewports should avoid task bar icons.
556    #[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    /// Returns whether viewports should avoid platform window decorations.
562    #[doc(alias = "ConfigViewportsNoDecoration")]
563    pub fn config_viewports_no_decoration(&self) -> bool {
564        self.0.ConfigViewportsNoDecoration
565    }
566
567    /// Set whether viewports should avoid platform window decorations.
568    #[doc(alias = "ConfigViewportsNoDecoration")]
569    pub fn set_config_viewports_no_decoration(&mut self, enabled: bool) {
570        self.0.ConfigViewportsNoDecoration = enabled;
571    }
572
573    /// Returns whether viewports should not have a default parent.
574    #[doc(alias = "ConfigViewportsNoDefaultParent")]
575    pub fn config_viewports_no_default_parent(&self) -> bool {
576        self.0.ConfigViewportsNoDefaultParent
577    }
578
579    /// Set whether viewports should not have a default parent.
580    #[doc(alias = "ConfigViewportsNoDefaultParent")]
581    pub fn set_config_viewports_no_default_parent(&mut self, enabled: bool) {
582        self.0.ConfigViewportsNoDefaultParent = enabled;
583    }
584
585    /// Returns whether platform focus also sets ImGui focus in viewports.
586    #[doc(alias = "ConfigViewportsPlatformFocusSetsImGuiFocus")]
587    pub fn config_viewports_platform_focus_sets_imgui_focus(&self) -> bool {
588        self.0.ConfigViewportsPlatformFocusSetsImGuiFocus
589    }
590
591    /// Set whether platform focus also sets ImGui focus in viewports.
592    #[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    /// Returns whether fonts are scaled by DPI.
598    #[doc(alias = "ConfigDpiScaleFonts")]
599    pub fn config_dpi_scale_fonts(&self) -> bool {
600        self.0.ConfigDpiScaleFonts
601    }
602
603    /// Set whether fonts are scaled by DPI.
604    #[doc(alias = "ConfigDpiScaleFonts")]
605    pub fn set_config_dpi_scale_fonts(&mut self, enabled: bool) {
606        self.0.ConfigDpiScaleFonts = enabled;
607    }
608
609    /// Returns whether viewports are scaled by DPI.
610    #[doc(alias = "ConfigDpiScaleViewports")]
611    pub fn config_dpi_scale_viewports(&self) -> bool {
612        self.0.ConfigDpiScaleViewports
613    }
614
615    /// Set whether viewports are scaled by DPI.
616    #[doc(alias = "ConfigDpiScaleViewports")]
617    pub fn set_config_dpi_scale_viewports(&mut self, enabled: bool) {
618        self.0.ConfigDpiScaleViewports = enabled;
619    }
620
621    /// Returns whether to use MacOSX-style behaviors.
622    #[doc(alias = "ConfigMacOSXBehaviors")]
623    pub fn config_macosx_behaviors(&self) -> bool {
624        self.0.ConfigMacOSXBehaviors
625    }
626
627    /// Set whether to use MacOSX-style behaviors.
628    #[doc(alias = "ConfigMacOSXBehaviors")]
629    pub fn set_config_macosx_behaviors(&mut self, enabled: bool) {
630        self.0.ConfigMacOSXBehaviors = enabled;
631    }
632
633    /// Returns whether to trickle input events through the queue.
634    #[doc(alias = "ConfigInputTrickleEventQueue")]
635    pub fn config_input_trickle_event_queue(&self) -> bool {
636        self.0.ConfigInputTrickleEventQueue
637    }
638
639    /// Set whether to trickle input events through the queue.
640    #[doc(alias = "ConfigInputTrickleEventQueue")]
641    pub fn set_config_input_trickle_event_queue(&mut self, enabled: bool) {
642        self.0.ConfigInputTrickleEventQueue = enabled;
643    }
644
645    /// Returns whether the input text cursor blinks.
646    #[doc(alias = "ConfigInputTextCursorBlink")]
647    pub fn config_input_text_cursor_blink(&self) -> bool {
648        self.0.ConfigInputTextCursorBlink
649    }
650
651    /// Set whether the input text cursor blinks.
652    #[doc(alias = "ConfigInputTextCursorBlink")]
653    pub fn set_config_input_text_cursor_blink(&mut self, enabled: bool) {
654        self.0.ConfigInputTextCursorBlink = enabled;
655    }
656
657    /// Returns whether Enter keeps the input text active.
658    #[doc(alias = "ConfigInputTextEnterKeepActive")]
659    pub fn config_input_text_enter_keep_active(&self) -> bool {
660        self.0.ConfigInputTextEnterKeepActive
661    }
662
663    /// Set whether Enter keeps the input text active.
664    #[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    /// Returns whether click-drag on numeric widgets turns into text input.
670    #[doc(alias = "ConfigDragClickToInputText")]
671    pub fn config_drag_click_to_input_text(&self) -> bool {
672        self.0.ConfigDragClickToInputText
673    }
674
675    /// Set whether click-drag on numeric widgets turns into text input.
676    #[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    /// Returns whether windows can be moved only from their title bar.
682    ///
683    /// When enabled, click-dragging on empty window content will no longer move the window.
684    /// This can be useful in multi-viewport setups to avoid accidental platform window moves
685    /// while interacting with in-window widgets (e.g. gizmos in a scene view).
686    #[doc(alias = "ConfigWindowsMoveFromTitleBarOnly")]
687    pub fn config_windows_move_from_title_bar_only(&self) -> bool {
688        self.0.ConfigWindowsMoveFromTitleBarOnly
689    }
690
691    /// Set whether windows can be moved only from their title bar.
692    ///
693    /// Note: This is typically latched by Dear ImGui at the start of the frame. Prefer setting it
694    /// during initialization or before calling `Context::frame()`.
695    #[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    /// Returns whether windows can be resized from their edges.
701    #[doc(alias = "ConfigWindowsResizeFromEdges")]
702    pub fn config_windows_resize_from_edges(&self) -> bool {
703        self.0.ConfigWindowsResizeFromEdges
704    }
705
706    /// Set whether windows can be resized from their edges.
707    #[doc(alias = "ConfigWindowsResizeFromEdges")]
708    pub fn set_config_windows_resize_from_edges(&mut self, enabled: bool) {
709        self.0.ConfigWindowsResizeFromEdges = enabled;
710    }
711
712    /// Returns whether Ctrl+C copies window contents.
713    #[doc(alias = "ConfigWindowsCopyContentsWithCtrlC")]
714    pub fn config_windows_copy_contents_with_ctrl_c(&self) -> bool {
715        self.0.ConfigWindowsCopyContentsWithCtrlC
716    }
717
718    /// Set whether Ctrl+C copies window contents.
719    #[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    /// Returns whether scrollbars scroll by page.
725    #[doc(alias = "ConfigScrollbarScrollByPage")]
726    pub fn config_scrollbar_scroll_by_page(&self) -> bool {
727        self.0.ConfigScrollbarScrollByPage
728    }
729
730    /// Set whether scrollbars scroll by page.
731    #[doc(alias = "ConfigScrollbarScrollByPage")]
732    pub fn set_config_scrollbar_scroll_by_page(&mut self, enabled: bool) {
733        self.0.ConfigScrollbarScrollByPage = enabled;
734    }
735
736    /// Returns the memory compact timer (seconds).
737    #[doc(alias = "ConfigMemoryCompactTimer")]
738    pub fn config_memory_compact_timer(&self) -> f32 {
739        self.0.ConfigMemoryCompactTimer
740    }
741
742    /// Set the memory compact timer (seconds).
743    #[doc(alias = "ConfigMemoryCompactTimer")]
744    pub fn set_config_memory_compact_timer(&mut self, seconds: f32) {
745        self.0.ConfigMemoryCompactTimer = seconds;
746    }
747
748    /// Returns the time for a double-click (seconds).
749    #[doc(alias = "MouseDoubleClickTime")]
750    pub fn mouse_double_click_time(&self) -> f32 {
751        self.0.MouseDoubleClickTime
752    }
753
754    /// Set the time for a double-click (seconds).
755    #[doc(alias = "MouseDoubleClickTime")]
756    pub fn set_mouse_double_click_time(&mut self, seconds: f32) {
757        self.0.MouseDoubleClickTime = seconds;
758    }
759
760    /// Returns the maximum distance to qualify as a double-click (pixels).
761    #[doc(alias = "MouseDoubleClickMaxDist")]
762    pub fn mouse_double_click_max_dist(&self) -> f32 {
763        self.0.MouseDoubleClickMaxDist
764    }
765
766    /// Set the maximum distance to qualify as a double-click (pixels).
767    #[doc(alias = "MouseDoubleClickMaxDist")]
768    pub fn set_mouse_double_click_max_dist(&mut self, pixels: f32) {
769        self.0.MouseDoubleClickMaxDist = pixels;
770    }
771
772    /// Returns the distance threshold for starting a drag (pixels).
773    #[doc(alias = "MouseDragThreshold")]
774    pub fn mouse_drag_threshold(&self) -> f32 {
775        self.0.MouseDragThreshold
776    }
777
778    /// Set the distance threshold for starting a drag (pixels).
779    #[doc(alias = "MouseDragThreshold")]
780    pub fn set_mouse_drag_threshold(&mut self, pixels: f32) {
781        self.0.MouseDragThreshold = pixels;
782    }
783
784    /// Returns the key repeat delay (seconds).
785    #[doc(alias = "KeyRepeatDelay")]
786    pub fn key_repeat_delay(&self) -> f32 {
787        self.0.KeyRepeatDelay
788    }
789
790    /// Set the key repeat delay (seconds).
791    #[doc(alias = "KeyRepeatDelay")]
792    pub fn set_key_repeat_delay(&mut self, seconds: f32) {
793        self.0.KeyRepeatDelay = seconds;
794    }
795
796    /// Returns the key repeat rate (seconds).
797    #[doc(alias = "KeyRepeatRate")]
798    pub fn key_repeat_rate(&self) -> f32 {
799        self.0.KeyRepeatRate
800    }
801
802    /// Set the key repeat rate (seconds).
803    #[doc(alias = "KeyRepeatRate")]
804    pub fn set_key_repeat_rate(&mut self, seconds: f32) {
805        self.0.KeyRepeatRate = seconds;
806    }
807
808    /// Returns whether error recovery is enabled.
809    #[doc(alias = "ConfigErrorRecovery")]
810    pub fn config_error_recovery(&self) -> bool {
811        self.0.ConfigErrorRecovery
812    }
813
814    /// Set whether error recovery is enabled.
815    #[doc(alias = "ConfigErrorRecovery")]
816    pub fn set_config_error_recovery(&mut self, enabled: bool) {
817        self.0.ConfigErrorRecovery = enabled;
818    }
819
820    /// Returns whether error recovery enables asserts.
821    #[doc(alias = "ConfigErrorRecoveryEnableAssert")]
822    pub fn config_error_recovery_enable_assert(&self) -> bool {
823        self.0.ConfigErrorRecoveryEnableAssert
824    }
825
826    /// Set whether error recovery enables asserts.
827    #[doc(alias = "ConfigErrorRecoveryEnableAssert")]
828    pub fn set_config_error_recovery_enable_assert(&mut self, enabled: bool) {
829        self.0.ConfigErrorRecoveryEnableAssert = enabled;
830    }
831
832    /// Returns whether error recovery enables debug logs.
833    #[doc(alias = "ConfigErrorRecoveryEnableDebugLog")]
834    pub fn config_error_recovery_enable_debug_log(&self) -> bool {
835        self.0.ConfigErrorRecoveryEnableDebugLog
836    }
837
838    /// Set whether error recovery enables debug logs.
839    #[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    /// Returns whether error recovery enables tooltips.
845    #[doc(alias = "ConfigErrorRecoveryEnableTooltip")]
846    pub fn config_error_recovery_enable_tooltip(&self) -> bool {
847        self.0.ConfigErrorRecoveryEnableTooltip
848    }
849
850    /// Set whether error recovery enables tooltips.
851    #[doc(alias = "ConfigErrorRecoveryEnableTooltip")]
852    pub fn set_config_error_recovery_enable_tooltip(&mut self, enabled: bool) {
853        self.0.ConfigErrorRecoveryEnableTooltip = enabled;
854    }
855
856    /// Returns whether Dear ImGui thinks a debugger is present.
857    #[doc(alias = "ConfigDebugIsDebuggerPresent")]
858    pub fn config_debug_is_debugger_present(&self) -> bool {
859        self.0.ConfigDebugIsDebuggerPresent
860    }
861
862    /// Set whether Dear ImGui thinks a debugger is present.
863    #[doc(alias = "ConfigDebugIsDebuggerPresent")]
864    pub fn set_config_debug_is_debugger_present(&mut self, enabled: bool) {
865        self.0.ConfigDebugIsDebuggerPresent = enabled;
866    }
867
868    /// Returns whether to highlight ID conflicts.
869    #[doc(alias = "ConfigDebugHighlightIdConflicts")]
870    pub fn config_debug_highlight_id_conflicts(&self) -> bool {
871        self.0.ConfigDebugHighlightIdConflicts
872    }
873
874    /// Set whether to highlight ID conflicts.
875    #[doc(alias = "ConfigDebugHighlightIdConflicts")]
876    pub fn set_config_debug_highlight_id_conflicts(&mut self, enabled: bool) {
877        self.0.ConfigDebugHighlightIdConflicts = enabled;
878    }
879
880    /// Returns whether to show the item picker when highlighting ID conflicts.
881    #[doc(alias = "ConfigDebugHighlightIdConflictsShowItemPicker")]
882    pub fn config_debug_highlight_id_conflicts_show_item_picker(&self) -> bool {
883        self.0.ConfigDebugHighlightIdConflictsShowItemPicker
884    }
885
886    /// Set whether to show the item picker when highlighting ID conflicts.
887    #[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    /// Returns whether `Begin()` returns `true` once.
893    #[doc(alias = "ConfigDebugBeginReturnValueOnce")]
894    pub fn config_debug_begin_return_value_once(&self) -> bool {
895        self.0.ConfigDebugBeginReturnValueOnce
896    }
897
898    /// Set whether `Begin()` returns `true` once.
899    #[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    /// Returns whether `Begin()` returns `true` in a loop.
905    #[doc(alias = "ConfigDebugBeginReturnValueLoop")]
906    pub fn config_debug_begin_return_value_loop(&self) -> bool {
907        self.0.ConfigDebugBeginReturnValueLoop
908    }
909
910    /// Set whether `Begin()` returns `true` in a loop.
911    #[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    /// Returns whether to ignore focus loss.
917    #[doc(alias = "ConfigDebugIgnoreFocusLoss")]
918    pub fn config_debug_ignore_focus_loss(&self) -> bool {
919        self.0.ConfigDebugIgnoreFocusLoss
920    }
921
922    /// Set whether to ignore focus loss.
923    #[doc(alias = "ConfigDebugIgnoreFocusLoss")]
924    pub fn set_config_debug_ignore_focus_loss(&mut self, enabled: bool) {
925        self.0.ConfigDebugIgnoreFocusLoss = enabled;
926    }
927
928    /// Returns whether to display ini settings debug tools.
929    #[doc(alias = "ConfigDebugIniSettings")]
930    pub fn config_debug_ini_settings(&self) -> bool {
931        self.0.ConfigDebugIniSettings
932    }
933
934    /// Set whether to display ini settings debug tools.
935    #[doc(alias = "ConfigDebugIniSettings")]
936    pub fn set_config_debug_ini_settings(&mut self, enabled: bool) {
937        self.0.ConfigDebugIniSettings = enabled;
938    }
939
940    /// Returns the backend platform name, if set.
941    ///
942    /// Note: to set this safely, use `Context::set_platform_name()`.
943    #[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    /// Returns the backend renderer name, if set.
950    ///
951    /// Note: to set this safely, use `Context::set_renderer_name()`.
952    #[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    /// Returns the backend platform user data pointer.
959    #[doc(alias = "BackendPlatformUserData")]
960    pub fn backend_platform_user_data(&self) -> *mut c_void {
961        self.0.BackendPlatformUserData
962    }
963
964    /// Set the backend platform user data pointer.
965    #[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    /// Returns the backend renderer user data pointer.
971    #[doc(alias = "BackendRendererUserData")]
972    pub fn backend_renderer_user_data(&self) -> *mut c_void {
973        self.0.BackendRendererUserData
974    }
975
976    /// Set the backend renderer user data pointer.
977    #[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    /// Returns the backend language user data pointer.
983    #[doc(alias = "BackendLanguageUserData")]
984    pub fn backend_language_user_data(&self) -> *mut c_void {
985        self.0.BackendLanguageUserData
986    }
987
988    /// Set the backend language user data pointer.
989    #[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    /// Backend flags
995    pub fn backend_flags(&self) -> BackendFlags {
996        BackendFlags::from_bits_truncate(self.0.BackendFlags)
997    }
998
999    /// Set backend flags
1000    pub fn set_backend_flags(&mut self, flags: BackendFlags) {
1001        self.0.BackendFlags = flags.bits();
1002    }
1003
1004    /// Add a key event to the input queue
1005    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    /// Add a character input event to the input queue
1012    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    /// Add a mouse position event to the input queue
1019    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    /// Add a mouse button event to the input queue
1026    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    /// Add a mouse wheel event to the input queue
1033    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    /// Add a mouse source event to the input queue.
1040    ///
1041    /// When the input source switches between mouse / touch screen / pen,
1042    /// backends should call this before submitting other mouse events for
1043    /// the frame.
1044    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    /// Queue the hovered viewport id for the current frame.
1051    ///
1052    /// When multi-viewport is enabled and the backend can reliably obtain
1053    /// the ImGui viewport hovered by the OS mouse, it should set
1054    /// `BackendFlags::HAS_MOUSE_HOVERED_VIEWPORT` and call this once per
1055    /// frame.
1056    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    /// Notify Dear ImGui that the application window gained or lost focus
1063    /// This mirrors `io.AddFocusEvent()` in Dear ImGui and is used by platform backends.
1064    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    /// Get the global font scale (not available in current Dear ImGui version)
1071    /// Compatibility shim: maps to style.FontScaleMain (Dear ImGui 1.92+)
1072    pub fn font_global_scale(&self) -> f32 {
1073        unsafe { (*sys::igGetStyle()).FontScaleMain }
1074    }
1075
1076    /// Set the global font scale (not available in current Dear ImGui version)
1077    /// Compatibility shim: maps to style.FontScaleMain (Dear ImGui 1.92+)
1078    pub fn set_font_global_scale(&mut self, _scale: f32) {
1079        unsafe {
1080            (*sys::igGetStyle()).FontScaleMain = _scale;
1081        }
1082    }
1083
1084    /// Get the display framebuffer scale
1085    pub fn display_framebuffer_scale(&self) -> [f32; 2] {
1086        let scale = self.0.DisplayFramebufferScale;
1087        [scale.x, scale.y]
1088    }
1089
1090    /// Returns the mouse delta from the previous frame, in pixels.
1091    #[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    /// Returns whether Ctrl modifier is held.
1098    #[doc(alias = "KeyCtrl")]
1099    pub fn key_ctrl(&self) -> bool {
1100        self.0.KeyCtrl
1101    }
1102
1103    /// Returns whether Shift modifier is held.
1104    #[doc(alias = "KeyShift")]
1105    pub fn key_shift(&self) -> bool {
1106        self.0.KeyShift
1107    }
1108
1109    /// Returns whether Alt modifier is held.
1110    #[doc(alias = "KeyAlt")]
1111    pub fn key_alt(&self) -> bool {
1112        self.0.KeyAlt
1113    }
1114
1115    /// Returns whether Super/Command modifier is held.
1116    #[doc(alias = "KeySuper")]
1117    pub fn key_super(&self) -> bool {
1118        self.0.KeySuper
1119    }
1120
1121    /// Returns the current mouse input source.
1122    #[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    /// Returns the viewport id hovered by the OS mouse (if supported by the backend).
1133    #[doc(alias = "MouseHoveredViewport")]
1134    pub fn mouse_hovered_viewport(&self) -> crate::Id {
1135        crate::Id::from(self.0.MouseHoveredViewport)
1136    }
1137
1138    /// Returns whether Ctrl+LeftClick should be treated as RightClick.
1139    #[doc(alias = "MouseCtrlLeftAsRightClick")]
1140    pub fn mouse_ctrl_left_as_right_click(&self) -> bool {
1141        self.0.MouseCtrlLeftAsRightClick
1142    }
1143
1144    /// Set whether Ctrl+LeftClick should be treated as RightClick.
1145    #[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    /// Set the display framebuffer scale
1151    /// This is important for HiDPI displays to ensure proper rendering
1152    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}