pub struct MONITORS;Expand description
Monitors service.
List monitor screens and configure the pixel density of a given monitor.
§Uses
Uses of this service:
§Start Position
Windows are positioned on a virtual screen that overlaps all monitors, but all position configuration is done relative to an specific parent monitor, it is important to track the parent monitor as it defines properties that affect the layout of the window. This service is used to provide information to implement this feature.
§Fullscreen
To set a window to fullscreen a monitor must be selected, by default it can be the one the window is at but
the users may want to select a monitor. To enter fullscreen exclusive the video mode must also be decided, all video
modes supported by the monitor are available in the MonitorInfo value.
§Real-Size Preview
Some apps, like image editors, may implement a feature where the user can preview the real dimensions of
the content they are editing, to accurately implement this you must known the real dimensions of the monitor screen,
unfortunately this information is not provided by display drivers. You can ask the user to measure their screen and
set the pixel density for the screen using the density variable, this value is then available in the LayoutMetrics
for the next layout. If not set, the default is 96.0ppi.
§Provider
This service is provided by the WindowManager extension, it will panic if used in an app not extended.
Implementations§
Source§impl MONITORS
impl MONITORS
Sourcepub fn monitor(&self, monitor_id: MonitorId) -> Option<MonitorInfo>
pub fn monitor(&self, monitor_id: MonitorId) -> Option<MonitorInfo>
Get monitor info.
Returns None if the monitor was not found or the app is running in headless mode without renderer.
Sourcepub fn available_monitors(&self) -> Var<Vec<MonitorInfo>>
pub fn available_monitors(&self) -> Var<Vec<MonitorInfo>>
List all available monitors.
Is empty if no monitor was found or the app is running in headless mode without renderer.
Sourcepub fn primary_monitor(&self) -> Var<Option<MonitorInfo>>
pub fn primary_monitor(&self) -> Var<Option<MonitorInfo>>
Gets the monitor info marked as primary.
Auto Trait Implementations§
impl Freeze for MONITORS
impl RefUnwindSafe for MONITORS
impl Send for MONITORS
impl Sync for MONITORS
impl Unpin for MONITORS
impl UnwindSafe for MONITORS
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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