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        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("Ui::frame_count()", unsafe { sys::igGetFrameCount() })
15    }
16
17    /// Returns the width of an item based on the current layout state.
18    #[doc(alias = "CalcItemWidth")]
19    pub fn calc_item_width(&self) -> f32 {
20        unsafe { sys::igCalcItemWidth() }
21    }
22}