returned the platform io func on the docking branch

This commit is contained in:
Jonathan Spira 2024-10-02 00:38:05 -04:00
parent 17986be68a
commit 8f636f8057
2 changed files with 18 additions and 0 deletions

View File

@ -23,6 +23,7 @@ parking_lot = "0.12"
cfg-if = "1"
[features]
default = ["docking"]
wasm = ["imgui-sys/wasm"]
freetype = ["imgui-sys/freetype"]
docking = ["imgui-sys/docking"]

View File

@ -610,6 +610,23 @@ impl Context {
#[cfg(feature = "docking")]
impl Context {
/// Returns an immutable reference to the Context's [`PlatformIo`](crate::PlatformIo) object.
pub fn platform_io(&self) -> &crate::PlatformIo {
unsafe {
// safe because PlatformIo is a transparent wrapper around sys::ImGuiPlatformIO
// and &self ensures we have shared ownership of PlatformIo.
&*(sys::igGetPlatformIO() as *const crate::PlatformIo)
}
}
/// Returns a mutable reference to the Context's [`PlatformIo`](crate::PlatformIo) object.
pub fn platform_io_mut(&mut self) -> &mut crate::PlatformIo {
unsafe {
// safe because PlatformIo is a transparent wrapper around sys::ImGuiPlatformIO
// and &mut self ensures exclusive ownership of PlatformIo.
&mut *(sys::igGetPlatformIO() as *mut crate::PlatformIo)
}
}
/// Returns an immutable reference to the main [`Viewport`](crate::Viewport)
pub fn main_viewport(&self) -> &crate::Viewport {
unsafe {