pub struct Monitor { /* private fields */ }
Expand description
Monitor struct containing data about a monitor on the system
Use Screen::get_monitors
to return a Vec<Monitor>
of all the monitors on the system
Implementations§
Source§impl Monitor
impl Monitor
Sourcepub fn is_primary(&self) -> bool
pub fn is_primary(&self) -> bool
Returns true if the monitor is the primary monitor. The primary monitor has its origin at (0, 0) in virtual screen coordinates.
Sourcepub fn virtual_rect(&self) -> Rect
pub fn virtual_rect(&self) -> Rect
Returns the monitor rectangle in virtual screen coordinates.
Examples found in repository?
examples/sub_window.rs (line 280)
274 fn paint(&mut self, ctx: &mut PaintCtx, _data: &(), env: &Env) {
275 let sz = ctx.size();
276
277 let monitors = Screen::get_monitors();
278 let all = monitors
279 .iter()
280 .map(|x| x.virtual_rect())
281 .fold(Rect::ZERO, |s, r| r.union(s));
282 if all.width() > 0. && all.height() > 0. {
283 let trans = Affine::scale(f64::min(sz.width / all.width(), sz.height / all.height()))
284 * Affine::translate(all.origin().to_vec2()).inverse();
285 let font = env.get(theme::UI_FONT).family;
286
287 for (i, mon) in monitors.iter().enumerate() {
288 let vr = mon.virtual_rect();
289 let tr = trans.transform_rect_bbox(vr);
290 ctx.stroke(tr, &Color::WHITE, 1.0);
291
292 if let Ok(tl) = ctx
293 .text()
294 .new_text_layout(format!(
295 "{}:{}x{}@{},{}",
296 i,
297 vr.width(),
298 vr.height(),
299 vr.x0,
300 vr.y0
301 ))
302 .max_width(tr.width() - 5.)
303 .font(font.clone(), env.get(theme::TEXT_SIZE_NORMAL))
304 .text_color(Color::WHITE)
305 .build()
306 {
307 ctx.draw_text(&tl, tr.center() - tl.size().to_vec2() * 0.5);
308 }
309 }
310 }
311 }
Sourcepub fn virtual_work_rect(&self) -> Rect
pub fn virtual_work_rect(&self) -> Rect
Returns the monitor working rectangle in virtual screen coordinates. The working rectangle excludes certain things like the dock and menubar on mac, and the taskbar on windows.
Trait Implementations§
impl StructuralPartialEq for Monitor
Auto Trait Implementations§
impl Freeze for Monitor
impl RefUnwindSafe for Monitor
impl Send for Monitor
impl Sync for Monitor
impl Unpin for Monitor
impl UnwindSafe for Monitor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
Source§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.