Some documentation fixes, added test for ImVec2 -> ImRange conversion

This commit is contained in:
4bb4 2021-04-19 12:00:25 +02:00
parent f2a4c6a3d8
commit 465e81d7f9
3 changed files with 8 additions and 2 deletions

View file

@ -4,7 +4,7 @@
// just for linking for tests // just for linking for tests
#[cfg(test)] #[cfg(test)]
use imgui_sys as _; use imgui_sys;
use std::ops::Range; use std::ops::Range;
include!("bindings.rs"); include!("bindings.rs");
@ -65,5 +65,10 @@ mod tests {
let im_range: ImPlotRange = tuple.clone().into(); let im_range: ImPlotRange = tuple.clone().into();
assert_eq!(im_range.Min, tuple.0); assert_eq!(im_range.Min, tuple.0);
assert_eq!(im_range.Max, tuple.1); assert_eq!(im_range.Max, tuple.1);
let imvec = imgui_sys::ImVec2::new(33.0, 55.0);
let im_range: ImPlotRange = imvec.clone().into();
assert_eq!(im_range.Min, imvec.x as f64);
assert_eq!(im_range.Max, imvec.y as f64);
} }
} }

View file

@ -20,6 +20,7 @@ pub struct Context {
// This mutex is used to guard any accesses to the context // This mutex is used to guard any accesses to the context
static CTX_MUTEX: ReentrantMutex<()> = parking_lot::const_reentrant_mutex(()); static CTX_MUTEX: ReentrantMutex<()> = parking_lot::const_reentrant_mutex(());
/// Check if there is no current context defined by calling into the C++ API
fn no_current_context() -> bool { fn no_current_context() -> bool {
let ctx = unsafe { sys::ImPlot_GetCurrentContext() }; let ctx = unsafe { sys::ImPlot_GetCurrentContext() };
ctx.is_null() ctx.is_null()

View file

@ -181,7 +181,7 @@ impl Plot {
} }
/// Sets the plot size, given as [size_x, size_y]. Units are the same as /// Sets the plot size, given as [size_x, size_y]. Units are the same as
/// what imgui uses. TODO(4b4) ... which is? I'm not sure it's pixels /// what imgui uses. TODO(4bb4) ... which is? I'm not sure it's pixels
#[inline] #[inline]
pub fn size(mut self, size: [f32; 2]) -> Self { pub fn size(mut self, size: [f32; 2]) -> Self {
self.size = size; self.size = size;