mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-12 05:58:35 +00:00
init effort
This commit is contained in:
parent
04af6ab69a
commit
52e08bd09a
@ -527,6 +527,7 @@ impl Context {
|
||||
Ui {
|
||||
ctx: self,
|
||||
font_atlas,
|
||||
buffer: RefCell::new(Vec::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,6 +120,7 @@ impl Context {
|
||||
pub struct Ui<'ui> {
|
||||
ctx: &'ui Context,
|
||||
font_atlas: Option<cell::RefMut<'ui, SharedFontAtlas>>,
|
||||
buffer: cell::RefCell<Vec<u8>>,
|
||||
}
|
||||
|
||||
impl<'ui> Ui<'ui> {
|
||||
|
||||
@ -38,13 +38,27 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
/// Renders text wrapped to the end of window (or column)
|
||||
#[doc(alias = "TextWrapperd")]
|
||||
pub fn text_wrapped(&self, text: &ImStr) {
|
||||
unsafe { sys::igTextWrapped(fmt_ptr(), text.as_ptr()) }
|
||||
pub fn text_wrapped(&self, text: impl AsRef<str>) {
|
||||
let mut handle = self.buffer.borrow_mut();
|
||||
handle.clear();
|
||||
handle.extend(text.as_ref().as_bytes());
|
||||
handle.push(b'\0');
|
||||
unsafe { sys::igTextWrapped(fmt_ptr(), handle.as_ptr()) }
|
||||
}
|
||||
/// Render a text + label combination aligned the same way as value+label widgets
|
||||
#[doc(alias = "LabelText")]
|
||||
pub fn label_text(&self, label: &ImStr, text: &ImStr) {
|
||||
unsafe { sys::igLabelText(label.as_ptr(), fmt_ptr(), text.as_ptr()) }
|
||||
pub fn label_text(&self, label: impl AsRef<str>, text: impl AsRef<str>) {
|
||||
let mut handle = self.buffer.borrow_mut();
|
||||
handle.clear();
|
||||
handle.extend(label.as_ref().as_bytes());
|
||||
handle.push(b'\0');
|
||||
handle.extend(text.as_ref().as_bytes());
|
||||
handle.push(b'\0');
|
||||
|
||||
let ptr_one = handle.as_ptr();
|
||||
let ptr_two = unsafe { ptr_one.add(text.as_ref().len() + 1) };
|
||||
|
||||
unsafe { sys::igLabelText(ptr_one as *const _, fmt_ptr(), ptr_two as *const _) }
|
||||
}
|
||||
/// Renders text with a little bullet aligned to the typical tree node
|
||||
#[doc(alias = "BulletText")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user