Merge pull request #125 from malikolivier/draw_list_add_methods

window_draw_list: Add support for drawing text
This commit is contained in:
Malik Olivier Boussejra 2018-06-02 19:48:50 +09:00 committed by GitHub
commit f0b3010684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,6 +209,23 @@ impl<'ui> WindowDrawList<'ui> {
Circle::new(self, center, radius, color)
}
/// Draw a text whose upper-left corner is at point `pos`.
pub fn add_text<P, C, T>(&self, pos: P, col: C, text: T)
where
P: Into<ImVec2>,
C: Into<ImColor>,
T: AsRef<str>,
{
use std::os::raw::c_char;
let text = text.as_ref();
unsafe {
let start = text.as_ptr() as *const c_char;
let end = (start as usize + text.len()) as *const c_char;
sys::ImDrawList_AddText(self.draw_list, pos.into(), col.into().into(), start, end)
}
}
/// Returns a Bezier curve stretching from `pos0` to `pos1`, whose
/// curvature is defined by `cp0` and `cp1`.
pub fn add_bezier_curve<P1, P2, P3, P4, C>(