From 8f636f805789c6307580aebc7192fc4852e843dc Mon Sep 17 00:00:00 2001 From: Jonathan Spira Date: Wed, 2 Oct 2024 00:38:05 -0400 Subject: [PATCH] returned the platform io func on the docking branch --- imgui/Cargo.toml | 1 + imgui/src/context.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) 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 {