Skip to main content

dear_imgui_rs/utils/
general.rs

1use super::counts::non_negative_count_from_i32;
2use crate::sys;
3
4impl crate::ui::Ui {
5    /// Get global imgui time. Incremented by io.DeltaTime every frame.
6    #[doc(alias = "GetTime")]
7    pub fn time(&self) -> f64 {
8        self.run_with_bound_context(|| unsafe { sys::igGetTime() })
9    }
10
11    /// Get global imgui frame count. Incremented by 1 every frame.
12    #[doc(alias = "GetFrameCount")]
13    pub fn frame_count(&self) -> usize {
14        non_negative_count_from_i32(
15            "Ui::frame_count()",
16            self.run_with_bound_context(|| unsafe { sys::igGetFrameCount() }),
17        )
18    }
19
20    /// Returns the width of an item based on the current layout state.
21    #[doc(alias = "CalcItemWidth")]
22    pub fn calc_item_width(&self) -> f32 {
23        self.run_with_bound_context(|| unsafe { sys::igCalcItemWidth() })
24    }
25}