Skip to main content

dear_imgui_rs/utils/
window.rs

1use super::focus::{FocusedFlags, validate_focused_flags};
2use super::hover_flags::{WindowHoveredFlags, validate_window_hovered_flags};
3use crate::sys;
4
5impl crate::ui::Ui {
6    /// Returns `true` if the current window is hovered (and typically: not blocked by a popup/modal)
7    #[doc(alias = "IsWindowHovered")]
8    pub fn is_window_hovered(&self) -> bool {
9        unsafe { sys::igIsWindowHovered(WindowHoveredFlags::NONE.bits()) }
10    }
11
12    /// Returns `true` if the current window is hovered based on the given flags
13    #[doc(alias = "IsWindowHovered")]
14    pub fn is_window_hovered_with_flags(&self, flags: WindowHoveredFlags) -> bool {
15        validate_window_hovered_flags("Ui::is_window_hovered_with_flags()", flags);
16        unsafe { sys::igIsWindowHovered(flags.bits()) }
17    }
18
19    /// Returns `true` if the current window is focused (and typically: not blocked by a popup/modal)
20    #[doc(alias = "IsWindowFocused")]
21    pub fn is_window_focused(&self) -> bool {
22        self.is_window_focused_with_flags(FocusedFlags::NONE)
23    }
24
25    /// Returns `true` if the current window is focused based on the given flags
26    #[doc(alias = "IsWindowFocused")]
27    pub fn is_window_focused_with_flags(&self, flags: FocusedFlags) -> bool {
28        validate_focused_flags("Ui::is_window_focused_with_flags()", flags);
29        unsafe { sys::igIsWindowFocused(flags.bits()) }
30    }
31
32    /// Returns `true` if the current window is appearing this frame.
33    #[doc(alias = "IsWindowAppearing")]
34    pub fn is_window_appearing(&self) -> bool {
35        unsafe { sys::igIsWindowAppearing() }
36    }
37
38    /// Returns `true` if the current window is collapsed.
39    #[doc(alias = "IsWindowCollapsed")]
40    pub fn is_window_collapsed(&self) -> bool {
41        unsafe { sys::igIsWindowCollapsed() }
42    }
43}