pub struct WindowMetricsHandle { /* private fields */ }Expand description
A cloneable handle for reading a window’s metrics without borrowing it.
The snapshot it reads is published by the window, so a handle can be held by an entity or moved to a background task and read at any time, without the window being borrowed and without a round trip through the UI thread.
Implementations§
Source§impl WindowMetricsHandle
impl WindowMetricsHandle
Sourcepub fn snapshot(&self) -> Arc<WindowMetrics> ⓘ
pub fn snapshot(&self) -> Arc<WindowMetrics> ⓘ
The snapshot all of the accessors below read from.
Reading one snapshot rather than several keeps the values consistent with each other, since a frame may publish a new one in between.
Sourcepub fn bounds(&self) -> Bounds<Pixels>
pub fn bounds(&self) -> Bounds<Pixels>
The window’s bounds in the global coordinate space, which can span displays.
Sourcepub fn viewport(&self) -> Bounds<Pixels>
pub fn viewport(&self) -> Bounds<Pixels>
The visible viewport in window-local logical pixels.
Unlike Self::content_size, this can shrink or move when a software
keyboard opens.
Sourcepub fn content_size(&self) -> Size<Pixels>
pub fn content_size(&self) -> Size<Pixels>
The size of the drawable area, which is the window’s full layout size.
Sourcepub fn scale_factor(&self) -> f32
pub fn scale_factor(&self) -> f32
The scale factor of the display the window is on.
Sourcepub fn display_id(&self) -> Option<DisplayId>
pub fn display_id(&self) -> Option<DisplayId>
The display the window is on, when the platform reports one.
Sourcepub fn is_fullscreen(&self) -> bool
pub fn is_fullscreen(&self) -> bool
Whether the window is fullscreen.
Auto Trait Implementations§
impl Freeze for WindowMetricsHandle
impl RefUnwindSafe for WindowMetricsHandle
impl Send for WindowMetricsHandle
impl Sync for WindowMetricsHandle
impl Unpin for WindowMetricsHandle
impl UnsafeUnpin for WindowMetricsHandle
impl UnwindSafe for WindowMetricsHandle
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 more