Struct bevy_window::WindowResolution
source · 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§
source§impl WindowResolution
impl WindowResolution
sourcepub fn new(logical_width: f32, logical_height: f32) -> Self
pub fn new(logical_width: f32, logical_height: f32) -> Self
Creates a new WindowResolution
.
sourcepub fn with_scale_factor_override(self, scale_factor_override: f64) -> Self
pub fn with_scale_factor_override(self, scale_factor_override: f64) -> Self
Builder method for adding a scale factor override to the resolution.
sourcepub fn physical_width(&self) -> u32
pub fn physical_width(&self) -> u32
The window’s client area width in physical pixels.
sourcepub fn physical_height(&self) -> u32
pub fn physical_height(&self) -> u32
The window’s client area height in physical pixels.
sourcepub 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
sourcepub 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
.
sourcepub 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.
sourcepub 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
.
sourcepub 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.
sourcepub 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§
source§impl Clone for WindowResolution
impl Clone for WindowResolution
source§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 moresource§impl Debug for WindowResolution
impl Debug for WindowResolution
source§impl Default for WindowResolution
impl Default for WindowResolution
source§impl<I> From<[I; 2]> for WindowResolutionwhere
I: Into<f32>,
impl<I> From<[I; 2]> for WindowResolutionwhere I: Into<f32>,
source§fn from([width, height]: [I; 2]) -> WindowResolution
fn from([width, height]: [I; 2]) -> WindowResolution
source§impl<I> From<(I, I)> for WindowResolutionwhere
I: Into<f32>,
impl<I> From<(I, I)> for WindowResolutionwhere I: Into<f32>,
source§fn from((width, height): (I, I)) -> WindowResolution
fn from((width, height): (I, I)) -> WindowResolution
source§impl From<DVec2> for WindowResolution
impl From<DVec2> for WindowResolution
source§fn from(res: DVec2) -> WindowResolution
fn from(res: DVec2) -> WindowResolution
source§impl From<Vec2> for WindowResolution
impl From<Vec2> for WindowResolution
source§fn from(res: Vec2) -> WindowResolution
fn from(res: Vec2) -> WindowResolution
source§impl FromReflect for WindowResolutionwhere
u32: FromReflect,
Option<f64>: FromReflect,
f64: FromReflect,
impl FromReflect for WindowResolutionwhere u32: FromReflect, Option<f64>: FromReflect, f64: FromReflect,
source§fn from_reflect(reflect: &dyn Reflect) -> Option<Self>
fn from_reflect(reflect: &dyn Reflect) -> Option<Self>
Self
from a reflected value.source§impl GetTypeRegistration for WindowResolutionwhere
u32: Reflect,
Option<f64>: Reflect,
f64: Reflect,
impl GetTypeRegistration for WindowResolutionwhere u32: Reflect, Option<f64>: Reflect, f64: Reflect,
source§impl PartialEq<WindowResolution> for WindowResolution
impl PartialEq<WindowResolution> for WindowResolution
source§fn eq(&self, other: &WindowResolution) -> bool
fn eq(&self, other: &WindowResolution) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Reflect for WindowResolutionwhere
u32: Reflect,
Option<f64>: Reflect,
f64: Reflect,
impl Reflect for WindowResolutionwhere u32: Reflect, Option<f64>: Reflect, f64: Reflect,
source§fn get_type_info(&self) -> &'static TypeInfo
fn get_type_info(&self) -> &'static TypeInfo
source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
&mut dyn Any
.source§fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
source§fn as_reflect(&self) -> &dyn Reflect
fn as_reflect(&self) -> &dyn Reflect
source§fn as_reflect_mut(&mut self) -> &mut dyn Reflect
fn as_reflect_mut(&mut self) -> &mut dyn Reflect
source§fn clone_value(&self) -> Box<dyn Reflect>
fn clone_value(&self) -> Box<dyn Reflect>
Reflect
trait object. Read moresource§fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
source§fn reflect_owned(self: Box<Self>) -> ReflectOwned
fn reflect_owned(self: Box<Self>) -> ReflectOwned
source§fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
source§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
source§fn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
source§impl Struct for WindowResolutionwhere
u32: Reflect,
Option<f64>: Reflect,
f64: Reflect,
impl Struct for WindowResolutionwhere u32: Reflect, Option<f64>: Reflect, f64: Reflect,
source§fn field(&self, name: &str) -> Option<&dyn Reflect>
fn field(&self, name: &str) -> Option<&dyn Reflect>
name
as a &dyn Reflect
.source§fn field_mut(&mut self, name: &str) -> Option<&mut dyn Reflect>
fn field_mut(&mut self, name: &str) -> Option<&mut dyn Reflect>
name
as a
&mut dyn Reflect
.source§fn field_at(&self, index: usize) -> Option<&dyn Reflect>
fn field_at(&self, index: usize) -> Option<&dyn Reflect>
index
as a
&dyn Reflect
.source§fn field_at_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>
fn field_at_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>
index
as a &mut dyn Reflect
.source§fn name_at(&self, index: usize) -> Option<&str>
fn name_at(&self, index: usize) -> Option<&str>
index
.source§fn iter_fields(&self) -> FieldIter<'_>
fn iter_fields(&self) -> FieldIter<'_>
source§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> 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.source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere T: Default,
source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given Worldsource§impl<S> GetField for Swhere
S: Struct,
impl<S> GetField for Swhere S: Struct,
source§impl<T> GetPath for Twhere
T: Reflect,
impl<T> GetPath for Twhere T: Reflect,
source§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 moresource§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