pub struct WinitPlatform { /* private fields */ }Expand description
Main platform backend for Dear ImGui with winit integration
Implementations§
Source§impl WinitPlatform
impl WinitPlatform
Sourcepub fn new(imgui_ctx: &mut Context) -> Self
pub fn new(imgui_ctx: &mut Context) -> Self
Create a new winit platform backend
§Example
use dear_imgui_rs::Context;
use dear_imgui_winit::WinitPlatform;
let mut imgui_ctx = Context::create();
let mut platform = WinitPlatform::new(&mut imgui_ctx);Sourcepub fn set_hidpi_mode(&mut self, hidpi_mode: HiDpiMode)
pub fn set_hidpi_mode(&mut self, hidpi_mode: HiDpiMode)
Set the DPI scaling mode
Sourcepub fn set_ime_allowed(&mut self, window: &Window, allowed: bool)
pub fn set_ime_allowed(&mut self, window: &Window, allowed: bool)
Enable or disable IME events for the attached window.
Winit does not deliver WindowEvent::Ime events unless IME is explicitly
allowed on the window. When ime_auto_manage is enabled (default), the
backend will override this based on io.want_text_input() every frame.
Use this helper for immediate overrides (e.g. when auto-management is
disabled or you want to force a specific state for a while).
Sourcepub fn ime_enabled(&self) -> bool
pub fn ime_enabled(&self) -> bool
Returns whether IME is currently allowed for the attached window.
This reflects the last state set via set_ime_allowed or IME
WindowEvent::Ime(Enabled/Disabled) notifications.
Sourcepub fn set_ime_auto_management(&mut self, enabled: bool)
pub fn set_ime_auto_management(&mut self, enabled: bool)
Enable or disable automatic IME management.
When enabled (default), the backend will call set_ime_allowed based on
Dear ImGui’s io.want_text_input() flag each frame, turning IME on
while text widgets are active and off otherwise. When disabled, IME
state is left entirely under application control.
Sourcepub fn hidpi_factor(&self) -> f64
pub fn hidpi_factor(&self) -> f64
Get the current DPI scaling factor
Sourcepub fn attach_window(
&mut self,
window: &Window,
hidpi_mode: HiDpiMode,
imgui_ctx: &mut Context,
)
pub fn attach_window( &mut self, window: &Window, hidpi_mode: HiDpiMode, imgui_ctx: &mut Context, )
Attach the platform to a window
Sourcepub fn detach_window(&mut self, window: &Window, imgui_ctx: &mut Context)
pub fn detach_window(&mut self, window: &Window, imgui_ctx: &mut Context)
Detach the platform from a window and clear winit-owned IME hooks.
Call this before destroying a window when the Dear ImGui context will outlive it. The
method only clears the IME callback/userdata pair if it is still owned by this backend and
still points at window.
Sourcepub fn handle_event<T>(
&mut self,
imgui_ctx: &mut Context,
window: &Window,
event: &Event<T>,
) -> bool
pub fn handle_event<T>( &mut self, imgui_ctx: &mut Context, window: &Window, event: &Event<T>, ) -> bool
Handle a winit event.
This is the most general entry point: pass the full Event<T> from
your event loop and the backend will dispatch to the appropriate
handlers. For ApplicationHandler::window_event, where you already
receive a WindowEvent for a specific window, you can use
handle_window_event instead and avoid constructing a synthetic
Event::WindowEvent.
Sourcepub fn handle_window_event(
&mut self,
imgui_ctx: &mut Context,
window: &Window,
event: &WindowEvent,
) -> bool
pub fn handle_window_event( &mut self, imgui_ctx: &mut Context, window: &Window, event: &WindowEvent, ) -> bool
Handle a single window event for a given window.
This is a convenience wrapper for frameworks that already route
window-local events, such as winit’s ApplicationHandler::window_event,
and don’t need to build a full Event::WindowEvent value.
Sourcepub fn prepare_render(&mut self, imgui_ctx: &mut Context, window: &Window)
pub fn prepare_render(&mut self, imgui_ctx: &mut Context, window: &Window)
Prepare for rendering - should be called before Dear ImGui rendering
Sourcepub fn prepare_frame(&mut self, window: &Window, imgui_ctx: &mut Context)
pub fn prepare_frame(&mut self, window: &Window, imgui_ctx: &mut Context)
Prepare frame - alias for prepare_render for compatibility
Sourcepub fn set_software_cursor_enabled(
&mut self,
imgui_ctx: &mut Context,
enabled: bool,
)
pub fn set_software_cursor_enabled( &mut self, imgui_ctx: &mut Context, enabled: bool, )
Toggle Dear ImGui software-drawn cursor. When enabled, the OS cursor is hidden and ImGui draws the cursor in draw data.
Sourcepub fn prepare_render_with_ui(&mut self, ui: &Ui, window: &Window)
pub fn prepare_render_with_ui(&mut self, ui: &Ui, window: &Window)
Update cursor given a Ui reference (preferred, matches upstream)
Sourcepub fn scale_size_from_winit(
&self,
window: &Window,
logical_size: LogicalSize<f64>,
) -> LogicalSize<f64>
pub fn scale_size_from_winit( &self, window: &Window, logical_size: LogicalSize<f64>, ) -> LogicalSize<f64>
Scale a logical size from winit to our active HiDPI mode
Sourcepub fn scale_pos_from_winit(
&self,
window: &Window,
logical_pos: LogicalPosition<f64>,
) -> LogicalPosition<f64>
pub fn scale_pos_from_winit( &self, window: &Window, logical_pos: LogicalPosition<f64>, ) -> LogicalPosition<f64>
Scale a logical position from winit to our active HiDPI mode
Sourcepub fn scale_pos_for_winit(
&self,
window: &Window,
logical_pos: LogicalPosition<f64>,
) -> LogicalPosition<f64>
pub fn scale_pos_for_winit( &self, window: &Window, logical_pos: LogicalPosition<f64>, ) -> LogicalPosition<f64>
Scale a logical position for winit based on our active HiDPI mode
Sourcepub fn create_window_attributes() -> WindowAttributes
pub fn create_window_attributes() -> WindowAttributes
Create window attributes with Dear ImGui defaults
Auto Trait Implementations§
impl Freeze for WinitPlatform
impl RefUnwindSafe for WinitPlatform
impl Send for WinitPlatform
impl Sync for WinitPlatform
impl Unpin for WinitPlatform
impl UnsafeUnpin for WinitPlatform
impl UnwindSafe for WinitPlatform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.