Fixed build errors with docking feature

This commit is contained in:
Robin 2022-12-21 21:21:57 +01:00
parent 2d9efba59b
commit 0cb64e8b59
6 changed files with 62 additions and 16 deletions

View File

@ -142,7 +142,7 @@ impl<'ui> DrawListMut<'ui> {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "docking")] { if #[cfg(feature = "docking")] {
// Has extra overload in docking branch // Has extra overload in docking branch
sys::igGetBackgroundDrawListNil() sys::igGetBackgroundDrawList_Nil()
} else { } else {
sys::igGetBackgroundDrawList() sys::igGetBackgroundDrawList()
} }
@ -161,7 +161,7 @@ impl<'ui> DrawListMut<'ui> {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "docking")] { if #[cfg(feature = "docking")] {
// Has extra overload in docking branch // Has extra overload in docking branch
sys::igGetForegroundDrawListNil() sys::igGetForegroundDrawList_Nil()
} else { } else {
sys::igGetForegroundDrawList() sys::igGetForegroundDrawList()
} }

View File

@ -345,7 +345,13 @@ impl Ui {
#[inline] #[inline]
#[doc(alias = "IsKeyDown")] #[doc(alias = "IsKeyDown")]
pub fn is_key_index_down(&self, key_index: u32) -> bool { pub fn is_key_index_down(&self, key_index: u32) -> bool {
unsafe { sys::igIsKeyDown(key_index) } cfg_if::cfg_if!{
if #[cfg(feature = "docking")] {
unsafe { sys::igIsKeyDown_Nil(key_index) }
} else {
unsafe { sys::igIsKeyDown(key_index) }
}
}
} }
/// Returns true if the key was pressed (went from !down to down). /// Returns true if the key was pressed (went from !down to down).
@ -365,7 +371,13 @@ impl Ui {
#[inline] #[inline]
#[doc(alias = "IsKeyPressed")] #[doc(alias = "IsKeyPressed")]
pub fn is_key_index_pressed(&self, key_index: u32) -> bool { pub fn is_key_index_pressed(&self, key_index: u32) -> bool {
unsafe { sys::igIsKeyPressed(key_index, true) } cfg_if::cfg_if!{
if #[cfg(feature = "docking")] {
unsafe { sys::igIsKeyPressed_Bool(key_index, true) }
} else {
unsafe { sys::igIsKeyPressed(key_index, true) }
}
}
} }
/// Returns true if the key was pressed (went from !down to down). /// Returns true if the key was pressed (went from !down to down).
@ -386,7 +398,13 @@ impl Ui {
#[inline] #[inline]
#[doc(alias = "IsKeyPressed")] #[doc(alias = "IsKeyPressed")]
pub fn is_key_index_pressed_no_repeat(&self, key_index: u32) -> bool { pub fn is_key_index_pressed_no_repeat(&self, key_index: u32) -> bool {
unsafe { sys::igIsKeyPressed(key_index, false) } cfg_if::cfg_if!{
if #[cfg(feature = "docking")] {
unsafe { sys::igIsKeyPressed_Bool(key_index, false) }
} else {
unsafe { sys::igIsKeyPressed(key_index, false) }
}
}
} }
/// Returns true if the key was released (went from down to !down) /// Returns true if the key was released (went from down to !down)
@ -404,7 +422,13 @@ impl Ui {
#[inline] #[inline]
#[doc(alias = "IsKeyReleased")] #[doc(alias = "IsKeyReleased")]
pub fn is_key_index_released(&self, key_index: u32) -> bool { pub fn is_key_index_released(&self, key_index: u32) -> bool {
unsafe { sys::igIsKeyReleased(key_index) } cfg_if::cfg_if!{
if #[cfg(feature = "docking")] {
unsafe { sys::igIsKeyReleased_Nil(key_index) }
} else {
unsafe { sys::igIsKeyReleased(key_index) }
}
}
} }
/// Returns a count of key presses using the given repeat rate/delay settings. /// Returns a count of key presses using the given repeat rate/delay settings.

View File

@ -95,7 +95,13 @@ impl Ui {
/// Equivalent to indexing the Io struct with the button, e.g. `ui.io()[button]`. /// Equivalent to indexing the Io struct with the button, e.g. `ui.io()[button]`.
#[doc(alias = "IsMouseDown")] #[doc(alias = "IsMouseDown")]
pub fn is_mouse_down(&self, button: MouseButton) -> bool { pub fn is_mouse_down(&self, button: MouseButton) -> bool {
unsafe { sys::igIsMouseDown(button as i32) } cfg_if::cfg_if!{
if #[cfg(feature = "docking")] {
unsafe { sys::igIsMouseDown_Nil(button as i32) }
} else {
unsafe { sys::igIsMouseDown(button as i32) }
}
}
} }
/// Returns true if any mouse button is held down /// Returns true if any mouse button is held down
#[doc(alias = "IsAnyMouseDown")] #[doc(alias = "IsAnyMouseDown")]
@ -105,7 +111,13 @@ impl Ui {
/// Returns true if the given mouse button was clicked (went from !down to down) /// Returns true if the given mouse button was clicked (went from !down to down)
#[doc(alias = "IsMouseClicked")] #[doc(alias = "IsMouseClicked")]
pub fn is_mouse_clicked(&self, button: MouseButton) -> bool { pub fn is_mouse_clicked(&self, button: MouseButton) -> bool {
unsafe { sys::igIsMouseClicked(button as i32, false) } cfg_if::cfg_if!{
if #[cfg(feature = "docking")] {
unsafe { sys::igIsMouseClicked_Bool(button as i32, false) }
} else {
unsafe { sys::igIsMouseClicked(button as i32, false) }
}
}
} }
/// Returns true if the given mouse button was double-clicked /// Returns true if the given mouse button was double-clicked
#[doc(alias = "IsMouseDoubleClicked")] #[doc(alias = "IsMouseDoubleClicked")]
@ -115,7 +127,13 @@ impl Ui {
/// Returns true if the given mouse button was released (went from down to !down) /// Returns true if the given mouse button was released (went from down to !down)
#[doc(alias = "IsMouseReleased")] #[doc(alias = "IsMouseReleased")]
pub fn is_mouse_released(&self, button: MouseButton) -> bool { pub fn is_mouse_released(&self, button: MouseButton) -> bool {
unsafe { sys::igIsMouseReleased(button as i32) } cfg_if::cfg_if!{
if #[cfg(feature = "docking")] {
unsafe { sys::igIsMouseReleased_Nil(button as i32) }
} else {
unsafe { sys::igIsMouseReleased(button as i32) }
}
}
} }
/// Returns true if the mouse is currently dragging with the given mouse button held down /// Returns true if the mouse is currently dragging with the given mouse button held down
#[doc(alias = "IsMouseDragging")] #[doc(alias = "IsMouseDragging")]

View File

@ -188,7 +188,7 @@ pub struct Io {
#[cfg(feature = "docking")] #[cfg(feature = "docking")]
pub config_viewports_no_auto_merge: bool, pub config_viewports_no_auto_merge: bool,
#[cfg(feature = "docking")] #[cfg(feature = "docking")]
pub config_viewports_notask_bar_icon: bool, pub config_viewports_no_task_bar_icon: bool,
#[cfg(feature = "docking")] #[cfg(feature = "docking")]
pub config_viewports_no_decoration: bool, pub config_viewports_no_decoration: bool,
#[cfg(feature = "docking")] #[cfg(feature = "docking")]
@ -312,6 +312,8 @@ pub struct Io {
/// Most users don't have a mouse with a horizontal wheel, and may not be filled by all /// Most users don't have a mouse with a horizontal wheel, and may not be filled by all
/// backends. /// backends.
pub mouse_wheel_h: f32, pub mouse_wheel_h: f32,
#[cfg(feature = "docking")]
mouse_hovered_viewport: sys::ImGuiID,
/// Keyboard modifier pressed: Control /// Keyboard modifier pressed: Control
pub key_ctrl: bool, pub key_ctrl: bool,
/// Keyboard modifier pressed: Shift /// Keyboard modifier pressed: Shift
@ -337,6 +339,8 @@ pub struct Io {
mouse_down_owned_unless_popup_close: [bool; 5], mouse_down_owned_unless_popup_close: [bool; 5],
mouse_down_duration: [f32; 5], mouse_down_duration: [f32; 5],
mouse_down_duration_prev: [f32; 5], mouse_down_duration_prev: [f32; 5],
#[cfg(feature = "docking")]
mouse_drag_max_distance_abs: [sys::ImVec2; 5],
mouse_drag_max_distance_sqr: [f32; 5], mouse_drag_max_distance_sqr: [f32; 5],
pen_pressure: f32, pen_pressure: f32,

View File

@ -629,7 +629,7 @@ impl Ui {
// imgui uses utf8...though that is a continuous process there. // imgui uses utf8...though that is a continuous process there.
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "docking")] { if #[cfg(feature = "docking")] {
CStr::from_ptr(sys::igTableGetColumnNameInt(-1)) CStr::from_ptr(sys::igTableGetColumnName_Int(-1))
.to_str() .to_str()
.unwrap() .unwrap()
} else { } else {
@ -650,7 +650,7 @@ impl Ui {
// imgui uses utf8...though that is a continuous process there. // imgui uses utf8...though that is a continuous process there.
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature="docking")] { if #[cfg(feature="docking")] {
CStr::from_ptr(sys::igTableGetColumnNameInt(column as i32)) CStr::from_ptr(sys::igTableGetColumnName_Int(column as i32))
.to_str() .to_str()
.unwrap() .unwrap()
} else { } else {

View File

@ -37,7 +37,7 @@ impl<'ui> Ui {
unsafe { unsafe {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "docking")] { if #[cfg(feature = "docking")] {
sys::igSetScrollXFloat(scroll_x); sys::igSetScrollX_Float(scroll_x);
} else { } else {
sys::igSetScrollX(scroll_x); sys::igSetScrollX(scroll_x);
} }
@ -50,7 +50,7 @@ impl<'ui> Ui {
unsafe { unsafe {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "docking")] { if #[cfg(feature = "docking")] {
sys::igSetScrollYFloat(scroll_y); sys::igSetScrollY_Float(scroll_y);
} else { } else {
sys::igSetScrollY(scroll_y); sys::igSetScrollY(scroll_y);
} }
@ -113,7 +113,7 @@ impl<'ui> Ui {
unsafe { unsafe {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "docking")] { if #[cfg(feature = "docking")] {
sys::igSetScrollFromPosXFloat(local_x, center_x_ratio) sys::igSetScrollFromPosX_Float(local_x, center_x_ratio)
} else { } else {
sys::igSetScrollFromPosX(local_x, center_x_ratio) sys::igSetScrollFromPosX(local_x, center_x_ratio)
} }
@ -140,7 +140,7 @@ impl<'ui> Ui {
unsafe { unsafe {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "docking")] { if #[cfg(feature = "docking")] {
sys::igSetScrollFromPosYFloat(local_y, center_y_ratio); sys::igSetScrollFromPosY_Float(local_y, center_y_ratio);
} else { } else {
sys::igSetScrollFromPosY(local_y, center_y_ratio); sys::igSetScrollFromPosY(local_y, center_y_ratio);
} }