Skip to main content

Placement

Struct Placement 

Source
pub struct Placement {
    pub monitor: MonitorSelector,
    pub area: Area,
    pub fit: Fit,
    pub opacity: f32,
    pub always_on_top: bool,
    pub fall_back_to_primary: bool,
}
Expand description

What to show, where, and how.

Fields§

§monitor: MonitorSelector

Which monitor.

§area: Area

What part of it.

§fit: Fit

How the picture sits inside that area. Ignored for Area::Corners, which pins the picture’s own corners and so has no spare room to fit anything into.

§opacity: f32

0.0 to 1.0. The “translucent” the name promises.

§always_on_top: bool

Whether to keep this above other windows. Only meaningful when vtome owns the window.

§fall_back_to_primary: bool

Whether to fall back to the primary monitor when the selector finds nothing, rather than failing.

On by default: a show that loses a projector should carry on somewhere visible, and say so, rather than stop.

Implementations§

Source§

impl Placement

Source

pub fn new(monitor: MonitorSelector) -> Self

A full-screen placement on the monitor a selector names.

Source

pub fn area(self, rect: Rect) -> Self

A rectangle of that monitor, in its own coordinates.

Source

pub fn corners(self, quad: Quad) -> Self

Four corners of that monitor, in its own coordinates.

Source

pub fn corners_normalized(self, quad: Quad) -> Self

Four corners as fractions of the monitor, 0.0 to 1.0.

Prefer this when the monitor’s size is not known yet — see Area::NormalizedCorners.

Source

pub fn keystone(self, inset: f64) -> Self

A symmetric keystone over the whole monitor, narrowing the top edge by inset of the width at each end.

The projector-aimed-upwards case, in one call and without needing to know the monitor’s size. 0.1 is a mild correction; 0.4 is nearly a triangle.

Source

pub fn fit(self, fit: Fit) -> Self

How the picture sits inside the area.

Source

pub fn opacity(self, opacity: f32) -> Self

How opaque, from 0.0 to 1.0.

Source

pub fn always_on_top(self, on_top: bool) -> Self

Whether to stay above other windows.

Source

pub fn require_monitor(self, required: bool) -> Self

Whether a missing monitor is an error rather than a fallback.

Source

pub fn resolve( &self, source_width: u32, source_height: u32, monitors: &[Monitor], ) -> Result<ResolvedPlacement>

Works out where a source_width × source_height picture actually goes.

Everything in the result is in desktop coordinates, so a caller can hand it straight to a window system without knowing which monitor it came from.

§Errors

Error::NoSuchMonitor if nothing matches and fallback is off, Error::Placement for an opacity outside 0..=1, an empty rectangle, or a quad that is not convex.

Trait Implementations§

Source§

impl Clone for Placement

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Placement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Placement

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Placement

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.