mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-24 03:48:30 +00:00
init effort
This commit is contained in:
parent
04af6ab69a
commit
52e08bd09a
@ -527,6 +527,7 @@ impl Context {
|
|||||||
Ui {
|
Ui {
|
||||||
ctx: self,
|
ctx: self,
|
||||||
font_atlas,
|
font_atlas,
|
||||||
|
buffer: RefCell::new(Vec::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,6 +120,7 @@ impl Context {
|
|||||||
pub struct Ui<'ui> {
|
pub struct Ui<'ui> {
|
||||||
ctx: &'ui Context,
|
ctx: &'ui Context,
|
||||||
font_atlas: Option<cell::RefMut<'ui, SharedFontAtlas>>,
|
font_atlas: Option<cell::RefMut<'ui, SharedFontAtlas>>,
|
||||||
|
buffer: cell::RefCell<Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ui> Ui<'ui> {
|
impl<'ui> Ui<'ui> {
|
||||||
|
|||||||
@ -38,13 +38,27 @@ impl<'ui> Ui<'ui> {
|
|||||||
}
|
}
|
||||||
/// Renders text wrapped to the end of window (or column)
|
/// Renders text wrapped to the end of window (or column)
|
||||||
#[doc(alias = "TextWrapperd")]
|
#[doc(alias = "TextWrapperd")]
|
||||||
pub fn text_wrapped(&self, text: &ImStr) {
|
pub fn text_wrapped(&self, text: impl AsRef<str>) {
|
||||||
unsafe { sys::igTextWrapped(fmt_ptr(), text.as_ptr()) }
|
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
|
/// Render a text + label combination aligned the same way as value+label widgets
|
||||||
#[doc(alias = "LabelText")]
|
#[doc(alias = "LabelText")]
|
||||||
pub fn label_text(&self, label: &ImStr, text: &ImStr) {
|
pub fn label_text(&self, label: impl AsRef<str>, text: impl AsRef<str>) {
|
||||||
unsafe { sys::igLabelText(label.as_ptr(), fmt_ptr(), text.as_ptr()) }
|
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
|
/// Renders text with a little bullet aligned to the typical tree node
|
||||||
#[doc(alias = "BulletText")]
|
#[doc(alias = "BulletText")]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user