Skip to main content

dear_imgui_rs/widget/misc/
basic.rs

1use crate::Ui;
2use crate::sys;
3
4impl Ui {
5    /// Creates a bullet point
6    #[doc(alias = "Bullet")]
7    pub fn bullet(&self) {
8        self.run_with_bound_context(|| unsafe {
9            sys::igBullet();
10        });
11    }
12
13    /// Creates a bullet point with text
14    #[doc(alias = "BulletText")]
15    pub fn bullet_text(&self, text: impl AsRef<str>) {
16        let text_ptr = self.scratch_txt(text);
17        self.run_with_bound_context(|| unsafe {
18            // Always treat the value as unformatted user text.
19            const FMT: &[u8; 3] = b"%s\0";
20            sys::igBulletText(FMT.as_ptr() as *const std::os::raw::c_char, text_ptr);
21        });
22    }
23}
24
25impl Ui {
26    /// Creates a small button
27    #[doc(alias = "SmallButton")]
28    pub fn small_button(&self, label: impl AsRef<str>) -> bool {
29        let label_ptr = self.scratch_txt(label);
30        self.run_with_bound_context(|| unsafe { sys::igSmallButton(label_ptr) })
31    }
32}