Struct bevy::window::WindowResolution
pub struct WindowResolution { /* private fields */ }
Expand description
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§
§impl WindowResolution
impl WindowResolution
pub fn new(logical_width: f32, logical_height: f32) -> WindowResolution
pub fn new(logical_width: f32, logical_height: f32) -> WindowResolution
Creates a new WindowResolution
.
pub fn with_scale_factor_override(
self,
scale_factor_override: f64
) -> WindowResolution
pub fn with_scale_factor_override( self, scale_factor_override: f64 ) -> WindowResolution
Builder method for adding a scale factor override to the resolution.
pub fn physical_width(&self) -> u32
pub fn physical_width(&self) -> u32
The window’s client area width in physical pixels.
pub fn physical_height(&self) -> u32
pub fn physical_height(&self) -> u32
The window’s client area height in physical pixels.
pub fn scale_factor(&self) -> f64
pub fn scale_factor(&self) -> f64
The ratio of physical pixels to logical pixels
physical_pixels = logical_pixels * scale_factor
pub fn base_scale_factor(&self) -> f64
pub fn base_scale_factor(&self) -> f64
The window scale factor as reported by the window backend.
This value is unaffected by WindowResolution::scale_factor_override
.
pub fn scale_factor_override(&self) -> Option<f64>
pub fn scale_factor_override(&self) -> Option<f64>
The scale factor set with WindowResolution::set_scale_factor_override
.
This value may be different from the scale factor reported by the window backend.
pub fn set_physical_resolution(&mut self, width: u32, height: u32)
pub fn set_physical_resolution(&mut self, width: u32, height: u32)
Set the window’s physical resolution.
This will ignore the scale factor setting, so most of the time you should
prefer to use WindowResolution::set
.
pub fn set_scale_factor(&mut self, scale_factor: f64)
pub fn set_scale_factor(&mut self, scale_factor: f64)
Set the window’s scale factor, this may get overridden by the backend.
pub fn set_scale_factor_override(&mut self, scale_factor_override: Option<f64>)
pub fn set_scale_factor_override(&mut self, scale_factor_override: Option<f64>)
Set the window’s scale factor, this will be used over what the backend decides.
Trait Implementations§
§impl Clone for WindowResolution
impl Clone for WindowResolution
§fn clone(&self) -> WindowResolution
fn clone(&self) -> WindowResolution
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for WindowResolution
impl Debug for WindowResolution
§impl Default for WindowResolution
impl Default for WindowResolution
§fn default() -> WindowResolution
fn default() -> WindowResolution
§impl<I> From<[I; 2]> for WindowResolutionwhere
I: Into<f32>,
impl<I> From<[I; 2]> for WindowResolutionwhere I: Into<f32>,
§fn from(_: [I; 2]) -> WindowResolution
fn from(_: [I; 2]) -> WindowResolution
§impl<I> From<(I, I)> for WindowResolutionwhere
I: Into<f32>,
impl<I> From<(I, I)> for WindowResolutionwhere I: Into<f32>,
§fn from(_: (I, I)) -> WindowResolution
fn from(_: (I, I)) -> WindowResolution
§impl From<DVec2> for WindowResolution
impl From<DVec2> for WindowResolution
§fn from(res: DVec2) -> WindowResolution
fn from(res: DVec2) -> WindowResolution
§impl From<Vec2> for WindowResolution
impl From<Vec2> for WindowResolution
§fn from(res: Vec2) -> WindowResolution
fn from(res: Vec2) -> WindowResolution
§impl FromReflect for WindowResolutionwhere
u32: FromReflect,
Option<f64>: FromReflect,
f64: FromReflect,
impl FromReflect for WindowResolutionwhere u32: FromReflect, Option<f64>: FromReflect, f64: FromReflect,
§fn from_reflect(reflect: &(dyn Reflect + 'static)) -> Option<WindowResolution>
fn from_reflect(reflect: &(dyn Reflect + 'static)) -> Option<WindowResolution>
Self
from a reflected value.§impl GetTypeRegistration for WindowResolutionwhere
u32: Reflect,
Option<f64>: Reflect,
f64: Reflect,
impl GetTypeRegistration for WindowResolutionwhere u32: Reflect, Option<f64>: Reflect, f64: Reflect,
§impl PartialEq<WindowResolution> for WindowResolution
impl PartialEq<WindowResolution> for WindowResolution
§fn eq(&self, other: &WindowResolution) -> bool
fn eq(&self, other: &WindowResolution) -> bool
self
and other
values to be equal, and is used
by ==
.§impl Reflect for WindowResolutionwhere
u32: Reflect,
Option<f64>: Reflect,
f64: Reflect,
impl Reflect for WindowResolutionwhere u32: Reflect, Option<f64>: Reflect, f64: Reflect,
§fn get_type_info(&self) -> &'static TypeInfo
fn get_type_info(&self) -> &'static TypeInfo
§fn into_any(
self: Box<WindowResolution, Global>
) -> Box<dyn Any + 'static, Global>
fn into_any( self: Box<WindowResolution, Global> ) -> Box<dyn Any + 'static, Global>
Box<dyn Any>
.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut dyn Any
.§fn into_reflect(
self: Box<WindowResolution, Global>
) -> Box<dyn Reflect + 'static, Global>
fn into_reflect( self: Box<WindowResolution, Global> ) -> Box<dyn Reflect + 'static, Global>
§fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
§fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
§fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
Reflect
trait object. Read more§fn set(
&mut self,
value: Box<dyn Reflect + 'static, Global>
) -> Result<(), Box<dyn Reflect + 'static, Global>>
fn set( &mut self, value: Box<dyn Reflect + 'static, Global> ) -> Result<(), Box<dyn Reflect + 'static, Global>>
§fn apply(&mut self, value: &(dyn Reflect + 'static))
fn apply(&mut self, value: &(dyn Reflect + 'static))
§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
§fn reflect_owned(self: Box<WindowResolution, Global>) -> ReflectOwned
fn reflect_owned(self: Box<WindowResolution, Global>) -> ReflectOwned
§fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
§fn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
§impl Struct for WindowResolutionwhere
u32: Reflect,
Option<f64>: Reflect,
f64: Reflect,
impl Struct for WindowResolutionwhere u32: Reflect, Option<f64>: Reflect, f64: Reflect,
§fn field(&self, name: &str) -> Option<&(dyn Reflect + 'static)>
fn field(&self, name: &str) -> Option<&(dyn Reflect + 'static)>
name
as a &dyn Reflect
.§fn field_mut(&mut self, name: &str) -> Option<&mut (dyn Reflect + 'static)>
fn field_mut(&mut self, name: &str) -> Option<&mut (dyn Reflect + 'static)>
name
as a
&mut dyn Reflect
.§fn field_at(&self, index: usize) -> Option<&(dyn Reflect + 'static)>
fn field_at(&self, index: usize) -> Option<&(dyn Reflect + 'static)>
index
as a
&dyn Reflect
.§fn field_at_mut(&mut self, index: usize) -> Option<&mut (dyn Reflect + 'static)>
fn field_at_mut(&mut self, index: usize) -> Option<&mut (dyn Reflect + 'static)>
index
as a &mut dyn Reflect
.§fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn iter_fields(&self) -> FieldIter<'_> ⓘ
§fn clone_dynamic(&self) -> DynamicStruct
fn clone_dynamic(&self) -> DynamicStruct
DynamicStruct
.impl StructuralPartialEq for WindowResolution
Auto Trait Implementations§
impl RefUnwindSafe for WindowResolution
impl Send for WindowResolution
impl Sync for WindowResolution
impl Unpin for WindowResolution
impl UnwindSafe for WindowResolution
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§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.§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.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World§impl<T> GetPath for Twhere
T: Reflect,
impl<T> GetPath for Twhere T: Reflect,
§fn reflect_path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
fn reflect_path<'r, 'p>( &'r self, path: &'p str ) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read more§fn reflect_path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn reflect_path_mut<'r, 'p>( &'r mut self, path: &'p str ) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read more