From 465e81d7f978c0de63bb9b84a85851cfebc0edd8 Mon Sep 17 00:00:00 2001 From: 4bb4 <67376761+4bb4@users.noreply.github.com> Date: Mon, 19 Apr 2021 12:00:25 +0200 Subject: [PATCH] Some documentation fixes, added test for ImVec2 -> ImRange conversion --- implot-sys/src/lib.rs | 7 ++++++- src/context.rs | 1 + src/plot.rs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/implot-sys/src/lib.rs b/implot-sys/src/lib.rs index cbca664..02c16fc 100644 --- a/implot-sys/src/lib.rs +++ b/implot-sys/src/lib.rs @@ -4,7 +4,7 @@ // just for linking for tests #[cfg(test)] -use imgui_sys as _; +use imgui_sys; use std::ops::Range; include!("bindings.rs"); @@ -65,5 +65,10 @@ mod tests { let im_range: ImPlotRange = tuple.clone().into(); assert_eq!(im_range.Min, tuple.0); 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); } } diff --git a/src/context.rs b/src/context.rs index b0ef496..1e3d833 100644 --- a/src/context.rs +++ b/src/context.rs @@ -20,6 +20,7 @@ pub struct Context { // This mutex is used to guard any accesses to the context 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 { let ctx = unsafe { sys::ImPlot_GetCurrentContext() }; ctx.is_null() diff --git a/src/plot.rs b/src/plot.rs index 3e28aea..5c6c311 100644 --- a/src/plot.rs +++ b/src/plot.rs @@ -181,7 +181,7 @@ impl Plot { } /// 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] pub fn size(mut self, size: [f32; 2]) -> Self { self.size = size;