mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-15 15:38:28 +00:00
Remove unnecessary casts
On all currently supported platforms c_float = f32, c_int = i32
This commit is contained in:
parent
b523fe9fb9
commit
9a37676580
10
src/lib.rs
10
src/lib.rs
@ -118,7 +118,7 @@ impl ImGui {
|
||||
}
|
||||
pub fn mouse_pos(&self) -> (f32, f32) {
|
||||
let io: &mut ffi::ImGuiIO = unsafe { mem::transmute(ffi::igGetIO()) };
|
||||
(io.mouse_pos.x as f32, io.mouse_pos.y as f32)
|
||||
(io.mouse_pos.x, io.mouse_pos.y)
|
||||
}
|
||||
pub fn set_mouse_pos(&mut self, x: f32, y: f32) {
|
||||
let io: &mut ffi::ImGuiIO = unsafe { mem::transmute(ffi::igGetIO()) };
|
||||
@ -129,8 +129,8 @@ impl ImGui {
|
||||
let io: &mut ffi::ImGuiIO = unsafe { mem::transmute(ffi::igGetIO()) };
|
||||
io.mouse_down = *states;
|
||||
}
|
||||
pub fn get_time(&self) -> f32 { unsafe { ffi::igGetTime() as f32 } }
|
||||
pub fn get_frame_count(&self) -> i32 { unsafe { ffi::igGetFrameCount() as i32 } }
|
||||
pub fn get_time(&self) -> f32 { unsafe { ffi::igGetTime() } }
|
||||
pub fn get_frame_count(&self) -> i32 { unsafe { ffi::igGetFrameCount() } }
|
||||
pub fn frame<'fr, 'a: 'fr>(&'a mut self, width: u32, height: u32, delta_time: f32) -> Frame<'fr> {
|
||||
unsafe {
|
||||
let io: &mut ffi::ImGuiIO = mem::transmute(ffi::igGetIO());
|
||||
@ -234,12 +234,12 @@ impl<'fr> Frame<'fr> {
|
||||
pub fn separator(&self) { unsafe { ffi::igSeparator() }; }
|
||||
pub fn same_line(&self, pos_x: f32) {
|
||||
unsafe {
|
||||
ffi::igSameLine(pos_x as c_float, -1.0f32 as c_float)
|
||||
ffi::igSameLine(pos_x, -1.0f32)
|
||||
}
|
||||
}
|
||||
pub fn same_line_spacing(&self, pos_x: f32, spacing_w: f32) {
|
||||
unsafe {
|
||||
ffi::igSameLine(pos_x as c_float, spacing_w as c_float)
|
||||
ffi::igSameLine(pos_x, spacing_w)
|
||||
}
|
||||
}
|
||||
pub fn spacing(&self) { unsafe { ffi::igSpacing() }; }
|
||||
|
||||
@ -34,16 +34,15 @@ impl<'fr, 'p> SliderInt<'fr, 'p> {
|
||||
}
|
||||
}
|
||||
pub fn build(self) -> Option<i32> {
|
||||
let mut value = self.value as c_int;
|
||||
let mut value = self.value;
|
||||
let changed = unsafe {
|
||||
ffi::igSliderInt(self.label.as_ptr(),
|
||||
&mut value,
|
||||
self.min as c_int,
|
||||
self.max as c_int,
|
||||
self.min, self.max,
|
||||
self.display_format.as_ptr()
|
||||
)
|
||||
};
|
||||
if changed { Some(value as i32) } else { None }
|
||||
if changed { Some(value) } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,17 +83,16 @@ impl<'fr, 'p> SliderFloat<'fr, 'p> {
|
||||
}
|
||||
}
|
||||
pub fn build(self) -> Option<f32> {
|
||||
let mut value = self.value as c_float;
|
||||
let mut value = self.value;
|
||||
let changed = unsafe {
|
||||
ffi::igSliderFloat(self.label.as_ptr(),
|
||||
&mut value,
|
||||
self.min as c_float,
|
||||
self.max as c_float,
|
||||
self.min, self.max,
|
||||
self.display_format.as_ptr(),
|
||||
self.power as c_float
|
||||
self.power
|
||||
)
|
||||
};
|
||||
if changed { Some(value as f32) } else { None }
|
||||
if changed { Some(value) } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -171,7 +171,7 @@ impl<'fr, 'p> Window<'fr, 'p> {
|
||||
}
|
||||
ffi::igBegin2(self.name.as_ptr(),
|
||||
if self.closable { &mut opened } else { ptr::null_mut() },
|
||||
ImVec2::new(0.0, 0.0), self.bg_alpha as c_float, self.flags
|
||||
ImVec2::new(0.0, 0.0), self.bg_alpha, self.flags
|
||||
)
|
||||
};
|
||||
if render {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user