1#![allow(non_upper_case_globals)]
29#![allow(non_camel_case_types)]
30#![allow(non_snake_case)]
31#![allow(dead_code)]
32#![allow(unnecessary_transmutes)]
33#![allow(unsafe_op_in_unsafe_fn)]
34#![allow(clippy::all)]
35#![allow(unpredictable_function_pointer_comparisons)]
36
37pub use dear_imgui_sys::{
39 ImDrawData, ImDrawList, ImFontAtlas, ImGuiCond, ImGuiContext, ImGuiDragDropFlags, ImGuiIO,
40 ImGuiMouseButton, ImGuiStyle, ImTextureID, ImVec2, ImVec4,
41};
42
43include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
45
46#[cfg(all(feature = "native-test-probe", not(target_arch = "wasm32")))]
47#[doc(hidden)]
48pub mod native_test_probe {
49 unsafe extern "C" {
50 pub fn dear_implot_rectangle_probe_plot(
51 plot_context: *mut super::ImPlotContext,
52 kind: std::ffi::c_int,
53 invert_x: bool,
54 invert_y: bool,
55 bounds: *mut f32,
56 ) -> std::ffi::c_int;
57 pub fn dear_implot_line_probe_plot(
58 plot_context: *mut super::ImPlotContext,
59 weight: f32,
60 pixel_density: f32,
61 anti_aliased: bool,
62 alpha: f32,
63 positions: *mut f32,
64 uvs: *mut f32,
65 expected_uvs: *mut f32,
66 expected_width: *mut f32,
67 colors: *mut u32,
68 expected_color: *mut u32,
69 ) -> std::ffi::c_int;
70 }
71}
72
73use std::ops::Range;
79
80impl From<Range<f64>> for ImPlotRange {
81 fn from(from: Range<f64>) -> Self {
82 ImPlotRange {
83 Min: from.start,
84 Max: from.end,
85 }
86 }
87}
88
89impl From<[f64; 2]> for ImPlotRange {
90 fn from(from: [f64; 2]) -> Self {
91 ImPlotRange {
92 Min: from[0],
93 Max: from[1],
94 }
95 }
96}
97
98impl From<(f64, f64)> for ImPlotRange {
99 fn from(from: (f64, f64)) -> Self {
100 ImPlotRange {
101 Min: from.0,
102 Max: from.1,
103 }
104 }
105}
106
107impl From<ImVec2> for ImPlotRange {
108 fn from(from: ImVec2) -> Self {
109 ImPlotRange {
110 Min: from.x as f64,
111 Max: from.y as f64,
112 }
113 }
114}
115
116#[cfg(test)]
117mod tests {
118 use super::*;
119
120 #[test]
121 fn test_implot_range_conversions() {
122 let range1: ImPlotRange = (0.0..10.0).into();
123 assert_eq!(range1.Min, 0.0);
124 assert_eq!(range1.Max, 10.0);
125
126 let range2: ImPlotRange = [1.0, 5.0].into();
127 assert_eq!(range2.Min, 1.0);
128 assert_eq!(range2.Max, 5.0);
129
130 let range3: ImPlotRange = (2.0, 8.0).into();
131 assert_eq!(range3.Min, 2.0);
132 assert_eq!(range3.Max, 8.0);
133 }
134}