dear_imgui_rs/window/
content_region.rs

1//! Content region helpers
2//!
3//! Query the available region inside the current window, excluding decorations
4//! such as title bars and scrollbars. Handy for adaptive sizing.
5//!
6use crate::Ui;
7use crate::sys;
8
9impl Ui {
10    /// Returns the size of the content region available for widgets
11    ///
12    /// This is the size of the window minus decorations (title bar, scrollbars, etc.)
13    #[doc(alias = "GetContentRegionAvail")]
14    pub fn content_region_avail(&self) -> [f32; 2] {
15        let size = unsafe { sys::igGetContentRegionAvail() };
16        [size.x, size.y]
17    }
18
19    /// Returns the width of the content region available for widgets
20    ///
21    /// This is equivalent to `content_region_avail()[0]`
22    pub fn content_region_avail_width(&self) -> f32 {
23        self.content_region_avail()[0]
24    }
25
26    /// Returns the height of the content region available for widgets
27    ///
28    /// This is equivalent to `content_region_avail()[1]`
29    pub fn content_region_avail_height(&self) -> f32 {
30        self.content_region_avail()[1]
31    }
32}