Skip to main content

Window

Trait Window 

Source
pub trait Window: Send + Sync {
    // Required methods
    fn set_title(&self, title: &str);
    fn inner_size(&self) -> Vec2;
    fn scale_factor(&self) -> f32;
    fn request_redraw(&self);
    fn set_cursor_visible(&self, visible: bool);
    fn as_any(&self) -> &(dyn Any + 'static);
}
Expand description

Platform-independent window interface.

Provides core window operations that application code typically needs: setting the title, querying dimensions, requesting redraws, etc.

§Backend Access

For advanced use cases (e.g., UI framework integration), the underlying platform window can be accessed via as_any and downcasting:

// When using the winit backend:
if let Some(winit_window) = window.as_any().downcast_ref::<winit::window::Window>() {
    // Access winit-specific APIs
}

Required Methods§

Source

fn set_title(&self, title: &str)

Sets the window title.

Source

fn inner_size(&self) -> Vec2

Returns the window’s inner (client area) size in physical pixels.

Source

fn scale_factor(&self) -> f32

Returns the display scale factor (DPI scaling).

Source

fn request_redraw(&self)

Requests the window to redraw.

Source

fn set_cursor_visible(&self, visible: bool)

Shows or hides the mouse cursor.

Source

fn as_any(&self) -> &(dyn Any + 'static)

Returns the underlying platform window as Any for downcasting.

This enables advanced users to access platform-specific APIs without coupling the core engine to any particular windowing backend.

Implementations on Foreign Types§

Source§

impl Window for Window

Source§

fn set_title(&self, title: &str)

Source§

fn inner_size(&self) -> Vec2

Source§

fn scale_factor(&self) -> f32

Source§

fn request_redraw(&self)

Source§

fn set_cursor_visible(&self, visible: bool)

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Implementors§