Struct bevy_window::Window [−][src]
pub struct Window { /* fields omitted */ }
Expand description
An operating system window that can present content and receive user input.
Window Sizes
There are three sizes associated with a window. The physical size which is the height and width in physical pixels on the monitor. The logical size which is the physical size scaled by an operating system provided factor to account for monitors with differing pixel densities or user preference. And the requested size, measured in logical pixels, which is the value submitted to the API when creating the window, or requesting that it be resized.
The actual size, in logical pixels, of the window may not match the requested size due to operating system limits on the window size, or the quantization of the logical size when converting the physical size to the logical size through the scaling factor.
Implementations
pub fn new(
id: WindowId,
window_descriptor: &WindowDescriptor,
physical_width: u32,
physical_height: u32,
scale_factor: f64,
position: Option<IVec2>,
raw_window_handle: RawWindowHandle
) -> Self
The requested window client area width in logical pixels from window creation or the last call to set_resolution.
This may differ from the actual width depending on OS size limits and the scaling factor for high DPI monitors.
The requested window client area height in logical pixels from window creation or the last call to set_resolution.
This may differ from the actual width depending on OS size limits and the scaling factor for high DPI monitors.
The window’s client area width in physical pixels.
The window’s client area height in physical pixels.
The window’s client resize constraint in logical pixels.
Sets the window to minimized or back.
Platform-specific
- iOS / Android / Web: Unsupported.
- Wayland: Un-minimize is unsupported.
Modifies the position of the window in physical pixels.
Note that the top-left hand corner of the desktop is not necessarily the same as the screen. If the user uses a desktop with multiple monitors, the top-left hand corner of the desktop is the top-left hand corner of the monitor at the top-left of the desktop. This automatically un-maximizes the window if it’s maximized.
Platform-specific
- iOS: Can only be called on the main thread. Sets the top left coordinates of the window in the screen space coordinate system.
- Web: Sets the top-left coordinates relative to the viewport.
- Android / Wayland: Unsupported.
Modifies the minimum and maximum window bounds for resizing in logical pixels.
Request the OS to resize the window such the the client area matches the specified width and height.
Override the os-reported scaling factor
The ratio of physical pixels to logical pixels
physical_pixels = logical_pixels * scale_factor
The window scale factor as reported by the window backend. This value is unaffected by scale_factor_override.
The current mouse position, in physical pixels.
The current mouse position, in logical pixels, taking into account the screen scale factor.
pub fn update_cursor_physical_position_from_backend(
&mut self,
cursor_position: Option<DVec2>
)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Window
impl UnwindSafe for Window
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: 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
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub 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. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more