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 289)
256 fn dump_monitors(&self, event_loop: &ActiveEventLoop) {
257 info!("Monitors information");
258 let primary_monitor = event_loop.primary_monitor();
259 for monitor in event_loop.available_monitors() {
260 let intro = if primary_monitor.as_ref() == Some(&monitor) {
261 "Primary monitor"
262 } else {
263 "Monitor"
264 };
265
266 if let Some(name) = monitor.name() {
267 info!("{intro}: {name}");
268 } else {
269 info!("{intro}: [no name]");
270 }
271
272 let PhysicalSize { width, height } = monitor.size();
273 info!(
274 " Current mode: {width}x{height}{}",
275 if let Some(m_hz) = monitor.refresh_rate_millihertz() {
276 format!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000)
277 } else {
278 String::new()
279 }
280 );
281
282 let PhysicalPosition { x, y } = monitor.position();
283 info!(" Position: {x},{y}");
284
285 info!(" Scale factor: {}", monitor.scale_factor());
286
287 info!(" Available modes (width x height x bit-depth):");
288 for mode in monitor.video_modes() {
289 let PhysicalSize { width, height } = mode.size();
290 let bits = mode.bit_depth();
291 let m_hz = mode.refresh_rate_millihertz();
292 info!(" {width}x{height}x{bits} @ {}.{} Hz", m_hz / 1000, m_hz % 1000);
293 }
294 }
295 }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 290)
256 fn dump_monitors(&self, event_loop: &ActiveEventLoop) {
257 info!("Monitors information");
258 let primary_monitor = event_loop.primary_monitor();
259 for monitor in event_loop.available_monitors() {
260 let intro = if primary_monitor.as_ref() == Some(&monitor) {
261 "Primary monitor"
262 } else {
263 "Monitor"
264 };
265
266 if let Some(name) = monitor.name() {
267 info!("{intro}: {name}");
268 } else {
269 info!("{intro}: [no name]");
270 }
271
272 let PhysicalSize { width, height } = monitor.size();
273 info!(
274 " Current mode: {width}x{height}{}",
275 if let Some(m_hz) = monitor.refresh_rate_millihertz() {
276 format!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000)
277 } else {
278 String::new()
279 }
280 );
281
282 let PhysicalPosition { x, y } = monitor.position();
283 info!(" Position: {x},{y}");
284
285 info!(" Scale factor: {}", monitor.scale_factor());
286
287 info!(" Available modes (width x height x bit-depth):");
288 for mode in monitor.video_modes() {
289 let PhysicalSize { width, height } = mode.size();
290 let bits = mode.bit_depth();
291 let m_hz = mode.refresh_rate_millihertz();
292 info!(" {width}x{height}x{bits} @ {}.{} Hz", m_hz / 1000, m_hz % 1000);
293 }
294 }
295 }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 291)
256 fn dump_monitors(&self, event_loop: &ActiveEventLoop) {
257 info!("Monitors information");
258 let primary_monitor = event_loop.primary_monitor();
259 for monitor in event_loop.available_monitors() {
260 let intro = if primary_monitor.as_ref() == Some(&monitor) {
261 "Primary monitor"
262 } else {
263 "Monitor"
264 };
265
266 if let Some(name) = monitor.name() {
267 info!("{intro}: {name}");
268 } else {
269 info!("{intro}: [no name]");
270 }
271
272 let PhysicalSize { width, height } = monitor.size();
273 info!(
274 " Current mode: {width}x{height}{}",
275 if let Some(m_hz) = monitor.refresh_rate_millihertz() {
276 format!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000)
277 } else {
278 String::new()
279 }
280 );
281
282 let PhysicalPosition { x, y } = monitor.position();
283 info!(" Position: {x},{y}");
284
285 info!(" Scale factor: {}", monitor.scale_factor());
286
287 info!(" Available modes (width x height x bit-depth):");
288 for mode in monitor.video_modes() {
289 let PhysicalSize { width, height } = mode.size();
290 let bits = mode.bit_depth();
291 let m_hz = mode.refresh_rate_millihertz();
292 info!(" {width}x{height}x{bits} @ {}.{} Hz", m_hz / 1000, m_hz % 1000);
293 }
294 }
295 }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 duplicate 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 UnsafeUnpin 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