pub struct VideoModeHandle { /* private fields */ }
Expand description
Describes a fullscreen video mode of a monitor.
Can be acquired with MonitorHandle::video_modes
.
Implementations§
Source§impl VideoModeHandle
impl VideoModeHandle
Sourcepub fn size(&self) -> PhysicalSize<u32>
pub fn size(&self) -> PhysicalSize<u32>
Returns the resolution of this video mode.
Examples found in repository?
examples/window.rs (line 272)
239 fn dump_monitors(&self, event_loop: &ActiveEventLoop) {
240 info!("Monitors information");
241 let primary_monitor = event_loop.primary_monitor();
242 for monitor in event_loop.available_monitors() {
243 let intro = if primary_monitor.as_ref() == Some(&monitor) {
244 "Primary monitor"
245 } else {
246 "Monitor"
247 };
248
249 if let Some(name) = monitor.name() {
250 info!("{intro}: {name}");
251 } else {
252 info!("{intro}: [no name]");
253 }
254
255 let PhysicalSize { width, height } = monitor.size();
256 info!(
257 " Current mode: {width}x{height}{}",
258 if let Some(m_hz) = monitor.refresh_rate_millihertz() {
259 format!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000)
260 } else {
261 String::new()
262 }
263 );
264
265 let PhysicalPosition { x, y } = monitor.position();
266 info!(" Position: {x},{y}");
267
268 info!(" Scale factor: {}", monitor.scale_factor());
269
270 info!(" Available modes (width x height x bit-depth):");
271 for mode in monitor.video_modes() {
272 let PhysicalSize { width, height } = mode.size();
273 let bits = mode.bit_depth();
274 let m_hz = mode.refresh_rate_millihertz();
275 info!(
276 " {width}x{height}x{bits} @ {}.{} Hz",
277 m_hz / 1000,
278 m_hz % 1000
279 );
280 }
281 }
282 }
Sourcepub fn bit_depth(&self) -> u16
pub fn bit_depth(&self) -> u16
Returns the bit depth of this video mode, as in how many bits you have available per color. This is generally 24 bits or 32 bits on modern systems, depending on whether the alpha channel is counted or not.
§Platform-specific
- Wayland / Orbital: Always returns 32.
- iOS: Always returns 32.
Examples found in repository?
examples/window.rs (line 273)
239 fn dump_monitors(&self, event_loop: &ActiveEventLoop) {
240 info!("Monitors information");
241 let primary_monitor = event_loop.primary_monitor();
242 for monitor in event_loop.available_monitors() {
243 let intro = if primary_monitor.as_ref() == Some(&monitor) {
244 "Primary monitor"
245 } else {
246 "Monitor"
247 };
248
249 if let Some(name) = monitor.name() {
250 info!("{intro}: {name}");
251 } else {
252 info!("{intro}: [no name]");
253 }
254
255 let PhysicalSize { width, height } = monitor.size();
256 info!(
257 " Current mode: {width}x{height}{}",
258 if let Some(m_hz) = monitor.refresh_rate_millihertz() {
259 format!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000)
260 } else {
261 String::new()
262 }
263 );
264
265 let PhysicalPosition { x, y } = monitor.position();
266 info!(" Position: {x},{y}");
267
268 info!(" Scale factor: {}", monitor.scale_factor());
269
270 info!(" Available modes (width x height x bit-depth):");
271 for mode in monitor.video_modes() {
272 let PhysicalSize { width, height } = mode.size();
273 let bits = mode.bit_depth();
274 let m_hz = mode.refresh_rate_millihertz();
275 info!(
276 " {width}x{height}x{bits} @ {}.{} Hz",
277 m_hz / 1000,
278 m_hz % 1000
279 );
280 }
281 }
282 }
Sourcepub fn refresh_rate_millihertz(&self) -> u32
pub fn refresh_rate_millihertz(&self) -> u32
Returns the refresh rate of this video mode in mHz.
Examples found in repository?
examples/window.rs (line 274)
239 fn dump_monitors(&self, event_loop: &ActiveEventLoop) {
240 info!("Monitors information");
241 let primary_monitor = event_loop.primary_monitor();
242 for monitor in event_loop.available_monitors() {
243 let intro = if primary_monitor.as_ref() == Some(&monitor) {
244 "Primary monitor"
245 } else {
246 "Monitor"
247 };
248
249 if let Some(name) = monitor.name() {
250 info!("{intro}: {name}");
251 } else {
252 info!("{intro}: [no name]");
253 }
254
255 let PhysicalSize { width, height } = monitor.size();
256 info!(
257 " Current mode: {width}x{height}{}",
258 if let Some(m_hz) = monitor.refresh_rate_millihertz() {
259 format!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000)
260 } else {
261 String::new()
262 }
263 );
264
265 let PhysicalPosition { x, y } = monitor.position();
266 info!(" Position: {x},{y}");
267
268 info!(" Scale factor: {}", monitor.scale_factor());
269
270 info!(" Available modes (width x height x bit-depth):");
271 for mode in monitor.video_modes() {
272 let PhysicalSize { width, height } = mode.size();
273 let bits = mode.bit_depth();
274 let m_hz = mode.refresh_rate_millihertz();
275 info!(
276 " {width}x{height}x{bits} @ {}.{} Hz",
277 m_hz / 1000,
278 m_hz % 1000
279 );
280 }
281 }
282 }
Sourcepub fn monitor(&self) -> MonitorHandle
pub fn monitor(&self) -> MonitorHandle
Returns the monitor that this video mode is valid for. Each monitor has a separate set of valid video modes.
Trait Implementations§
Source§impl Clone for VideoModeHandle
impl Clone for VideoModeHandle
Source§fn clone(&self) -> VideoModeHandle
fn clone(&self) -> VideoModeHandle
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for VideoModeHandle
impl Debug for VideoModeHandle
Source§impl Display for VideoModeHandle
impl Display for VideoModeHandle
Source§impl Hash for VideoModeHandle
impl Hash for VideoModeHandle
Source§impl Ord for VideoModeHandle
impl Ord for VideoModeHandle
Source§fn cmp(&self, other: &VideoModeHandle) -> Ordering
fn cmp(&self, other: &VideoModeHandle) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for VideoModeHandle
impl PartialEq for VideoModeHandle
Source§impl PartialOrd for VideoModeHandle
impl PartialOrd for VideoModeHandle
impl Eq for VideoModeHandle
impl StructuralPartialEq for VideoModeHandle
Auto Trait Implementations§
impl Freeze for VideoModeHandle
impl RefUnwindSafe for VideoModeHandle
impl Send for VideoModeHandle
impl Sync for VideoModeHandle
impl Unpin for VideoModeHandle
impl UnwindSafe for VideoModeHandle
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