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§
Sourcefn inner_size(&self) -> Vec2
fn inner_size(&self) -> Vec2
Returns the window’s inner (client area) size in physical pixels.
Sourcefn scale_factor(&self) -> f32
fn scale_factor(&self) -> f32
Returns the display scale factor (DPI scaling).
Sourcefn request_redraw(&self)
fn request_redraw(&self)
Requests the window to redraw.
Sourcefn set_cursor_visible(&self, visible: bool)
fn set_cursor_visible(&self, visible: bool)
Shows or hides the mouse cursor.