pub struct Viewport { /* private fields */ }Expand description
The rendering viewport — physical dimensions and DPI scale factor.
Physical pixels = logical pixels × scale_factor.
Used by:
- Layout engine: viewport units (
vw,vh,vmin,vmax) - Style resolution:
ResolveContextgetsviewport_width/viewport_height - Media queries:
@media (min-width: ...)
Implementations§
Source§impl Viewport
impl Viewport
Sourcepub fn new(width: u32, height: u32, scale_factor: f64) -> Self
pub fn new(width: u32, height: u32, scale_factor: f64) -> Self
Create a viewport with the given dimensions and scale factor.
Sourcepub fn scale_factor(&self) -> f64
pub fn scale_factor(&self) -> f64
DPI scale factor.
Sourcepub fn logical_width(&self) -> f64
pub fn logical_width(&self) -> f64
Width in logical (CSS-like) pixels.
This is what layout uses for viewport units.
Sourcepub fn logical_height(&self) -> f64
pub fn logical_height(&self) -> f64
Height in logical (CSS-like) pixels.
Sourcepub fn set_scale_factor(&mut self, factor: f64)
pub fn set_scale_factor(&mut self, factor: f64)
Update the DPI scale factor.
Trait Implementations§
impl Copy for Viewport
Auto Trait Implementations§
impl Freeze for Viewport
impl RefUnwindSafe for Viewport
impl Send for Viewport
impl Sync for Viewport
impl Unpin for Viewport
impl UnsafeUnpin for Viewport
impl UnwindSafe for Viewport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert