mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-10 21:18:36 +00:00
Separate impl block for sdl2
This commit is contained in:
parent
d8644c8eae
commit
ff2ddf00df
31
src/lib.rs
31
src/lib.rs
@ -57,20 +57,6 @@ impl ImGui {
|
||||
let io: &mut ffi::ImGuiIO = unsafe { mem::transmute(ffi::igGetIO()) };
|
||||
io.mouse_draw_cursor = value;
|
||||
}
|
||||
#[cfg(feature = "sdl2")]
|
||||
pub fn update_mouse(&mut self, mouse: &::sdl2::mouse::MouseUtil) {
|
||||
let (mouse_state, mouse_x, mouse_y) = mouse.get_mouse_state();
|
||||
let io: &mut ffi::ImGuiIO = unsafe { mem::transmute(ffi::igGetIO()) };
|
||||
io.mouse_pos.x = mouse_x as f32;
|
||||
io.mouse_pos.y = mouse_y as f32;
|
||||
io.mouse_down = [
|
||||
mouse_state.left(),
|
||||
mouse_state.right(),
|
||||
mouse_state.middle(),
|
||||
mouse_state.x1(),
|
||||
mouse_state.x2()
|
||||
];
|
||||
}
|
||||
pub fn set_mouse_pos(&mut self, x: f32, y: f32) {
|
||||
let io: &mut ffi::ImGuiIO = unsafe { mem::transmute(ffi::igGetIO()) };
|
||||
io.mouse_pos.x = x;
|
||||
@ -103,6 +89,23 @@ impl Drop for ImGui {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "sdl2")]
|
||||
impl ImGui {
|
||||
pub fn update_mouse(&mut self, mouse: &::sdl2::mouse::MouseUtil) {
|
||||
let (mouse_state, mouse_x, mouse_y) = mouse.get_mouse_state();
|
||||
let io: &mut ffi::ImGuiIO = unsafe { mem::transmute(ffi::igGetIO()) };
|
||||
io.mouse_pos.x = mouse_x as f32;
|
||||
io.mouse_pos.y = mouse_y as f32;
|
||||
io.mouse_down = [
|
||||
mouse_state.left(),
|
||||
mouse_state.right(),
|
||||
mouse_state.middle(),
|
||||
mouse_state.x1(),
|
||||
mouse_state.x2()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DrawList<'a> {
|
||||
pub cmd_buffer: &'a [ffi::ImDrawCmd],
|
||||
pub idx_buffer: &'a [ffi::ImDrawIdx],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user