Handle new FontGlyph bitfields

This commit is contained in:
Joonas Javanainen 2020-04-24 23:36:59 +03:00
parent 41ac160bd8
commit f93389178b
No known key found for this signature in database
GPG Key ID: D39CCA5CB19B9179

View File

@ -5,7 +5,7 @@ use crate::sys;
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(C)]
pub struct FontGlyph {
pub codepoint: u16,
bitfields: u32,
pub advance_x: f32,
pub x0: f32,
pub y0: f32,
@ -17,6 +17,21 @@ pub struct FontGlyph {
pub v1: f32,
}
impl FontGlyph {
pub fn codepoint(&self) -> u32 {
unsafe { self.raw().Codepoint() }
}
pub fn set_codepoint(&mut self, codepoint: u32) {
unsafe { self.raw_mut().set_Codepoint(codepoint) };
}
pub fn visible(&self) -> bool {
unsafe { self.raw().Visible() != 0 }
}
pub fn set_visible(&mut self, visible: bool) {
unsafe { self.raw_mut().set_Visible(visible as u32) }
}
}
unsafe impl RawCast<sys::ImFontGlyph> for FontGlyph {}
#[test]
@ -37,7 +52,7 @@ fn test_font_glyph_memory_layout() {
assert_eq!(offset_of!(FontGlyph, $l), offset_of!(ImFontGlyph, $r));
};
};
assert_field_offset!(codepoint, Codepoint);
assert_field_offset!(bitfields, _bitfield_1);
assert_field_offset!(advance_x, AdvanceX);
assert_field_offset!(x0, X0);
assert_field_offset!(y0, Y0);