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        unsafe {
16            let mut size = sys::ImVec2 { x: 0.0, y: 0.0 };
17            sys::igGetContentRegionAvail(&mut size);
18            [size.x, size.y]
19        }
20    }
21
22    /// Returns the width of the content region available for widgets
23    ///
24    /// This is equivalent to `content_region_avail()[0]`
25    pub fn content_region_avail_width(&self) -> f32 {
26        self.content_region_avail()[0]
27    }
28
29    /// Returns the height of the content region available for widgets
30    ///
31    /// This is equivalent to `content_region_avail()[1]`
32    pub fn content_region_avail_height(&self) -> f32 {
33        self.content_region_avail()[1]
34    }
35}