Skip to main content

PhysicalRect

Struct PhysicalRect 

Source
pub struct PhysicalRect {
    pub x: i32,
    pub y: i32,
    pub width: u32,
    pub height: u32,
}
Expand description

An axis-aligned rectangle in device pixels.

Each use names its space. Monitor geometry is in the desktop’s, where the origin is the desktop origin rather than a window corner and coordinates can be negative (a monitor placed left of the primary one); Shell::set_text_input_area is in a window’s client area.

Fields§

§x: i32

Left edge, in device pixels of the space the use names.

§y: i32

Top edge, in device pixels of the space the use names.

§width: u32

Width in device pixels.

§height: u32

Height in device pixels.

Implementations§

Source§

impl PhysicalRect

Source

pub const fn new(x: i32, y: i32, width: u32, height: u32) -> Self

A rectangle at (x, y) of width × height device pixels.

Source

pub const fn size(self) -> PhysicalSize

The rectangle’s size.

Source

pub const fn contains(self, x: i32, y: i32) -> bool

Whether a desktop-space point lies inside.

Half-open: the left and top edges belong to this rectangle, the right and bottom ones do not. Monitors tile edge to edge — the standard side-by-side layout is (0,0,1920,1080) next to (1920,0,1920,1080) — so an inclusive far edge would put the first column of the second monitor inside both, and the monitor lookup in the X11 backend returns the first match. Half-open makes the tiling a partition.

The subtraction is widened to i64 before it happens, not after: a rectangle at a negative origin and a point near i32::MAX overflow an i32 difference, which panics in debug and wraps to “inside” in release.

Source

pub fn rounded(self, radius: u32) -> Vec<Self>

This rectangle with its corners rounded to radius device pixels, as the union of rectangles Shell::set_input_region takes.

An outer bound: every pixel a corner’s quarter circle covers at all is inside, so a panel drawn with antialiased rounded corners keeps its whole edge — which matters on Win32, where the region also clips what the window draws. Neighbouring rows with the same inset are merged, so the count grows with the radius rather than the height, and the rectangles never overlap. The radius is clamped to half the shorter side; an empty rectangle gives none.

Trait Implementations§

Source§

impl Clone for PhysicalRect

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 Copy for PhysicalRect

Source§

impl Debug for PhysicalRect

Source§

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

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

impl Default for PhysicalRect

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for PhysicalRect

Source§

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

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

impl Eq for PhysicalRect

Source§

impl Hash for PhysicalRect

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PhysicalRect

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 PhysicalRect

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<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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.