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 259)
226 fn dump_monitors(&self, event_loop: &ActiveEventLoop) {
227 info!("Monitors information");
228 let primary_monitor = event_loop.primary_monitor();
229 for monitor in event_loop.available_monitors() {
230 let intro = if primary_monitor.as_ref() == Some(&monitor) {
231 "Primary monitor"
232 } else {
233 "Monitor"
234 };
235
236 if let Some(name) = monitor.name() {
237 info!("{intro}: {name}");
238 } else {
239 info!("{intro}: [no name]");
240 }
241
242 let PhysicalSize { width, height } = monitor.size();
243 info!(
244 " Current mode: {width}x{height}{}",
245 if let Some(m_hz) = monitor.refresh_rate_millihertz() {
246 format!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000)
247 } else {
248 String::new()
249 }
250 );
251
252 let PhysicalPosition { x, y } = monitor.position();
253 info!(" Position: {x},{y}");
254
255 info!(" Scale factor: {}", monitor.scale_factor());
256
257 info!(" Available modes (width x height x bit-depth):");
258 for mode in monitor.video_modes() {
259 let PhysicalSize { width, height } = mode.size();
260 let bits = mode.bit_depth();
261 let m_hz = mode.refresh_rate_millihertz();
262 info!(" {width}x{height}x{bits} @ {}.{} Hz", m_hz / 1000, m_hz % 1000);
263 }
264 }
265 }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 260)
226 fn dump_monitors(&self, event_loop: &ActiveEventLoop) {
227 info!("Monitors information");
228 let primary_monitor = event_loop.primary_monitor();
229 for monitor in event_loop.available_monitors() {
230 let intro = if primary_monitor.as_ref() == Some(&monitor) {
231 "Primary monitor"
232 } else {
233 "Monitor"
234 };
235
236 if let Some(name) = monitor.name() {
237 info!("{intro}: {name}");
238 } else {
239 info!("{intro}: [no name]");
240 }
241
242 let PhysicalSize { width, height } = monitor.size();
243 info!(
244 " Current mode: {width}x{height}{}",
245 if let Some(m_hz) = monitor.refresh_rate_millihertz() {
246 format!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000)
247 } else {
248 String::new()
249 }
250 );
251
252 let PhysicalPosition { x, y } = monitor.position();
253 info!(" Position: {x},{y}");
254
255 info!(" Scale factor: {}", monitor.scale_factor());
256
257 info!(" Available modes (width x height x bit-depth):");
258 for mode in monitor.video_modes() {
259 let PhysicalSize { width, height } = mode.size();
260 let bits = mode.bit_depth();
261 let m_hz = mode.refresh_rate_millihertz();
262 info!(" {width}x{height}x{bits} @ {}.{} Hz", m_hz / 1000, m_hz % 1000);
263 }
264 }
265 }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 261)
226 fn dump_monitors(&self, event_loop: &ActiveEventLoop) {
227 info!("Monitors information");
228 let primary_monitor = event_loop.primary_monitor();
229 for monitor in event_loop.available_monitors() {
230 let intro = if primary_monitor.as_ref() == Some(&monitor) {
231 "Primary monitor"
232 } else {
233 "Monitor"
234 };
235
236 if let Some(name) = monitor.name() {
237 info!("{intro}: {name}");
238 } else {
239 info!("{intro}: [no name]");
240 }
241
242 let PhysicalSize { width, height } = monitor.size();
243 info!(
244 " Current mode: {width}x{height}{}",
245 if let Some(m_hz) = monitor.refresh_rate_millihertz() {
246 format!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000)
247 } else {
248 String::new()
249 }
250 );
251
252 let PhysicalPosition { x, y } = monitor.position();
253 info!(" Position: {x},{y}");
254
255 info!(" Scale factor: {}", monitor.scale_factor());
256
257 info!(" Available modes (width x height x bit-depth):");
258 for mode in monitor.video_modes() {
259 let PhysicalSize { width, height } = mode.size();
260 let bits = mode.bit_depth();
261 let m_hz = mode.refresh_rate_millihertz();
262 info!(" {width}x{height}x{bits} @ {}.{} Hz", m_hz / 1000, m_hz % 1000);
263 }
264 }
265 }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 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