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