1#![allow(non_upper_case_globals)]
25#![allow(non_camel_case_types)]
26#![allow(non_snake_case)]
27#![allow(dead_code)]
28#![allow(unnecessary_transmutes)]
29#![allow(unsafe_op_in_unsafe_fn)]
30#![allow(clippy::all)]
31#![allow(unpredictable_function_pointer_comparisons)]
32
33pub use dear_imgui_sys::{
35 ImDrawData, ImDrawList, ImFontAtlas, ImGuiCond, ImGuiContext, ImGuiDragDropFlags, ImGuiIO,
36 ImGuiMouseButton, ImGuiStyle, ImTextureID, ImVec2, ImVec4,
37};
38
39include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
41
42use std::ops::Range;
48
49impl From<Range<f64>> for ImPlotRange {
50 fn from(from: Range<f64>) -> Self {
51 ImPlotRange {
52 Min: from.start,
53 Max: from.end,
54 }
55 }
56}
57
58impl From<[f64; 2]> for ImPlotRange {
59 fn from(from: [f64; 2]) -> Self {
60 ImPlotRange {
61 Min: from[0],
62 Max: from[1],
63 }
64 }
65}
66
67impl From<(f64, f64)> for ImPlotRange {
68 fn from(from: (f64, f64)) -> Self {
69 ImPlotRange {
70 Min: from.0,
71 Max: from.1,
72 }
73 }
74}
75
76impl From<ImVec2> for ImPlotRange {
77 fn from(from: ImVec2) -> Self {
78 ImPlotRange {
79 Min: from.x as f64,
80 Max: from.y as f64,
81 }
82 }
83}
84
85#[cfg(test)]
86mod tests {
87 use super::*;
88
89 #[test]
90 fn test_implot_range_conversions() {
91 let range1: ImPlotRange = (0.0..10.0).into();
92 assert_eq!(range1.Min, 0.0);
93 assert_eq!(range1.Max, 10.0);
94
95 let range2: ImPlotRange = [1.0, 5.0].into();
96 assert_eq!(range2.Min, 1.0);
97 assert_eq!(range2.Max, 5.0);
98
99 let range3: ImPlotRange = (2.0, 8.0).into();
100 assert_eq!(range3.Min, 2.0);
101 assert_eq!(range3.Max, 8.0);
102 }
103}