1#![allow(non_upper_case_globals)]
30#![allow(non_camel_case_types)]
31#![allow(non_snake_case)]
32#![allow(dead_code)]
33#![allow(unnecessary_transmutes)]
34#![allow(clippy::all)]
35#![allow(unpredictable_function_pointer_comparisons)]
38
39mod ffi;
42pub use ffi::*;
43
44const _: [(); 4] = [(); std::mem::size_of::<ImWchar>()];
46
47pub use ImColor as Color;
56pub use ImVec2 as Vector2;
57pub use ImVec4 as Vector4;
58
59pub const IMGUI_VERSION: &str = env!("CARGO_PKG_VERSION");
61
62pub const HAS_DOCKING: bool = true;
64
65#[cfg(feature = "freetype")]
67pub const HAS_FREETYPE: bool = true;
68
69#[cfg(not(feature = "freetype"))]
70pub const HAS_FREETYPE: bool = false;
71
72#[cfg(feature = "wasm")]
74pub const HAS_WASM: bool = true;
75
76#[cfg(not(feature = "wasm"))]
77pub const HAS_WASM: bool = false;
78
79impl ImVec2 {
82 #[inline]
83 pub const fn new(x: f32, y: f32) -> ImVec2 {
84 ImVec2 { x, y }
85 }
86
87 #[inline]
88 pub const fn zero() -> ImVec2 {
89 ImVec2 { x: 0.0, y: 0.0 }
90 }
91}
92
93impl From<[f32; 2]> for ImVec2 {
94 #[inline]
95 fn from(array: [f32; 2]) -> ImVec2 {
96 ImVec2::new(array[0], array[1])
97 }
98}
99
100impl From<(f32, f32)> for ImVec2 {
101 #[inline]
102 fn from((x, y): (f32, f32)) -> ImVec2 {
103 ImVec2::new(x, y)
104 }
105}
106
107impl From<ImVec2> for [f32; 2] {
108 #[inline]
109 fn from(v: ImVec2) -> [f32; 2] {
110 [v.x, v.y]
111 }
112}
113
114impl From<ImVec2> for (f32, f32) {
115 #[inline]
116 fn from(v: ImVec2) -> (f32, f32) {
117 (v.x, v.y)
118 }
119}
120
121impl From<mint::Vector2<f32>> for ImVec2 {
122 #[inline]
123 fn from(v: mint::Vector2<f32>) -> ImVec2 {
124 ImVec2::new(v.x, v.y)
125 }
126}
127
128#[cfg(feature = "glam")]
129impl From<glam::Vec2> for ImVec2 {
130 #[inline]
131 fn from(v: glam::Vec2) -> ImVec2 {
132 ImVec2::new(v.x, v.y)
133 }
134}
135
136impl ImVec4 {
137 #[inline]
138 pub const fn new(x: f32, y: f32, z: f32, w: f32) -> ImVec4 {
139 ImVec4 { x, y, z, w }
140 }
141
142 #[inline]
143 pub const fn zero() -> ImVec4 {
144 ImVec4 {
145 x: 0.0,
146 y: 0.0,
147 z: 0.0,
148 w: 0.0,
149 }
150 }
151}
152
153impl From<[f32; 4]> for ImVec4 {
154 #[inline]
155 fn from(array: [f32; 4]) -> ImVec4 {
156 ImVec4::new(array[0], array[1], array[2], array[3])
157 }
158}
159
160impl From<(f32, f32, f32, f32)> for ImVec4 {
161 #[inline]
162 fn from((x, y, z, w): (f32, f32, f32, f32)) -> ImVec4 {
163 ImVec4::new(x, y, z, w)
164 }
165}
166
167impl From<ImVec4> for [f32; 4] {
168 #[inline]
169 fn from(v: ImVec4) -> [f32; 4] {
170 [v.x, v.y, v.z, v.w]
171 }
172}
173
174impl From<ImVec4> for (f32, f32, f32, f32) {
175 #[inline]
176 fn from(v: ImVec4) -> (f32, f32, f32, f32) {
177 (v.x, v.y, v.z, v.w)
178 }
179}
180
181impl From<mint::Vector4<f32>> for ImVec4 {
182 #[inline]
183 fn from(v: mint::Vector4<f32>) -> ImVec4 {
184 ImVec4::new(v.x, v.y, v.z, v.w)
185 }
186}
187
188#[cfg(feature = "glam")]
189impl From<glam::Vec4> for ImVec4 {
190 #[inline]
191 fn from(v: glam::Vec4) -> ImVec4 {
192 ImVec4::new(v.x, v.y, v.z, v.w)
193 }
194}