Skip to main content

WinitPlatform

Struct WinitPlatform 

Source
pub struct WinitPlatform { /* private fields */ }
Expand description

Main platform backend for Dear ImGui with winit integration

Implementations§

Source§

impl WinitPlatform

Source

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);
Source

pub fn set_hidpi_mode(&mut self, hidpi_mode: HiDpiMode)

Set the DPI scaling mode

Source

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).

Source

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.

Source

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.

Source

pub fn hidpi_factor(&self) -> f64

Get the current DPI scaling factor

Source

pub fn attach_window( &mut self, window: &Window, hidpi_mode: HiDpiMode, imgui_ctx: &mut Context, )

Attach the platform to a window

Source

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.

Source

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.

Source

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.

Source

pub fn prepare_render(&mut self, imgui_ctx: &mut Context, window: &Window)

Prepare for rendering - should be called before Dear ImGui rendering

Source

pub fn prepare_frame(&mut self, window: &Window, imgui_ctx: &mut Context)

Prepare frame - alias for prepare_render for compatibility

Source

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.

Source

pub fn prepare_render_with_ui(&mut self, ui: &Ui, window: &Window)

Update cursor given a Ui reference (preferred, matches upstream)

Source

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

Source

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

Source

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

Source

pub fn create_window_attributes() -> WindowAttributes

Create window attributes with Dear ImGui defaults

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more