mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-12 05:58:35 +00:00
window_draw_list: Use generic to add_text
This change allows to use `add_text` with any type that implements `AsRef<str>`. This includes `String`, `&str`, `ImString` and `&ImStr`.
This commit is contained in:
parent
429073a29c
commit
485c8a230e
@ -210,11 +210,13 @@ impl<'ui> WindowDrawList<'ui> {
|
||||
}
|
||||
|
||||
/// Draw a text whose upper-left corner is at point `pos`.
|
||||
pub fn add_text<P, C>(&self, pos: P, col: C, text: &str)
|
||||
pub fn add_text<P, C, T>(&self, pos: P, col: C, text: T)
|
||||
where
|
||||
P: Into<ImVec2>,
|
||||
C: Into<ImColor>,
|
||||
T: AsRef<str>,
|
||||
{
|
||||
let text = text.as_ref();
|
||||
unsafe {
|
||||
let start = text.as_ptr() as *const i8;
|
||||
let end = (start as usize + text.len()) as *const i8;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user