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