diff --git a/imgui/Cargo.toml b/imgui/Cargo.toml index 57eccef..31d614d 100644 --- a/imgui/Cargo.toml +++ b/imgui/Cargo.toml @@ -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"] diff --git a/imgui/src/context.rs b/imgui/src/context.rs index aa9cdd2..22e0d63 100644 --- a/imgui/src/context.rs +++ b/imgui/src/context.rs @@ -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 {